javascript - Onclick event for hightcharts range selector -


here have requirement in highcharts have range selector 1d,1w,1m,3m,6m,all when click of range selector have response data server means ajax call onclick range selector. have below fiddle file has code . has problem adding data using

$.getjson('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) {      if(data != null) {         chart.addseries({             name : 'energy consumption',             id   : 'energyconsumption',             data : data         },{             name : 'outdoor temperature',             id   : 'outdoordata',             data : data         }         );            }  });  

the above code working if changed data static or jquery callback response not working. fiddle file below http://jsfiddle.net/uegzk/4/

please me on in advance,

instead of reset_all_buttons function, calling chart.rangeselector.clickbutton(index) apply highstock's default behavior. have use case i'm switching between daily , intraday stock prices. when switch 3day view, want more granular intraday prices equidistant datapoints. on longer-range views, want xaxis ordinal:true points time-based. here's load event (typescript)

chart: {     events: {         load: function() {             var chart: highchartschartobject = <highchartschartobject>this;             var replaceseries = (serieses: highchartsseriesoptions[]): void => {                 while(chart.series.length > 0) {                     chart.series[0].remove(false);                 }                 _.each(serieses, (series: highchartsseriesoptions) => {                     chart.addseries(series, false);                 });                 chart.redraw();             }             var buttons = chart.rangeselector.buttons;             buttons[0].on("click", function(e) {                 if (chart.rangeselector.selected !== 0) {                     _.each(this.xaxis, (xaxis: any): void => {                         xaxis.options.ordinal = false;                         xaxis.options.minrange = undefined;                     });                     replaceseries(chartdataservice.builddataseries(true));                 }                 chart.rangeselector.clickbutton(0);             });             _.each(buttons, (button, index: number): void => {                 if (index !== 0) {                     button.on("click", function(e) {                         if (chart.rangeselector.selected === 0) {                             _.each(this.xaxis, (xaxis: any): void => {                                 xaxis.options.ordinal = true;                                 xaxis.options.minrange = 1000 * 60 * 60 * 24 * 7; // 1wk daily data                             });                             replaceseries(chartdataservice.builddataseries(false));                         }                         chart.rangeselector.clickbutton(index);                     });                 }             })         }     } } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -