Toggle navigation
饼状分类轮播图
By
原点丹枫
2017-06-02 08:06:19
脚本
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
图表已生成
整理代码
刷新
代码
var data = []; var innerList = []; var carTotal = 0; var faceTotal = 0; var macTotal = 0; var modelData = { "code": "200", "data": [{ "type": 1, "name": "苹果", "count": 2000 }, { "type": 1, "name": "樱桃", "count": 2000 }, { "type": 1, "name": "西瓜", "count": 2000 }, { "type": 1, "name": "梨子", "count": 2000 }, { "type": 2, "name": "大米", "count": 2000 }, { "type": 2, "name": "小麦", "count": 2000 }, { "type": 2, "name": "面粉", "count": 2000 }, { "type": 2, "name": "葱", "count": 2000 }, { "type": 2, "name": "大蒜", "count": 2000 }, { "type": 2, "name": "可乐", "count": 2000 }, { "type": 2, "name": "啤酒", "count": 2000 }, { "type": 3, "name": "雪碧", "count": 2000 }, { "type": 3, "name": "橙汁", "count": 2000 }], "message": "Successful" }; var lineIconName=[]; var dataLength = modelData.data.length; var temp = modelData.data; for (var i = 0; i < temp.length; i++) { if (temp[i].type === 1) { carTotal = carTotal + temp[i].count; } if (temp[i].type === 2) { faceTotal = faceTotal + temp[i].count; } if (temp[i].type === 3) { macTotal = macTotal + temp[i].count; } data.push({ value: temp[i].count, name: temp[i].name, type: temp[i].type }); } if (carTotal > 0) { innerList.push({ value: carTotal, name: '水果统计', }); lineIconName.push({ name: '水果统计', icon: 'rect' }); } if (faceTotal > 0) { innerList.push({ value: faceTotal, name: '粮食统计', }); lineIconName.push({ name: '粮食统计', icon: 'rect' }); } if (macTotal > 0) { innerList.push({ value: macTotal, name: '饮料统计', }); lineIconName.push({ name: '饮料统计', icon: 'rect' }); } option = { tooltip: { trigger: 'item', formatter: "{a}
{b}: {c} ({d}%)", }, grid: { show: false, zlevel: 0, z: 2, left: '0%', top: '20%', right: '0%', bottom: '0%' }, series: [{ name: '模型分析', type: 'pie', selectedMode: 'single', radius: [0, '50%'], label: { normal: { position: 'outside', show: true, } }, labelLine: { normal: { show: true, length: 20, length2: 25, } }, center: ['50%', '50%'], data: innerList, // color: ['#61a0a8', '#2f4554', '#c23521'] }, { name: "模型分析", type: 'pie', center: ['50%', '50%'], radius: ['70%', '90%'], label: { normal: { show: false, } }, itemStyle: { normal: { color: function(prams) { if (prams.data.type === 1) { return '#C1232B'; } if (prams.data.type === 2) { return '#27727B'; } if (prams.data.type === 3) { return '#FCCE10'; } }, borderColor: '#ddd', borderWidth: 1, } }, data: data }] }; var timeTicket = null; var count = 0; timeTicket && clearInterval(timeTicket); timeTicket = setInterval(function() { myChart.dispatchAction({ type: 'downplay', seriesIndex: 1 }); myChart.dispatchAction({ type: 'highlight', seriesIndex: 1, dataIndex: count % dataLength }); myChart.dispatchAction({ type: 'showTip', seriesIndex: 1, dataIndex: count % dataLength, }); count++; }, 1500); myChart.on('mouseover', function(params) { clearInterval(timeTicket); }); myChart.on('mouseout', function(params) { timeTicket && clearInterval(timeTicket); timeTicket = setInterval(function() { myChart.dispatchAction({ type: 'downplay', seriesIndex: 1 }); myChart.dispatchAction({ type: 'highlight', seriesIndex: 1, dataIndex: count % dataLength }); myChart.dispatchAction({ type: 'showTip', seriesIndex: 1, dataIndex: count % dataLength, }); count++; }, 1500); });