Echarts 折线图自动选中并跳转
作者:互联网
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<style type="text/css">
#myChart{width:1000px;height:500px;}
#myChart2{width:1000px;height:500px;}
</style>
</head>
<body>
<div id="myChart"></div>
<div id="myChart2"></div>
</body>
</html>
<script src="jquery-2.1.1.min.js"></script>
<script src="https://www.bdsjzx.gov.cn/static_material/source/plugin/data/js/echarts.min.js"></script>
<script type="text/javascript">
var XIdx_2 = [];
var data_2 = [55, 86, 46, 45, 77, 96, 89, 88, 23, 38,
3, 66, 98, 43, 73, 76, 44, 16, 21, 14,
71, 8, 61, 65, 1, 68, 33, 69, 49, 24
];
for(var i = 1; i <= data_2.length; i++) {
XIdx_2.push(i);
}
var option_2 = {
backgroundColor: 'white',
grid: {
// top: 20,
// left: 20,
// right: 20,
// bottom: 20,
containLabel: true //轴上的数值
},
xAxis: {
type: 'category',
data: XIdx_2
},
yAxis: {
type: 'value'
},
tooltip: {
trigger: 'axis'
},
series: [{
name: '人',
type: 'line',
data: data_2
}]
};
var myChart_2 = echarts.init(document.getElementById("myChart2"));
myChart_2.setOption(option_2);
var index8 = 0;
var mTime = setInterval(function() {
myChart_2.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: index8
});
index8++;
if (index8 > option_2.series[0].data.length) {
index8 = 0;
}
}, 1000);
</script>
标签:width,500px,1000px,height,var,跳转,折线图,data,Echarts 来源: https://blog.csdn.net/qq_17211063/article/details/123252223