问题
I am trying to plot xy line in which y axis is reversed and I am getting plot but mouse event
I am unable to correct it it is showing reverse event, and I want to find min and mix of axis automatically how this can be done? And how to bring x axis on top?
This is my code:
JS
$(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
zoomType: 'xy',
marginLeft: 50,
marginBottom: 90
},
// How to get minmax automatically zooming is a issue
// reverse is true
yAxis: {
reversed: true,
min:0,max:50
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [
{
name: '01-Jan-2014',
data: [[30,0],[28,10]]
}
]
});
});
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
Here is a JS Fiddle.
Whether its possible to pass string inside series ? may be my question is silly please tell me whether its possible, like below I am interested
string mystring = "{
name: '01-Jan-2014',
data: [[28, 10],[30, 0]]
},
{
name: '01-Jan-2014',
data: [[28, 10],[30, 0]]
}"
In series part of code I would like to do like below
series: [
mystring
]
Expected output from this array, sorted y axis GOOD PATTERN - Fiddle but mouse movement is not working
data:[
[ 25.290,1.000 ],
[ 25.240,2.000 ],
[ 25.210,3.000 ],
[ 25.190,4.000 ],
[ 25.180,5.000 ],
[ 25.170,6.000 ],
[ 25.160,7.000 ],
[ 25.310,8.000 ],
[ 25.210,9.000 ],
[ 25.170,10.000 ],
[ 25.160,11.000 ],
[ 25.160,12.000 ],
[ 25.150,13.000 ],
]
here I sorted xaxis - mouse event is alright but plot pattern (line) is not the one which I expect BAD PATTERN - Fiddle
data:[
[ 25.150,13.000 ],
[ 25.160,12.000 ],
[ 25.160,11.000 ],
[ 25.160,7.000 ],
[ 25.170,6.000 ],
[ 25.170,10.000 ],
[ 25.180,5.000 ],
[ 25.190,4.000 ],
[ 25.210,9.000 ],
[ 25.210,3.000 ],
[ 25.240,2.000 ],
[ 25.290,1.000 ],
[ 25.310,8.000 ],
]
回答1:
Answers:
- you have errors in JS console - fix them (sort data ascending by x-value!)
- to set min and max, just don't set anything, Highcharts will calculate extremes
- to display xAxis on top, set
opposite: true
Demo: http://jsfiddle.net/2xLvY/1/
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
zoomType: 'xy',
marginLeft: 50,
marginBottom: 90
},
yAxis: {
reversed: true,
//min: 0,
//max: 50
},
plotOptions: {
series: {
stacking: 'normal'
}
},
xAxis: {
opposite: true
},
series: [{
name: '01-Jan-2014',
data: [
// NOTE: proper order, first x-value is lower that second
[28, 10],
[30, 0]
]
}]
});
来源:https://stackoverflow.com/questions/22524584/how-to-correct-mouse-event-in-highcharts