有时根据项目需要,使用echart展示当前状态效果,不能用0和1数字表示,必须使用文字提示。搜索了很久找到了解决方案,效果如下:
废话不多说直接上代码:
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta charset="utf-8">
<style>
body{
background-color: #111f44;
}
</style>
</head>
<body style="height: 100%; margin: 0">
<div id="container" style="height: 100%"></div>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"></script>
<script type="text/javascript">
var jsonData = [
{
style:'符合开关状态',
state:'合闸',
time:['7-22 5:00', '7-22 6:00', '7-22 7:00', '47-22 8:00', '7-22 9:00', '7-22 12:00', '7-22 15:00'],
data:[1, 0, 1, 0, 0, 0, 0]
}
];
var echartsDataset = echarts.init(document.getElementById('container'), 'walden');
var optionDataset = {
toolbox: {
show: true,
feature: {
dataZoom: {
yAxisIndex: "none"
},
dataView: {