All,
I'm using Highcharts in a web app I'm working on. One of the requirements is that users should be able to click a button and "flip" or reverse the Y axis.
In other words - when the user clicks a button - the y Axis values should flip from:
highest at the top / lowest at the bottom
to
lowest at the top / highest at the bottom
When you first create the chart - this is possible using the "reversed" property of the y Axis:
.reversed
Example here: /
However - if I attempt to do this programmatically with JavaScript using the options object (e.g., on a button click), it doesn't seem to work:
chart.options.yAxis.reversed = !chart.options.yAxis.reversed;
chart.redraw();
Here's a jsfiddle I set up to test: /
Is this possible?
Thanks in advance!
All,
I'm using Highcharts in a web app I'm working on. One of the requirements is that users should be able to click a button and "flip" or reverse the Y axis.
In other words - when the user clicks a button - the y Axis values should flip from:
highest at the top / lowest at the bottom
to
lowest at the top / highest at the bottom
When you first create the chart - this is possible using the "reversed" property of the y Axis:
http://api.highcharts./highcharts#yAxis.reversed
Example here: http://jsfiddle/ZgVNS/
However - if I attempt to do this programmatically with JavaScript using the options object (e.g., on a button click), it doesn't seem to work:
chart.options.yAxis.reversed = !chart.options.yAxis.reversed;
chart.redraw();
Here's a jsfiddle I set up to test: http://jsfiddle/4JZxS/6/
Is this possible?
Thanks in advance!
Share Improve this question asked Jan 7, 2013 at 23:07 mattstuehlermattstuehler 9,33218 gold badges81 silver badges115 bronze badges 2-
@oftopic
: It's my jsfiddle or it's not showing loaded code ? – Ricardo Lohmann Commented Jan 8, 2013 at 2:03 - @RicardoLohmann Mine is not working at Chrome. In firefox I can see the code. – Felipe Fonseca Commented Jan 8, 2013 at 11:45
2 Answers
Reset to default 6You can use the Axis.update() method:
$(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
reversed: false
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
var reversed = chart.options.yAxis.reversed;
// the button action
$('#button').click(function () {
chart.yAxis[0].update({
reversed: !reversed
});
reversed = !reversed;
});
});
Here's the updated JSFiddle: http://jsfiddle/4JZxS/15/
I don't think it's possible.
My advice is to destroy the chart using chart.destroy()
and create the new one with the reversed property, like in this fiddle
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744805645a4594760.html
评论列表(0条)