Created
August 9, 2017 01:56
-
-
Save mengxy/3b6027030fe2d0eefd808a91497346ef to your computer and use it in GitHub Desktop.
Echarts 3 PieSelect & PieUnSelect action demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html style="height: 100%"> | |
<head> | |
<meta charset="utf-8"> | |
</head> | |
<body style="height: 100%; margin: 0"> | |
<div id="container" style="height: 100%"></div> | |
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts-all-3.js"></script> | |
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts-stat/ecStat.min.js"></script> | |
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/dataTool.min.js"></script> | |
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script> | |
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/world.js"></script> | |
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ZUONbpqGBsYGXNIYHicvbAbM"></script> | |
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/bmap.min.js"></script> | |
<script type="text/javascript"> | |
var dom = document.getElementById("container"); | |
var myChart = echarts.init(dom); | |
var app = {}; | |
option = null; | |
option = { | |
"series": [ | |
{ | |
"data": [ | |
{ | |
"value": 4251901.507000001, | |
"name": "东北", | |
"label": "东北,14%" | |
}, | |
{ | |
"value": 5987640.768999987, | |
"name": "华北", | |
"label": "华北,20%" | |
}, | |
{ | |
"value": 5399737.763000001, | |
"name": "华东", | |
"label": "华东,18%" | |
}, | |
{ | |
"value": 11515413.933999965, | |
"name": "华南", | |
"label": "华南,38%" | |
}, | |
{ | |
"value": 2206083.199000002, | |
"name": "西北", | |
"label": "西北,7%" | |
}, | |
{ | |
"value": 948463.3399999994, | |
"name": "西南", | |
"label": "西南,3%" | |
} | |
], | |
"type": "pie", | |
"selectedMode": "single" | |
} | |
], | |
} | |
app.currentIndex = -1; | |
setInterval(function () { | |
var dataLen = option.series[0].data.length; | |
if (app.currentIndex > 0) { | |
myChart.dispatchAction({ | |
type: 'pieUnSelect', | |
seriesIndex: 0, | |
dataIndex: option.series[0].data[app.currentIndex].name | |
}); | |
} | |
app.currentIndex = (app.currentIndex + 1) % dataLen; | |
// pieSelect | |
myChart.dispatchAction({ | |
type: 'pieSelect', | |
seriesIndex: 0, | |
name: option.series[0].data[app.currentIndex].name, | |
}); | |
}, 1000);; | |
if (option && typeof option === "object") { | |
myChart.setOption(option, true); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment