2017-10-06 154 views
0

我想为dataLabels使用像<table><tr>这样的html标签,但似乎我无法使用这些标签,只能使用基本标签(<b>, <strong>, <i>, <em>, <br/>, <span>)。我能够通过将'useHTML'标签设置为true来将工具提示数据格式化为其他html标签。有没有办法为dataLabels做同样的事情?这就是两者的样子,工具提示在底部。 enter image description here在Highcharts中格式化数据标签

+0

请提供一些代码,以便其他人可以帮助你。在提出问题之前,请先查看这些资源[https://stackoverflow.com/help/mcve](https://stackoverflow.com/help/mcve) – jfeferman

回答

1

您也可以使用useHTML格式化dataLabels。我不知道图表的可读性如何随时显示所有额外的数据,但您可以在dataLabels中放置一个表格。

http://jsfiddle.net/crLcxvLr/1

plotOptions: { 
    series: { 
     dataLabels: { 
     formatter: function() { 
      return "<table><tr><td>HEADER LEFT</td><td class='right'>Header Right</td></tr><tr><td>" + this.x + "</td><td class='right'>" + this.y + "</td></tr>"; 
     }, 
     enabled: true, 
     useHTML: true, 
     } 
    } 
    },