javascript - Displays Highcharts with portion of given data -
so i'm using "stacked column", given example
$("#chart_container").highcharts({ chart: { type: 'column' }, xaxis: { categories: ['one', 'two', 'three', 'four', 'five', 'six'] }, series: [{ name: 'red', data: [1,1,22,4,2,5] }] }) so scenario display two, three, four on chart , whenever user click on left/right arrows , data shifted left or right. example , when user click left arrow, chart display one, two, three
is there anyway can achieve highcharts itself? ( without custom javascript added )
as far know there's nothing built in support this, rather small amount of javascript combined of highcharts functions enough.
for example, utilizing jquery highcharts setextremes, this:
$(document).keydown(function(e) { switch(e.which) { case 37: // left chart.xaxis[0].setextremes(chart.xaxis[0].min-1, chart.xaxis[0].max-1); break; case 39: // right chart.xaxis[0].setextremes(chart.xaxis[0].min+1, chart.xaxis[0].max+1); break; default: return; // exit handler other keys } e.preventdefault(); // prevent default action (scroll / move caret) }); see this jsfiddle demonstration of in action. cap @ start , end add logic depending on categories , span width in this example.
Comments
Post a Comment