我还没有找到一种方法来用工具提示格式化程序中<br>
换行符替换逗号。
我希望能够将这些数据传入:
var data = [
{ "hc-key": "ad", "code": ['dogs','cats','horses','birds','snakes','boar'] }
];
并在格式化程序中使用拆分/连接或替换,如下所示:
tooltip: {
backgroundColor: 'none',
borderWidth: 0,
shadow: false,
useHTML: true,
padding: 0,
formatter:function(){
$('#tooltip').html(this.point.code).replace(/,/g,'<br>');
}
},
任何想法我该怎么做?
您应该返回所需的字符串作为工具提示,并使用 join:
http://jsfiddle.net/rL5ju28j/
tooltip: {
formatter: function() {
return this.point.code.join(',').replace(/,/g,'<br>');
}
}
http://www.highcharts.com/docs/chart-concepts/tooltip#formatter