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

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

tooltip: {
     
     extraCssText: 'white-space: normal; word-break: break-all;'
 }