Toggle navigation
半圆饼图
By
射***士
2020-04-08 10:16:31
脚本
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
图表已生成
整理代码
刷新
代码
let list = [{ name: '类型1', value: 20, startColor: 'rgba(242, 160, 48, 1)', endColor: 'rgba(242, 160, 48, .2)' }, { name: '类型2', value: 20, startColor: 'rgba(46, 201, 163, 1)', endColor: 'rgba(46, 201, 163, .2)' }, { name: '类型3', value: 20, startColor: 'rgba(72, 203, 82, 1)', endColor: 'rgba(72, 203, 82, .2)' }, { name: '类型4', value: 20, startColor: 'rgba(43, 159, 254, 1)', endColor: 'rgba(43, 159, 254, .2)' }, { name: '类型5', value: 20, startColor: 'rgba(109, 65, 232, 1)', endColor: 'rgba(109, 65, 232, .2)' } ] let listData = []; let totalValue = 0; let listLength = list.length; list.forEach((item, index) => { totalValue = totalValue + item.value; listData.push({ value: item.value, name: item.name, itemStyle: { normal: { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: item.startColor // 0% 处的颜色 }, { offset: 1, color: item.endColor // 100% 处的颜色 }], global: false // 缺省为 false } } }, }) // totalValue就是算出来隐藏的另一半的值,把它push进数组 if (index == listLength - 1) { listData.push({ value: totalValue, name: '隐藏的一半', itemStyle: { normal: { color: { type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: 'rgba(0,0,0,0)' // 0% 处的颜色 }, { offset: 1, color: 'rgba(0,0,0,0)' // 100% 处的颜色 }], global: false // 缺省为 false } } }, }) } }) option = { backgroundColor: "#344b58", tooltip: { trigger: 'item', formatter: '{a}
{b} : {c}' }, legend: { data: ['类型1', '类型2', '类型3', '类型4', '类型5'], icon: "rect", itemGap: 24, itemWidth: 10, itemHeight: 10, top:'20%', right: '30%', orient: "horizontal", textStyle: { color: "rgba(255,255,255,0.7)", fontSize: 18, padding: [0, 0, 0, 3], fontFamily: "SourceHanSansCN-Regular" // lineHeight: 30 } }, series: [{ name: '类型分布', type: 'pie', radius: 300, center: ['50%', '100%'], startAngle: 180, labelLine: { normal: { show: false } }, label: { normal: { show: false } }, data: listData, emphasis: { itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)', } } }] };