zoukankan      html  css  js  c++  java
  • 实时动态更新曲线图,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;
                    }())
                }]
            });
        });
    });

  • 相关阅读:
    2019CCPC厦门游记
    [codeforces940E]Cashback
    [codeforces#592Div2]C-G题
    Material Design UI素材库【React版】【2】--定制
    Material Design UI素材库【React版】【1】--入门
    resin中配置session相关参数
    quartz定时任务
    Linux内核----make menuconfig时出错
    【Qt学习之路】Qt开发环境搭建
    已学算法与数据结构的习题
  • 原文地址:https://www.cnblogs.com/ysq0908/p/5998547.html
Copyright © 2011-2022 走看看