See this JSFiddle. How do I get the y-axis zero to align?
标签:
highcharts
相关问题
- Issues using highcharts node export server from Cl
- Rails collecting and rendering JSON data in to a H
- Create highchart density with more than 2 groups
- Highcharts / Highstock step line without vertical
- Highcharts Synchronized charts display tooltip
相关文章
- Change color of bars depending on value in Highcha
- Changing Highcharts data series type dynamically
- Set highcharts y-axis min value to 0, unless there
- high chart sample
- Highchart's gauge with gradient plotband
- HighCharts pie chart X-axies values are not displa
- Why Highcharts gets different size on Safari?
- Ajax JSON in to Highcharts Pie Chart
The simplest way is to just provide the same min/max for each axis. It would be a pretty simple to determine a good min/max based on the data before the plot call (combine the arrays, take the min/max round down/up to nearest int, would be my approach).
Updated fiddle.
You can set min / max value for first yAxis and use linkedTo to second axis, but I'm not sure if you expect this effect:
http://jsfiddle.net/qkDXv/2/
An easy workaround until this feature is added is to make sure the ratio of max/min is the same for both axis. For example is the min and max for the primary y-axis are -20 and 40 for example, then the max/min ratio is -2. Now say we have a max value for the secondary y-axis of 25. If we set the min for this axis to 25/-2 (=-12.5), then the y=0 line will be aligned for the two axes.
Would be much nicer to have a flag to set this automatically though ;-)
EDIT: Some thing like below worked OK for me:
I know it's been two year. However, I did found a better solution compare to exist solution which was given in previous answers. My solution is still using setExtremes to set min, max for yAxis but with better exception handling which are extremely good to
show()
andhide()
any plot. Solution: linkGithub: link
The short answer is: you can't.
You can tweak axis scaling, padding, and tick positions and the like and possibly get what you want, but there is no setting to accomplish this.
There is a feature request though, that you can add your votes and/or comments to:
http://highcharts.uservoice.com/forums/55896-general/suggestions/2554384-multiple-axis-alignment-control
EDIT: OTOH, I have to mention that dual axis charts like this are most often a very poor way to show the data, and invites the user to make comparisons that aren't valid.
While most people are always trying to put everything in one chart, multiple charts are very often the better solution.
FWIW
you can do it easily by following the below code-
you just need to find which point of opposite y -axis meets zero of first y-axis and set the min of opp y-axis to (that point * -1)
In my case yaxis[1] forms the main y-axis and yaxis[0] forms the opposite y-axis