
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./echart.min.js"></script>
</head>
<body>
<div class="box" style="width: 25rem; height: 25rem;"></div>
<script>
let myChart = echarts.init(document.querySelector('.box'))
let data = [20, 60, 70, 152, 70, 110, 130];
option = {
backgroundColor: '#000',
textStyle: {
color: '#fff'
},
yAxis: {
type: 'value'
},
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
series: [
{
data: data,
type: 'bar',
barWidth: 20,
itemStyle: {
color: '#1890ff'
}
},
{
type: 'lines',
coordinateSystem: 'cartesian2d',
data: data.map((item, index) => {
return {
coords: [
[index, 0],
[index, item - 4]
]
};
}),
effect: {
show: true,
period: 2.5,
trailLength: 0.5,
symbolSize: 10,
symbol: 'rect',
loop: true,
color: 'rgba(255, 255, 255, .45)'
},
lineStyle: {
width: 0,
opacity: 0,
curveness: 0
},
z: 99
}
]
};
myChart.setOption(option)
</script>
</body>
</html>