There, bizarrely, doesn't seem to be a way to target which Y axis a series is added to using the chart.addSeries() method. Nothing here (http://api.highcharts.com/highstock#Chart.addSeries%28%29) about targeting axes. This results in lines destined to be plotted against the oposite axis being incorrectly plotted in the left hand one; something I would have thought to be a basic prerequisite of the method.
Has anyone seen any hacks or plugins that might solve this or know where to go in the source to fix this?
That's what the yAxis property is used to specify in the series configuration object you pass into addSeries as the options parameter.
You can add serie as you define series in Highcharts, so you can use yAxis index. Take look at example http://jsfiddle.net/68Fp4/1/
$('#button').click(function() {
chart.addSeries({
name: 'ADBE',
data: ADBE,
yAxis:1
});
});
Related
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
}],
This a sample in highcharts for what exactly i need to create. The issue i am facing is the blue color should be in the area chart series, but highchart is applying the color at the top (outside the series). I apologize if i am not able to explain the issue correctly.
This happens when i use reversed: true, in yAxis.
Please help or let me know if you need me to explain the issue in different words.
When you reverse the axis, the data reverses as well, to match.
I would probably do this by using negative values as the axis min/max, and the data points.
Then, in the axis label formatter, return the absolute value (removing the '-').
labels: {
formatter: function() {
return Math.abs(this.value);
}
}
You can use the same formatting method to fix the tool tips, data labels, and anything else that might need it.
Example:
http://jsfiddle.net/jlbriggs/MybCM/27/
Highcharts' inferred categories for the yAxis aren't working like I'd expect. Setting
yAxis: { type: 'category' } and naming data points { name: 'Green', y: 1, x: 2 } doesn't set the yAxis labels to the name 'Green'. Is it possible to do this? What am I doing wrong?
Fiddle
That is correct. It will not work that way in Highcharts (with possible exception for pie charts maybe).
You need to set your categories explicitly, and either order the data points in order of their respective category, or supply the category array index as the appropriate x or y value.
example:
http://jsfiddle.net/jlbriggs/vtcyu3wt/
Edit: expanded answer based on comment
Ok, I was unaware of the change pointed out in your comment below. Per the API:
'Since Highcharts 3.0, categories can also be extracted by giving each point a name and setting axis type to "category"'.
There are two things going on here though:
1) from what I can see, this only works on the x axis, and not the y (from my very limited testing).
2) even if it did work on the y axis, you are supplying too much info. The category name takes the place of the x value, so you can supply a name, and a y value. You are giving it a name, an x value, and a y value, so I don't think Highcharts could parse that even if it did work for the y axis.
I have a series of points that has fast changing values, which makes it very spiky and uneasy to read when zooming out.
I would like to know if there is a way to draw above the already existing series, another one that would represent the average of, for exemple: every 10 points, or every point in a minute?
I've looked into dataGrouping but can't seem to make it work, is that what I'm looking for ?
Thanks for reading.
There is no current built-in method to do this. You would need to create a second series that is the running average and add it to the chart.
The main issue here is that HS has dataGrouping enabled by default for all series. So, when you add your second series that has dataGrouping enabled with params you want - it is also applied to the initial series. You only see one series on the chart because the 2 series are identical and overlap each other.
To fix this set dataGrouping off in the "real" series. Then have dataGrouping on in the averaged series. See this example.
...
series: [{
name: 'MSFT',
data: MSFT,
dataGrouping: {
enabled: false
}
}]
...
Whenever I change the x axis of an existing chart from linear to logarithmic, the chart doesn't scale in the same manner that it does when the Y axis is changed. To be clear, the axis does indeed change from linear to logarithmic, but the Y axis scale does not adjust and appears that it cannot be adjusted to the new settings.
I think that this may be a problem with HighCharts.
The fiddle demonstrating the problem is here. Note that the command that I am using to change the axis is :
chart.xAxis[0].update({ type: "logarithmic" });
I may need to include something in that command, but maybe my approach to the problem is too linear and I need to rescale my view (that was supposed to be humorous).
Looks like a bug in Highcharts, reported here. Thanks!