Echats-自定义图表2

效果图:

代码:

复制代码
<!DOCTYPE html>
<html lang="zh-cmn-Hans">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>图表</title>
    <style>
        #main {
            width: 237px;
            height: 250px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div id="main"></div>
    </div>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"></script>
    <script>
        var chartDom = document.getElementById('main');
        var myChart = echarts.init(chartDom);
        var option;

        option = {
            series: [
                {
                    type: 'gauge',
                    radius: '100%', // 圆盘大小
                    splitNumber: 10, // 刻度线单位
                    center: ['50%', '50%'], // 主体位置
                    startAngle: 216,
                    endAngle: -36,
                    z: 1,//y轴
                    min: 0,
                    max: 1,
                    itemStyle: {
                        color: '#2f9bff'
                    },
                    progress: {
                        show: true,
                        width: 12
                    },
                    axisLine: {
                        lineStyle: {
                            width: 12
                        }
                    },
                    // 中心圆点
                    anchor: {
                        show: false
                    },
                    pointer: {
                        show: false
                    },
                    // 小刻度线
                    axisTick: {
                        distance: 6,
                        length: 2,
                        lineStyle: {
                            color: '#666',
                            width: 1
                        }
                    },
                    splitLine: {
                        show: false // 不展示
                    },
                    axisLabel: {
                        show: false // 不展示
                    },
                    title: {
                        offsetCenter: [0, '85%'],
                        fontSize: 15,
                        color: 'rgba(37,35,58,0.4)'
                    },
                    detail: {
                        fontSize: 34,
                        offsetCenter: [0, '62%'],
                        valueAnimation: true,
                        formatter(value) {
                            return `${(value * 100).toFixed(2)}%`; // 计算百分率
                        },
                        color: '#2F9BFF'
                    },
                    data: [
                        {
                            value: 0.7,
                            name: '累计执行率'
                        }
                    ]
                },
                {
                    type: 'gauge',
                    radius: '50%', // 圆盘大小
                    splitNumber: 5, // 刻度线单位
                    center: ['50%', '50%'], // 主体位置
                    startAngle: 216,
                    endAngle: -36,
                    min: 0,
                    max: 1,
                    // itemStyle: {
                    //   color: '#ccc'
                    // },
                    // progress: {
                    //   show: true,
                    //   width: 12
                    // },
                    axisLine: {
                        lineStyle: {
                            width: 18,
                            color: [[1, '#DCE4FE']]
                        }
                    },
                    // 中心圆点
                    anchor: {
                        show: true,
                        size: 6,
                        showAbove: true, // 固定点是否显示在指针上面
                        itemStyle: {
                            borderColor: '#fff',
                            borderWidth: 8
                        }
                    },
                    pointer: {
                        width: 2,
                        offsetCenter: [0, '24%'],
                        icon: 'path://M2.9,0.7L2.9,0.7c1.4,0,2.6,1.2,2.6,2.6v115c0,1.4-1.2,2.6-2.6,2.6l0,0c-1.4,0-2.6-1.2-2.6-2.6V3.3C0.3,1.9,1.4,0.7,2.9,0.7z',
                        length: '220%',
                        itemStyle: {
                            color: '#1FA4FC'
                        }
                    },
                    // 小刻度线
                    axisTick: {
                        distance: -78,
                        length: 13,
                        lineStyle: {
                            color: 'rgba(255, 255, 255, 0.6)',
                            width: 3
                        }
                    },
                    splitLine: {
                        show: false // 不展示
                    },
                    axisLabel: {
                        show: false // 不展示
                    },
                    title: {
                        show: false
                    },
                    detail: {
                        show: false
                    },
                    data: [
                        {
                            value: 0.7,
                            name: '累计执行率'
                        }
                    ]
                }
            ]
        };

        option && myChart.setOption(option);
    </script>
</body>

</html>
相关推荐
new出一个对象4 天前
vue使用echarts实现只显示一根线的图表
前端·vue.js·echarts
KeroroLX4 天前
uniapp项目中使用echarts
javascript·uni-app·echarts
那些免费的砖5 天前
Uni ECharts - 基于 ECharts 开发的 uni-app 跨端图表解决方案,和 Vue ECharts 用法几乎一致
vue.js·uni-app·echarts
那个村的李富贵6 天前
用MySQL玩转数据可视化
mysql·信息可视化·echarts
Yaru117 天前
伪3D地图和3D饼图实现
前端·3d·echarts
计算机学姐9 天前
基于SpringBoot的校园跑腿系统【数据可视化统计+原创精品】
java·vue.js·spring boot·后端·mysql·信息可视化·echarts
徐小夕@趣谈前端9 天前
NO-CRM 2.0正式上线,Vue3+Echarts+NestJS实现的全栈CRM系统,用AI重新定义和实现客户管理系统
前端·javascript·人工智能·开源·编辑器·echarts
艾斯特_13 天前
Echarts常用配置项及解释
前端·javascript·echarts
winfredzhang13 天前
从零构建:基于 Node.js 与 ECharts 的量化交易策略模拟系统
前端·node.js·echarts·股票·策略
叫我辉哥e114 天前
新手进阶Python:办公看板集成多数据源+ECharts高级可视化
开发语言·python·echarts