• 实时动态更新曲线图,x轴时间s随数据的变化而变化


    $(function () {
        $(document).ready(function () {
            Highcharts.setOptions({
                global: {
                    useUTC: false
                }
            });
            $('#container').highcharts({
                chart: {
                    type: 'spline',
                    animation: Highcharts.svg, // don't animate in old IE
                    marginRight: 10,
                    events: {
                        load: function () {
                            // set up the updating of the chart each second
                            var series = this.series[0];
                            setInterval(function () {
                                var x = (new Date()).getTime().getSecond, // current time
                                    y = Math.random();
                                series.addPoint([x, y], true);
                            }, 1000);
                        }
                    }
                },
                title: {
                    text: 'Live random data'
                },
                xAxis: {
                    tickInterval:(new Date()).getTime().getSecond
                },
                yAxis: {
                    title: {
                        text: 'Value'
                    },
                    plotLines: [{
                        value: 0,
                        1,
                        color: '#808080'
                    }]
                },
                tooltip: {
                    formatter: function () {
                        return '<b>' + this.series.name + '</b><br/>' +
                            this.x + '<br/>' +
                            Highcharts.numberFormat(this.y, 2);
                    },
                    crosshairs:[true,true]//显示十指线
                },
                legend: {
                    enabled: false
                },
                exporting: {
                    enabled: false
                },
                series: [{
                    name: 'Random data',
                    data: (function () {
                        // generate an array of random data
                        var data = [],
                            time = (new Date()).getTime().getSecond,
                            i;
                        for (i = -19; i <= 0; i += 1) {
                            data.push({
                                x: time ,
                                y: Math.random()
                            });
                        }
                        return data;
                    }())
                }]
            });
        });
    });

  • 相关阅读:
    热爱工作 发财机会大增(这里不是选择软件还是硬件的问题,是自己的性格和追求的问题)——当你的老板不如你懂行的时候,还赚的盆满钵满的时候,你就可以考虑独立了 good
    TaintDroid:智能手机监控实时隐私信息流跟踪系统(三)
    Delphi读取文件属性
    创业者该如何看待腾讯的“跟进”?
    IBM总裁郭士纳总结的四类人
    迅雷程浩:企业外包服务,下一个大的风口?(2B业务一定要懂销售和营销的人,这点和2C 不一样)
    dddd
    android:minSdkVersion 之我见
    dddd
    请人不怕啦
  • 原文地址:https://www.cnblogs.com/ysq0908/p/5998547.html
Copyright © 2020-2023  润新知