echarts之折线图
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
<title>苗栋燊</title>
</head>
<body>
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
let myChart = echarts.init(document.getElementById('main'));
let xData = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"];
let yData = [5, 20, 36, 10, 10, 20];
let yData1 = [15, 120, 136, 110, 110, 120];
// 指定图表的配置项和数据
let option = {
title: {
text: '服装销量'
},
tooltip: {
show: true,
},
legend: {
data: ['销量']
},
xAxis: {
data: xData,
//紧挨边缘
boundaryGap: false
},
yAxis: {
type: 'value',
// 缩放: 脱离0值比例
scale: true
},
series: [
{
name: '销量',
type: 'line',
data: yData,
markPoint: {
data: [
{
//最大值
type: 'max'
},
{
//最小值
type: 'min'
},
]
},
markLine: {
data: [
{
//平均值
type: 'average'
}
]
},
// 标注区间
markArea: {
data: [
[
{
xAxis: '衬衫'
},
{
xAxis: '羊毛衫'
}
],
[
{
xAxis: '裤子'
},
{
xAxis: '高跟鞋'
}
],
],
},
//线条平滑设置
smooth: true,
//线条风格
lineStyle: {
color: 'blue',
type: 'dotted'
},
//填充风格
areaStyle: {
color: 'cyan'
},
},
{
type: 'line',
data: yData1,
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
</body>
</html>
posted on 2022-03-28 15:22 Indian_Mysore 阅读(74) 评论(0) 收藏 举报
浙公网安备 33010602011771号