如何使用电子图表创建预测图表

问题描述 投票:1回答:1

我想用实际(折线图)和预测值(虚线图)创建预测图。 Here是使用Excel制作的示例:enter image description here

我想使用ECharts库创建相同的图表,但是我无法从其网页https://echarts.apache.org/examples/en/中找到要使用的示例:

[如果有一种方法可以使用javascript构建此图表,那将非常有帮助,如果有这种可能性,我不介意使用ChartJs等其他库。

javascript echarts
1个回答
0
投票

尝试一下。

option = {
xAxis: {
    type: 'category',
    data: [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
},
yAxis: {
    type: 'value'
},
series: [{
    data: [0, 20, 30, 45, 40, 50, 51, 52, 50, 49, 56, 55],
    type: 'line',
    smooth: true,
    lineStyle: {
        color: 'red'
    }
}, {
    data: [null, null, null, null, null, null, null, null, null, null, null, 55, 50, 49, 48],
    type: 'line',
    smooth: true,
    lineStyle: {
        color: 'blue',
        type: 'dashed'
    }
}]

};

这是一个非常简单的示例,但它应该可以解决您的问题。我没有添加legenda,但是您应该可以做到无任何问题。

© www.soinside.com 2019 - 2024. All rights reserved.