Highcharts: is there a way to offset lines slightly so same coordinates do not overlap? - highcharts

I have a line chart with a limited Y axis (1-5). There are six different lines represented on the chart (3 each from two different users: measuring feeling 1, feeling 2 and feeling 3 from 1-5).
When users enter the same value over time (for instance, ranking feelings 1 and 2 as 5 for several weeks), the two lines completely overlap and you can only see one.
Is there a way I can offset a particular line by say, a couple pixels up and to the right so if there are two different lines representing same values over time, I can see both at once?

Using pointPlacement it is possible to slightly offset each series, so points with the same values do not overlap each other. The tooltip will still work as if points would overlap, so setting shared to true should help.
Example: https://jsfiddle.net/BlackLabel/3mhyojtd/1/
Another option that will allow not shared tooltip would be to use scatter type series with lineWidth set to 2, to imitate line type series.
Example with scatter series: https://jsfiddle.net/BlackLabel/r6pL4f2j/

Related

Highcharts: make y-axis extremes the same for two data series with different units

I have a chart where two graphs/series have different units. Therefore the y-Axis is different and the extremes are calculated separately from each other.
Is there a way to tell Highcharts to use the same scale, despite the different units, across all graphs/series?
Below is the chart. Relevant y-axis are the ones on the right, as an example. The units are different: "W/m^2" and "kW/kWp", however I want the scale to be the same.
Of course, one way would be a manual approach: in my controller, to go through all the data series and check the overall minimum and maximum value of all data series and then apply the extremes manually via
chart.yAxis[i].setExtremes(min, max)
but I was wondering if Highcharts has any way, like a configuration option, to achieve this.
I didn't find anything in the docs so far.
Thanks.
There is an option to achieve that. You can link one axis to another via linkedTo property.
From API:
linkedTo : Number
Index of another axis that this axis is linked to. When an axis is linked to a master axis, it will take the same extremes as the master, but as assigned by min or max or by setExtremes. It can be used to show additional info, or to ease reading the chart by duplicating the scales.
http://api.highcharts.com/highcharts/yAxis.linkedTo
Example: http://jsfiddle.net/n8tokqru/
yAxis: [{
}, {
linkedTo: 0
}],

How Do I Keep Bar Width the Same Across Multiple Charts?

Suppose I want to create two charts with horizontal bars. The names of the objects are listed on the y-axis and the horizontal bars represents some quantity. The first chart has 100 items and the second chart has 5 items.
When I create the charts the horizontal bars have different widths. I'd like the bars to be the same width across all of my charts.
I know I can try different values for the height parameter to the AddShape function. But that seems time-consuming and unreliable since the number of items can change. I'd like to do something like:
Chart.BarWidth = 10
The "thickness" of each bar will be primarily determined by the number of data points that need to be plotted. The more data points to plot, the thinner the bars will be. There are some options to further tweak them, such as IChartGroup.GapWidth, and you're welcome to try to adjust this so that both charts match. But I suspect that it will be very difficult to do this reliably, particularly if the number of plotted points is expected to change over time.
To maintain the same bar thickness for multiple charts, I think your best option will be to ensure both charts' series refer to the same size range. So if your first chart refers to 100 cells, have your second chart refer to 100 cells, even if only 5 are populated with values. The empty cells should not plot but will still take up space and therefore maintain consistent bar thicknesses between your two charts.

Labels on Grid lines in HighchartsJS

I'm using highcharts and trying to add labels to the grid lines of a polar chart, however, I can only add labels to the first axis (which is the y-axis in the cartesian coordinate system).
Polar charts are not well covered (as well as labels on grids) in the highcharts docs. My current approach is placing the labels manually on the correct positions, which will get cumbersome due to dynamic number of categories and sizes of my chart. Additionally, exporting the chart will not support labels anymore.
Background: Let's assume I am selling tickets for clubbing from Monday to Friday (no weekends, bad choice) for the clubs Green, Black, and Blue. Now, I want to know which club performed best on each day, and also how many tickets are sold in total. Therefore, I'd like to apply different scalings to each axis as attached (manually manipulated). I'm currently normalizing the ticket sales for each day to 0…1 which does the job for comparing each single day, but I can't apply the different labels to the axis.
One way might be to add more panes (with startAngle correction) and yAxes with different scales, so dataLabels are showing as in your image.
Example: http://jsfiddle.net/6b9m7Lvb/
Problem - each yAxis can have only a single pane, each series can have only a single yAxis, so there is one scale for a series - no matter what category.
Another way could be to do the same, but have all yAxes linked to each other, so scale is the same for all. Next it is possible to change axis labels and tooltip display, to match your image.
Example: http://jsfiddle.net/6b9m7Lvb/1/

Categories positions in highcharts

I'm trying to implement distribution histogram in highcharts. That is simple histogram but I want to put percents values as categories between the columns and '0%' in the middle of the middle column. I'm trying to move categories with tick positions and using multiple axis but that doesn't help.
That what I got now, hope that helps to understand what I'm trying to do.
[jsfiddle](http://jsfiddle.net/cwbyyang/)
I need to move '-25%', '-10%', '-5%', '5%', '10%', '25%' to ticks grid lines.
It doesn't make sense with the numbers given (the distance between 0 and 5% is 1.5 times the distance between 5 and 10%), but using three x axes and the x property of the labels, this is possible.
example:
http://jsfiddle.net/cwbyyang/2/
labels: {
x:-40
}

Highcharts Columnrange Questions (multiple y-axes and column widths)

I'm in the process of evaluating Highcharts as a replacement for our current platform, and have some questions about how we can replicate one of our existing charts:
I've been able to recreate the basic floating stacked column chart, but need help with some of our specific features.
1) Is is possible to replicate the multiple y-axes with the columns displayed to the right of each within a single chart? If not, I suppose we could do 3 charts next to one another - and draw our own titles above (and data table below). If we go this route, is there a way to group all these elements in a single "container"? We need to export these charts to images and need to end up with a single image that looks like the one attached.
2) How would I create the inner box within each column? Do I need to draw it myself, or can I create another column series with a border and transparent fill and somehow set the width of the column to be less than the width of the main columns (note that the number of columns on each chart is dynamic, so the column widths can't be a fixed size. i.e. the inner box width needs to be a percentage of the main column width)?
3) Assuming #2 is possible, I could probably use the same technique to plot the horizontal line - just make the height 0 (or very small) and make the bar wider instead of smaller. Is there a better way?
4) How do I get the x coordinates of the columns so we can align our data table under each column?
5) Can I separate the individual points within the column. You'll notice in my jsfiddle, product 1 and product 2 are vertically aligned in the center of the column. Can I spread them out within each column as the 2 points are in the screenshot?
Thanks in advance for advice on all or any of the above.
Mike
1) You can use multiple yAxis, see the example
2) You can use renderer or mix column/column range and border parameter, example
plotOptions: {
columnrange: {
pointPadding:0.2,
color: 'rgba(255,255,255,0)',
borderColor: '#303030'
}
},
3) Use renderer, as above or scatter series with customied marker
4) Column is shape in point.element.graphic, so you can extract it.
5) as far as I know, it is not possible

Resources