eharts pie 环形图 - 饼图

2024.07.16我设计了环形图,效果如下:

代码如下:

const chartData = { ONE: 10, TWO: 20, THREE: 30 ,num:60};
const seriesData = [];
const legendData = [];
const nameList = [
    { key: 'ONE', text: '一级问题', left: '15%', right: null, bottom: '20%' },
    { key: 'TWO', text: '二级问题', left: null, right: '15%', bottom: '20%' },
    { key: 'THREE', text: '三级问题', left: 'center', right: null, bottom: '10%' },
];
nameList.forEach((item, i) => {
    if (item.key) {
        seriesData.push({
            value: chartData[item.key],
            show: true,
            name: item.text,
        });
        legendData.push({
            orient: 'horizontal',
            bottom: item.bottom,
            left: item.left,
            right: item.right,
            textStyle: {
                color: '#fff',
                fontSize: 14,
            },
            padding: [10, 20],
            icon: 'circle',
            backgroundColor: 'rgba(0,102,255,0.2)',
            itemStyle: {},
            borderWidth: 0,
            borderColor: '#0066FF',
            borderRadius: 100,
            data: [{ name: item.text }],
            formatter(text) {
                const arr = nameList.filter((item) => item.text === text);
                return `${arr[0].text} ${chartData[arr[0].key] ? chartData[arr[0].key] : 0}人`;
            },
        });
    }
});

option = {
    legend: legendData,
    tooltip: {
        rich: {},
    },
backgroundColor:'#10225c',
    color: ['#243eff', '#2490ff', '#30f3e3'],
    series: [
        {
            name: '',
            type: 'pie',
            center: ['50%', '40%'],
            radius: ['40%', '50%'],
            avoidLabelOverlap: false,
            itemStyle: {
                borderRadius: 10,
            },
            label: {
                show: true,
                position: 'center',
                fontFamily: 'fzzz',
                color: '#fff',
                fontSize: 22,
                formatter() {
                    return `问题人数\n\n${chartData.num} 人`;
                },
            },

            labelLine: {
                show: false,
            },
            data: seriesData,
        },
    ],
};

相关推荐

  1. R 绘图 -

    2024-07-16 19:30:05       51 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-16 19:30:05       70 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-16 19:30:05       74 阅读
  3. 在Django里面运行非项目文件

    2024-07-16 19:30:05       62 阅读
  4. Python语言-面向对象

    2024-07-16 19:30:05       72 阅读

热门阅读

  1. InnoDB

    2024-07-16 19:30:05       22 阅读
  2. 跨入嵌入式day1(Linux下C语言-基础知识)

    2024-07-16 19:30:05       20 阅读
  3. sqlalchemy mapper的使用

    2024-07-16 19:30:05       19 阅读
  4. git初始化项目

    2024-07-16 19:30:05       19 阅读
  5. 有用的C语言相关函数

    2024-07-16 19:30:05       20 阅读
  6. P10781 【MX-J1-T1】『FLA - III』Spectral 题解

    2024-07-16 19:30:05       18 阅读
  7. docker镜像源配置

    2024-07-16 19:30:05       21 阅读
  8. React基础学习-Day05

    2024-07-16 19:30:05       18 阅读
  9. 每天一个数据分析题(四百三十一)- 卡方检验

    2024-07-16 19:30:05       22 阅读
  10. buttonrpc解析—server篇

    2024-07-16 19:30:05       21 阅读