• 实时动态更新曲线图,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;
                    }())
                }]
            });
        });
    });

  • 相关阅读:
    Windows下Yarn安装与使用
    论文阅读Graph Convolutional Matrix Completion
    如何快速查询中科院JCR分区和汤森路透JCR分区
    Implement GAN from scratch
    PyCharm将main.py解析成text文件的解决方法
    理解PyTorch的自动微分机制
    mcast_set_if函数
    mcast_get_if函数
    mcast_unblock_source函数
    mcast_block_source函数
  • 原文地址:https://www.cnblogs.com/ysq0908/p/5998547.html
Copyright © 2020-2023  润新知