echart修改字体大小

tooltip: {//鼠标悬浮提示字体大小
            trigger: 'axis',
            textStyle: {
                fontSize: getDpr()
            }
        },
        legend: {//标题
            data: ['事物量'],
            textStyle: {
                color: '#adadad',
                fontSize: getDpr()
            },
        },
xAxis: [{//右下角横轴名称
            name: '时间',
            nameTextStyle: {
                color: '#adadad',
                fontSize: getDpr()
            },
            nameGap: 6,
            type: 'category',
            boundaryGap: false,
            axisLabel: {
                textStyle: {
                    color: '#adadad',
                    fontSize: getDpr(),
                }
            },
            data: xData
        }],
yAxis: [{//y轴名称
            type: 'value',
            name: "单位:次",
            nameTextStyle: {
                color: '#adadad',
                fontSize: getDpr()
            },
            interval: 6000,
            nameGap: 11,
            splitLine: { //网格线
                show: true,
                lineStyle: {
                    color: ['#435357'],
                    type: 'solid'
                }
            },
            axisLabel: {
                textStyle: {
                    color: '#adadad',
                    fontSize: getDpr(),
                }
            },
        }],
series: [{//每项data中修改字体大小
            type: 'pie',
            radius: '70%',
            center: ['50%', '60%'],
            color: ['rgba(78, 181, 255, 0.74)', 'rgba( 0, 255, 255,0.1)'],
            data: [{
                name: '已用磁盘空间' + '\n' + used + 'TB',
                value: used,
                labelLine: {
                    normal: {
                        lineStyle: {
                            color: '#fff'
                        }
                    }
                },
                label: {
                    normal: {
                        textStyle: {
                            color: '#fff',
                            fontSize: getDpr(),
                        }
                    }
                }
            }]
}]
//其中getDpr()为一个方法,根据屏幕大小去加载不同字体大小
//图表根据屏幕大小去判断字体大小
var getDpr = function getDpr() {
    var windowWidth = $(window).width();
    if (windowWidth < 1920) {
        return 12
    }
    if (windowWidth >= 1920 && windowWidth <= 3840) {
        return 18
    }
    if (windowWidth > 3840 && windowWidth <= 5760) {
        return 30
    }

};

posted on   剩余价值  阅读(6652)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示