Toggle navigation
hover饼图
By
爱***n
2020-07-31 09:17:29
脚本
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 pieData = [{ value: 1224, name: '正常排污企业' }, { value: 415, name: '异常排放企业' }, { value: 224, name: '临界达标企业' }, ]; let totalNum = 0; pieData.forEach(item => { totalNum += item.value }) option = { backgroundColor: '#2c3e50', //设置主副标题 title: { show: true, text: '企业数量', subtext: totalNum, left: 'center', top: 'center', z: 0, zlevel: 100, textStyle: { textAlign: 'center', color: '#BAE7FF', fontSize: 14, }, subtextStyle: { textAlign: 'center', color: '#fff', fontSize: 30, fontWeight: 600, }, }, tooltip: { show: false, trigger: 'item', alwaysShowContent: true, formatter: '{a}
{b}: {c} ({d}%)', }, //图例 legend: { show: false, }, //设置图表撑满整个画布 grid: { left: '0%', right: '0%', bottom: '0%', containLabel: true, }, series: [{ name: '企业数量', type: 'pie', //自定义颜色 color: ['#06B716', '#F5222D', '#FAAD14'], radius: ['60%', '90%'], //饼图大小 avoidLabelOverlap: false, legendHoverLink: false, //移入leged不显示在中间 textAlign: 'center', label: { normal: { show: true, position: 'center', //文字显示在中间 align: 'center', verticalAlign: 'middle', textStyle: { //设置文字样式 fontSize: '0', }, }, emphasis: { show: true, //文字至于中间时,这里需为true textStyle: { //设置文字样式 fontSize: '14', color: '#BAE7FF', }, formatter: '{b|{b}} \n {c|{c}} {d|{d}%}', //图形外文字上下显示 //样式设置 rich: { b: { //name 文字样式 lineHeight: 20, fontSize: 14, textAlign: 'center', color: '#BAE7FF', }, c: { //value 文字样式 lineHeight: 36, color: '#fff', fontSize: 30, fontWeight: 600, }, d: { //百分比样式 fontSize: 12, color: '#BAE7FF', }, }, }, }, itemStyle: { borderWidth: 2, borderColor: '#2E3E62', }, labelLine: { show: false, }, data: pieData, }, ], }; // 自动渲染echarts window.addEventListener('resize', () => { myChart.resize() }) //自定义事件 myChart.on('mouseover', (params) => { myChart.setOption({ title: { show: false, }, series: { label: { emphasis: { rich: { c: { //value 文字样式 color: params.color, } } } } } }) }) //自定义事件 myChart.on('mouseout', (params) => { myChart.setOption({ title: { show: true, }, }) })