Highcharts工具提示格式化程序只显示this.point.name中的前8个字符

highcharts tooltip formatter only shows first 8 characters in this.point.name

本文关键字:name 字符 8个 point this 格式化 工具提示 程序 显示 Highcharts      更新时间:2023-09-26

我找了一整天都找不到这个问题的答案。我刚接触排行榜,但似乎并不难做到…

这是我在脚本中的内容:

 tooltip: {
    formatter: function() {
     return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage) +' %';
                        }
                    },

我只想显示this.point.name

的前8个字符

请帮忙!

你应该能够在这个函数中使用标准的javascript,例如substring()。

 tooltip: {
    formatter: function() {
         return '<b>'+ this.point.name.substring(0,7) +'</b>: '+ Math.round(this.percentage) +' %';
    }
},