• echarts柱状图文字过多倾斜+省略号显示


    需求:后台返回的项目名称太长,导致显示不开。

    可以设置成倾斜和省略号显示那种的

    通过一下属性:

    xAxis.axisLabel. interval(设置成 0 强制显示所有标签)

    xAxis.axisLabel. rotate(倾斜角度)

    xAxis.axisLabel. formatter(支持字符串模板和回调函数两种形式)

    function initThisMonthProjectsRanking() {
        $.ajax({
            url: urlpic + "thisMonthProjectRanking",
            type: 'get',
            data: {
                deptId: '4676',
                page: 1,
                limit: 10
            },
            success: function (res) {
                // console.log(res, '项目排名数据')
                let dataOption = res
                let styleOption = {
                        grid: {
                            left: 25 * sceenRate,
                            right: 15 * sceenRate,
                            top: 15 * sceenRate,
                            bottom: 15 * sceenRate
                        },
                        xAxis: {
                            type: 'category',
                            axisTick: {
                                show: false
                            },
                            nameTextStyle: {
                                color: '#a4d1ec'
                            },
                            axisLine: {
                                show: true,
                                lineStyle: {
                                    color: '#319cc9'
                                }
                            },
                            axisLabel: {
                                interval: 0,//横轴信息全部显示
                                rotate: 15,// 倾斜角度
                                formatter: function(value){
                                    return value.length > 10 ? value.substring(0, 10) + '...' : value;
                                }
                            }
                        },
                        yAxis: {
                            type: 'value',
                            axisTick: {
                                show: false
                            },
                            nameLocation: 'end',
                            axisLabel: {
    
                            },
                            axisLine: {
                                show: false,
                                lineStyle: {
                                    color: '#319cc9'
                                }
                            },
                            max: 1000,
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: '#092e5e',
                                    type: 'dashed'
                                }
                            }
                        }
                    }
                let id = 'rankingChart'
                return initCharts(id, dataOption, styleOption)
            },
        })
    }
    

      

  • 相关阅读:
    PyQuery
    计算 1+1/2!+1/3!+1/4!+...1/20!=?
    计算5的阶乘 5!的结果是?
    一张纸的厚度大约是0.08mm,对折多少次之后能达到珠穆朗玛峰的高度(8848.13米)?
    百马百担
    九九乘法表
    百钱买百鸡
    三角形菱形
    水仙花
    前缀表达式的计算
  • 原文地址:https://www.cnblogs.com/theblogs/p/13810230.html
Copyright © 2020-2023  润新知