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

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

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();
    })

}
相关推荐
liuyao_xianhui2 小时前
Linux开发工具结尾 _make
linux·运维·服务器·数据结构·哈希算法·宽度优先·1024程序员节
学传打活2 天前
【边打字.边学昆仑正义文化】_21_爱的结晶(1)
微信公众平台·1024程序员节·汉字·昆仑正义文化
数据皮皮侠AI9 天前
顶刊同款!中国地级市风灾风险与损失数据集(2000-2022)|灾害 / 环境 / 经济研究必备
大数据·人工智能·笔记·能源·1024程序员节
Fab1an10 天前
Busqueda——Hack The Box 靶机
linux·服务器·学习·1024程序员节
技术专家11 天前
Stable Diffusion系列的详细讨论 / Detailed Discussion of the Stable Diffusion Series
人工智能·python·算法·推荐算法·1024程序员节
学传打活13 天前
古代汉语是源,现代汉语是流,源与流一脉相承。
微信公众平台·1024程序员节·汉字·中华文化
学传打活18 天前
【边打字.边学昆仑正义文化】_19_星际生命的生存状况(1)
微信公众平台·1024程序员节·汉字·昆仑正义文化
unable code25 天前
[HNCTF 2022 WEEK2]ez_ssrf
网络安全·web·ctf·1024程序员节
unable code1 个月前
[NISACTF 2022]easyssrf
网络安全·web·ctf·1024程序员节
unable code1 个月前
BUUCTF-[第二章 web进阶]SSRF Training
网络安全·web·ctf·1024程序员节