简体   繁体   English

如何使用 ECharts 创建预测图表

[英]How to create Forecast Chart using ECharts

I want to create a forecast chart with Actual (a line chart) and projected values (a dotted chart).我想用实际(折线图)和投影值(点线图)创建预测图表。 Here is an example made with Excel: 是一个用Excel制作的例子: 在此处输入图片说明

I want to create the same chart using the ECharts library but I couldn't find any example to use from their web page https://echarts.apache.org/examples/en/ :我想使用 ECharts 库创建相同的图表,但在他们的网页https://echarts.apache.org/examples/en/ 中找不到任何示例:

It would be very helpful if there is an approach to build this chart using javascript, I don't mind using other libraries like ChartJs if they have this possibility.如果有一种方法可以使用 javascript 构建此图表,那将非常有帮助,如果有这种可能性,我不介意使用其他库,例如 ChartJs。

try this.尝试这个。

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'
    }
}]

}; };

It's a very simple example but it should solve your issue.这是一个非常简单的示例,但它应该可以解决您的问题。 I didn't add the legenda but you should be able to do thaat without any issues.我没有添加传奇,但你应该可以毫无问题地做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM