Toggle navigation
饼图循环高亮 与 鼠标移入 起冲突应该如何解决?
By
铅***擦
2019-11-15 05:37:41
脚本
16
21
作品使用的第三方脚本
数据管理
上传数据
支持小于 5M 任意格式(csv, xlsx, json, xml, ...)的数据文件
上传后可以通过生成的文件链接异步获取托管的数据。
历史数据
0 条
无历史数据
代码修改记录
信息提示
保存作品
对当前截图不满意?你还可以
上传本地截图
重新截图
作品名称
作品描述
标签
geo
grid
legend
markLine
markPoint
bar
effectScatter
line
lines
map
timeline
title
toolbox
tooltip
visualMap
作品默认版本
最新
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
20:11:45
图表已生成
整理代码
刷新
代码
option = { title: { "text": '特种设备接入数量', "textStyle": { "fontSize": 14, "color": "#007aff", "top": '10%' } }, tooltip: { trigger: 'item', formatter: "{a}
{b}: {c} ({d}%)" }, legend: { icon: 'circle', itemHeight: '8', orient: 'horizontal', x: 'center', bottom: '1', data: ['东渚', '木渎', '香山', '胥口'], textStyle: { // fontSize: 18, //字体大小 color: '#6ea4df' //字体颜色 }, }, series: [{ name: '访问来源', type: 'pie', radius: ['30%', '60%'], avoidLabelOverlap: false, label: { normal: { show: false, position: 'center' }, emphasis: { show: true, textStyle: { fontSize: '20', fontWeight: 'bold' } } }, labelLine: { normal: { show: false } }, data: [ { value: 335, name: '东渚' }, { value: 310, name: '木渎' }, { value: 234, name: '香山' }, { value: 135, name: '胥口' } ] }], color: ['#007aff', '#7f4450', '#bb8dff', '#c8a000', '#e8395d'] }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); cycle_heighlight(); function cycle_heighlight(){ //自动高亮 var currentIndex = -1; var a ; autoCycle();//初次点入执行 function autoCycle(){ a=setInterval(function() { var dataLength = option.series[0].data.length; // 取消之前高亮的图形 myChart.dispatchAction({ type: 'downplay', seriesIndex: 0, dataIndex: currentIndex }); currentIndex = (currentIndex + 1) % dataLength; // 高亮当前图形 myChart.dispatchAction({ type: 'highlight', seriesIndex: 0, dataIndex: currentIndex }); // 显示 tooltip myChart.dispatchAction({ type: 'showTip', seriesIndex: 0, dataIndex: currentIndex }); }, 3000); } //移除执行 myChart.on('mouseout',function(){ autoCycle(); }) //移入执行 myChart.on('mouseover', function(params) { myChart.dispatchAction({ type: 'downplay', seriesIndex: 0, dataIndex: currentIndex }); clearTimeout(a) currentIndex=-1 }) } $(window).resize(function() { myChart.resize(); })