echarts-如何绘制具有不同日期的两个时间序列

时间:2018-12-05 08:06:37

标签: time-series echarts

使用echarts时:有没有办法绘制两个具有不同日期的时间序列?

此处说明了一个示例:https://peltiertech.com/plot-two-time-series-with-different-dates/

2 个答案:

答案 0 :(得分:0)

看看Stacked Line chart

option = {
    title: {
        text: 'Stacked line'
    },
    tooltip: {
        trigger: 'axis'
    },
    legend: {
        data:['first','second']
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    toolbox: {
        feature: {
            saveAsImage: {}
        }
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['12/1/2018','12/2/2018','12/3/2018','12/4/2018','12/5/2018','12/6/2018','12/7/2018']
    },
    yAxis: {
        type: 'value'
    },
    series: [
        {
            name:'first',
            type:'line',
            data:[120, 132, 121, 134, , 200, 210]
        },
        {
            name:'second',
            type:'line',
            data:[220, 182, , 234, 290, 100, 310]
        }
    ]
};

stacked-line-chart

答案 1 :(得分:0)

例如我有以下示例数据:

 xAxisData = ['08:00', '08:05', '08:10', '08:15', '08:20', '08:25', '08:30'];

  legendData = ['Value1', 'Value2', 'Value3', 'Value4'];
  data= [
    [20.10, 30.10, null, null],
    [10.99, 53.10, null, null],
    [null, null, 5.3, 60],
    [33.10, 60.10, null, null],
    [null, null, 8.3, 40],
    [26.10, 88.10, null, null],
    [null, null, 12, 20]
  ];

我想在折线图中显示这些数据

解决方案是将系列数据上的“ connectNulls”属性设置为 true