zoukankan      html  css  js  c++  java
  • echarts

    function randomData() {
        now = new Date(+now + oneDay);
        value = value + Math.random() * 21 - 10;
        var valueName = now.getFullYear() + '/' + (now.getMonth() + 1) + '/' + now.getDate() +
            ' ' + (now.getHours() >= 10 ? now.getHours() : '0' + now.getHours()) + ':' +
            (now.getMinutes() >= 10 ? now.getMinutes() : '0' + now.getMinutes()) +
            ':' + (now.getSeconds() >= 10 ? now.getSeconds() : '0' + now.getSeconds());
    
        return {
            name: now.toString(),
            value: [
                valueName,
                Math.round(value)
            ]
        }
    }
    
    var data = [];
    var now = +new Date();
    var oneDay = 1000;
    //var oneDay = 24 * 3600 * 1000;
    var value = Math.random() * 1000;
    for (var i = 0; i < 60; i++) {
        data.push(randomData());
    }
    
    var temp = 59;
    
    option = {
        title: {
            text: '动态数据 + 时间坐标轴'
        },
        tooltip: {
            trigger: 'axis',
            formatter: function(params) {
                params = params[0];
                var date = new Date(params.name);
                return date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() + ' : ' + params.value[1];
            },
            axisPointer: {
                animation: false
            }
        },
        xAxis: {
            type: 'time',
            splitLine: {
                show: false
            },
            triggerEvent: true
        },
        yAxis: {
            type: 'value',
            boundaryGap: [0, '100%'],
            splitLine: {
                show: false
            }
        },
        series: [{
            name: '模拟数据',
            type: 'line',
            showSymbol: false,
            hoverAnimation: false,
            markPoint: {
                data: [
                    [{
                        symbol: 'none',
                        x: '95%',
                        yAxis: data[temp].value[1]
                    }, {
                        symbol: 'circle',
                        label: {
                            normal: {
                                position: 'start',
                                formatter: '实时数据
    {c}'
                            }
                        },
                        name: '实时数据',
                        value: data[temp].value[1],
                        xAxis: data[temp].value[0],
                        yAxis: data[temp].value[1]
                    }]
                ]
            },
            data: data
        }]
    };
    
    setInterval(function() {
    
        for (var i = 0; i < 5; i++) {
            data.shift();
            data.push(randomData());
        }
    
        //alert(data[999].name)
        myChart.setOption({
            series: [{
                data: data,
                markLine: {
                    data: [
                        [{
                            symbol: 'none',
                            x: '95%',
                            yAxis: data[temp].value[1]
                        }, {
                            symbol: 'circle',
                            label: {
                                normal: {
                                    position: 'start',
                                    formatter: '实时数据
    {c}'
                                }
                            },
                            name: '实时数据',
                            value: data[temp].value[1],
                            xAxis: data[temp].value[0],
                            yAxis: data[temp].value[1]
                        }]
                    ]
                }
            }]
        });
    }, 1000);
  • 相关阅读:
    RabbitMQ笔记-死信队列与延时队列
    设计模式-迭代器模式
    RabbitMQ笔记-Demo(C#)
    RabbitMQ笔记-消息追踪【未完成】
    RabbitMQ笔记-安装&命令
    RabbitMQ笔记-Exchange、Queue、Message详细说明
    MySQL笔记-MVCC【没写】
    MySQL笔记-基础知识
    多线程笔记-基础知识
    在Redis中进行分页排序查询【转】
  • 原文地址:https://www.cnblogs.com/lsgsanxiao/p/11856117.html
Copyright © 2011-2022 走看看