我想用实际(折线图)和预测值(虚线图)创建预测图。 Here是使用Excel制作的示例:
我想使用ECharts库创建相同的图表,但我无法从其网页https://echarts.apache.org/examples/en/中找到要使用的示例:
如果有一种使用javascript生成此图表的方法,这将非常有帮助,我不介意使用ChartJs之类的其他库(如果有这种可能性)。
答案 0 :(得分:3)
尝试一下。
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'
}
}]
};
这是一个非常简单的示例,但它应该可以解决您的问题。我没有添加图例,但您应该可以做到无任何问题。