echarts label的换行问题

clipboard.png

现在为了换行是用空格截断的
但是这样在hover的数据提示上也显示空格

clipboard.png

option1 = {
        title: {
            text: 'Part 1',
            subtext: ' 财务规划 ,绩效和控制\nFinancial Reporting ,\nPlanning,Performance\nand Control',
            x: 'center',
            y: 'center',
            top: '36%',
            textStyle: {
                fontWeight: 600,
                fontSize: 24,
                color: '#3c4858'
            },
            subtextStyle: {
                fontWeight: 600,
                fontSize: 12,
                color: '#3c4858'
            }
        },
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b}"
        },
        legend: {
            show: false,
            orient: 'vertical',
            x: 'left',
            data: ['20%-成本管理', '20%-绩效管理', '15%-对外财务报告决策', '15%-内部控制', '30%-规划预算编制与预测']
        },
        series: [
            {
                name: 'Part1',
                type: 'pie',
                selectedOffset:100,
                radius: ['42%', '68%'],
                center: ['50%', '50%'],
                itemStyle: {
                    normal: {
                        label: {
                            show: true,
                            textStyle: {color: '#3c4858', fontSize: "16"},
                            formatter: function (val) {   //让series 中的文字进行换行
                                return val.name.split(" ").join("\n");
                            }
                        },
                        title: {
                            text: 'aaaa'
                        },
                        labelLine: {
                            show: true,
                            length: 6,
                            lineStyle: {color: '#3c4858'}
                        }
                    },
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)',
                        textColor: '#000'
                    }
                },
                data: [
                    {value: 20, name: '20%成本管理'},
                    {value: 20, name: '20%绩效管理'},
                    {value: 15, name: '15%对外财务报告决策'},
                    {value: 15, name: '15% 内部 控制'},
                    {value: 30, name: '30% 规划预 算编制 与预测'}
                ]
            }
        ],
        color: ['rgb(61,171,232)', 'rgb(95,193,215)', 'rgb(146,198,96)', 'rgb(59,175,134)', 'rgb(53,128,198)']

    };

怎么解决请问

还想请问 饼图hover突出的效果能放大么 没找到参数

阅读 13.3k
4 个回答

在tooltip.formmatter中删除空格呢?类似这样

tooltip:{
    formatter:function(params){
                var res = params.seriesName + '</br>';
                res += params.name.split(" ").join("");
                return res;
            }
}

效果:图片描述

我也遇到你这个问题,我这里情况是折线图横轴,让竖排文字,不是旋转,于是,也是使用\n换行的,但是,和你这一样,折线图hvoer的时候,字也有空格。。。。不知道在怎么解决? 所幸,客户没提出这里要改。

可否能判断字数来控制换行呢?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题