Highcharts adding point data dynamically

Source: Internet
Author: User

Highcharts used as a chart data display is very convenient, the effect is better. Highcharts not only can realize the display of dead data, but also can realize the real-time display of dynamic data, similar to the real-time refresh effect of financial stock, the realization process is not difficult, roughly as follows.

After referencing Highcharts 3.0, you can add a method Highcharts () to the DIV container that loads the Highcharts chart, which can load the chart into the appropriate container. The code for the JS section is as follows:

The main methods include

function Loadmoredatafornoisechart (seriesobj) {    var series = seriesobj[0];    var series1 = seriesobj[1];    Chartstime = setinterval (function () {        count;        var x = (Newdate ()). GetTime () (8 * 60 * 60 * 1000); Current time         var y;        First line         y = Math.floor (Math.random () * x);        var Newpoint;        Newpoint = {            x:x,//Current time             y:y,            marker: {                symbol: ' url (.. /.. /.. /content/images/warnning.png) '            }        ;        Series.addpoint (Newpoint, False, true);  Only the second parameter of the first line is set to False         //second line         var y1;        Y1 = Math.floor (Math.random () *);        var newPoint1;        NewPoint1 = {            x:x,//Current time             y:y1        };        Series1.addpoint (NewPoint1, True, true);    }, 1500); 1.5 Seconds to add}

 

The specific implementation of Getdatafornoisemonitor () is as follows:

Get data for the first few minutes to make the effect look better function getdatafornoisemonitor () {    var dataarr = [];    var plotname = [' One Metre of sunshine ', ' miles away riding alone '];    for (var i = 0; i < myplotname.length; i++) {        var tempobj = {            Name:myplotname[i],            data: []        };        var time = (Newdate ()). GetTime (8 * * +), J;   Adjust         the time for (j = -10; J <= 0; j + +) {            TempObj.data.push ({                x:time + j *),      //3 minutes before                 Y:MATH.F Loor (Math.random () *)            });        Dataarr.push (tempobj);    }    Returndataarr;}

  

Finally, the two methods have a common place, that is, the polyline is the same number of bars, the above example is two.

The effect is as follows:

 

Highcharts adding point data dynamically

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.