仪表盘自定义标题和数值样式

仪表盘自定义标题和数值样式

javascript 复制代码
fn()
var myEcharts;
function fn(v) {
    var chartDom = document.getElementById('myEcharts');
    myEcharts&& myEcharts.dispose();
    myEcharts= echarts.init(chartDom, 'walden');
    var option;
    option = {
        series: [
            {
                type: 'gauge',
                radius: '85%',
                center: ['50%', '45%'],
                max: 1,
                axisLine: {
                    lineStyle: {
                        width: 5,
                        color: [
                            [0.3, '#00a2ff'],
                            [0.7, '#00e9fb'],
                            [1, '#00a2ff']
                        ]
                    }
                },
                pointer: {
                    itemStyle: {
                        color: 'auto'
                    }
                },
                axisTick: {
                    distance: 0,
                    length: 3,
                    lineStyle: {
                        color: 'auto',
                        width: 2
                    }
                },
                splitLine: {
                    show: true,
                    distance: 0,
                    length: 8,
                    lineStyle: {
                        color: 'transparent',
                        width: 0,
                        // type: "dashed"
                    },
                },

                axisLabel: {
                    color: 'auto',
                    distance: 0,
                    fontSize: 10
                },
                detail: {
                    valueAnimation: true,
                    formatter: '{title|累计用电}' +'\n' +'{value|{value}}',
                    // color: '#666666', //或者放开这里注释的两行,将{value|{value}}=》{value} 也可
                    // fontSize: 23,
                    offsetCenter: [0, '70%'],
                    rich: { //特定样式
                        title: {
                            fontSize: 16,
                            fontWeight: 'bolder',
                            color:"#666666",
                        },
                        value: {
                            fontSize: 23, 
                            fontWeight: 'bolder',
                            color: '#666666',
                        },
                    },
                },
                data: [
                    {
                        value: 3034467.56,
                    }
                ]
            }
        ]
    };


    option && myEcharts.setOption(option);

    //图表自适应
    window.addEventListener("resize", function (event) {
        myEcharts.resize();
    })

}
相关推荐
开开心心就好2 天前
显示器关不掉怎么办,用小工具一键息屏
算法·智能手机·pdf·计算机外设·ocr·lua·1024程序员节
Evand J3 天前
【MATLAB例程】基于IMM-EKF与AOA/测距融合的二维移动目标跟踪定位
matlab·代码·定位·1024程序员节·toa·aoa
普通人66 天前
PHP多维数组排序完全指南
开发语言·php·1024程序员节
普通人68 天前
WebGL与WebGPU入门指南
开发语言·webgl·1024程序员节
猫猫不是喵喵.9 天前
从0到1创建一个微服务项目
java·数据库·微服务·1024程序员节
fish_zzzz12 天前
笔记-论数据结构2
1024程序员节
普通人613 天前
PHP文件读写完全指南
开发语言·php·1024程序员节
Martina_032113 天前
AI生成3D场景从白模换成精模后镜头全偏了?用6步检查单位、枢轴与层级替换
图像处理·人工智能·3d·ai·自然语言处理·材质·1024程序员节
星云_byto14 天前
CSS布局
人工智能·机器学习·目标跟踪·1024程序员节
张小姐的猫17 天前
【MySQL】访问 & 数据流动原理
android·数据库·mysql·adb·1024程序员节