In this article, we make the dynamic chart, we often need more than one chart, if each chart with the service interface to do an interaction is too frequent, this is a pressure both before and after the background, this article describes a one-time access to return multiple sets of data to reduce the front-end and back-end service interaction, Gossip less, view dynamic effects →.→ detailed code ←.←
As shown above, the chart property of Highchart can add the events event, the event we inserted above is:
events: {load:function () { varSeries = This. series[0]; varOld = 0; SetInterval (function () { varx = (k++); vary = math.random () * 100; while(Y-old >= | | y-old <=-10) {y= Math.random () * 100; } Old=y; Series.addpoint ([x, parseint (y)],true,true); }, 1000); } }
The event gets a random number every 1 seconds after a successful load, if the value is not more than 10 from the last occurrence, the value is added to the Highchart array, otherwise the random number is regenerated, but the event needs to get a predetermined array by this.series[0]. If we need more than one chart, define THIS.SERIES[1],THIS.SERIES[2] ..... The resulting data is placed in a single chart, which is inconsistent with our needs.
Of course we can not write the events, but directly to SetInterval (func,1000) mentioned outside to write, so that the series can be defined only one item, and applied to different charts.
For implementation please see →.→ detailed code ←.←
Highchart Accessing a background service returns more than one chart data