熊猫923 2022-01-04 11:09 采纳率: 46.4%
浏览 607
已结题

Echarts 雷达图label过长,回调换行后,悬浮提示就多了一个空格,怎么解决?


                         radar: {
                                  radius:'60%',
                                // shape: 'circle',
                                indicator: indicator,
                                axisName: {
                                    color:'#333333'
                                },
                                name: {
                                    textStyle: {
                                        color: "#555555",
                                    },
                                    formatter: function (text) {
                                        var strlength = text.length;
                                        if (strlength % 5 == 1) {
                                            text = text.replace(/\S{5}/g, function (match) {
                                                return match + '\n'
                                            })
                                        }else {
                                            text = text.replace(/\S{5}/g, function (match) {
                                                return match + '\n'
                                            });
                                            strlength = text.length;
                                            text = text.substring(0, strlength);
                                        }
                                        return text
                                    },
                                },
                            },

加入上面的换行后就变成这样了,请问这个怎么解决,要重写提示框吗?或者只能重写?

img

  • 写回答

1条回答 默认 最新

  • 归来巨星 新星创作者: 前端开发技术领域 2022-01-05 16:19
    关注

    在你的 tooltip 选项中添加 extraCssText 然后把你的换行数据删除掉

    tooltip: {
         
         extraCssText: 'white-space: normal; word-break: break-all;'
     }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 1月21日
  • 已采纳回答 1月13日
  • 创建了问题 1月4日