Javascript examples for highcharts:Line Chart
Pan one of multiple Y axis for line chart
<html> <head> <title>Highcharts Demo</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> $(function () {/*from w w w . j ava2 s.co m*/ var chart = new Highcharts.Chart({ chart: { renderTo: 'container', height: 500 }, xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, yAxis: [{ min: -50, tickInterval: 500, startOnTick:false, endOnTick:false },{ min: -50, opposite:true, tickInterval: 500, startOnTick:false, endOnTick:false }], series: [{ data: [929.9, 971.5, 1106.4, 1129.2, 1144.0, 1176.0, 1135.6, 1148.5, 2216.4, 1194.1, 995.6, 954.4] },{yAxis:1, data: [929.9, 971.5, 1106.4, 1129.2, 1144.0, 1176.0, 1135.6, 1148.5, 2216.4, 1194.1, 995.6, 954.4] }] }); var isDragging = false; var mouseY; $(chart.container) .mousedown(function(event) { mouseY=event.offsetY; yData=chart.yAxis[0].getExtremes(); yDataRange=yData.max-yData.min; isDragging=true; }) .mousemove(function(e) { var wasDragging = isDragging; if (wasDragging) { yVar=mouseY-e.pageY; if(yVar<-20 || yVar > 20) { mouseY = e.pageY; yVarDelta=yVar/10*yDataRange; yVarDelta = chart.yAxis[0].translate(e.pageY) - chart.yAxis[0].translate(e.pageY - yVarDelta); chart.yAxis[0].setExtremes((yData.min-yVarDelta),(yData.max-yVarDelta)); } } }) .mouseup(function (e) { isDragging = false; }); }); </script> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <div id="container" style="height: 300px"></div> </body> </html>