想用线条实现echart图例图标
网上的朋友说line是默认的,但是我的echart没有line。我的echarts版本是“echarts”:“^5.4.0”,echarts选项配置如下:
dataVolumeOptions: {
legend: {
show: true,
icon: 'circle',
bottom: '0',
width: "auto",
height: "auto",
orient: "vertical",
align: "auto",
itemWidth: 20,
itemHeight: 10,
itemGap: 10,
data: [{
name: "data-size",
itemStyle: {
color: "#FFFFFF",
borderColor: '#1088FF',
borderWidth: 2,
},
textStyle: {
color: "#000",
fontSize: 14
},
}]
},
xAxis: {
data: ['2023-4-25 9:46:00', '2023-4-25 9:46:00', '2023-4-25 9:46:00', '2023-4-25 9:46:00', '2023-4-25 9:46:00']
},
yAxis: {},
series: [
{
name: "data-size",
type: 'line',
label: {
show: true,
position: 'top',
fontSize: 14
},
data: [10, 22, 28, 23, 19],
}
]
}
}
我想我明白你需要什么。我改了很多代码,看看这是不是你想要的结果
var grafico = echarts.init(document.getElementById('grafico'));
var dataVolumeOptions = {
title: {
text: 'test code'
},
tooltip: {
trigger: 'axis'
},
legend: {
data: ['Blue line']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['2023-4-25 9:46:00', '2023-4-25 9:46:00', '2023-4-25 9:46:00', '2023-4-25 9:46:00', '2023-4-25 9:46:00']
},
yAxis: {
type: 'value'
},
series: [
{
name: 'Blue line',
type: 'line',
stack: 'Total',
data: [10, 22, 28, 23, 19]
},
]
};
grafico.setOption(dataVolumeOptions);
<html>
<head>
<meta charset="utf-8">
<title>Exemplo ECharts</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script>
</head>
<body>
<div id="grafico" style="width: 600px; height: 200px;"></div>
</body>
</html>