官方例子:Examples - Apache ECharts
官方文档:Documentation - Apache ECharts
必须要的属性:xAxis、yAxis、series
效果图:
实现步骤:
1.定义容器,存放图表
<div id="main" class="lineChar"></div>
样式:
<style>
.lineChar {
width: 1900px;
height: 400px;
margin: 0;
padding: 0;
background-color: #000000;
}
</style>
2.数据结构 数组形式
let Xdata=[1,2,3,4,5]
let Ydata=[1,2,3,4,5]
3.option配置
option = {
legend:{
data: ["本周", "上周"],
textStyle: {fontSize: 16}
},
xAxis: {
type: 'category',
data: ["2020-11-16", "2020-11-17", "2020-11-18", "2020-11-19", "2020-11-20", "2020-11-21", "2020-11-22"]
},
yAxis: {
type: 'value'
},
series: [
{
data: [3293.5,3945.6,3760.9,996.6,3481.6,4514.9,3223.5],
name: "本周",
smooth: true,
type: "line"
},
{
data: [1553.9,1180.8,2583.9,2488.5,1890,1881.3,3258.5],
name: "上周",
smooth: true,
type: "line"
}
]
};
遇到什么问题,可留言,看到会尽快回复。