2016-08-10 43 views
1
chart: { 
     type: 'column' 
    }, 
    xAxis: { 
     type: 'category' 
    }, 
    plotOptions: { 
     series: { 
      dataLabels: { 
       enabled: true, 
       formatter: function() { 
       return '<b >'+Math.round(this.point.y)+'%</b>'+'<br> 
         <b >(N='+ this.point.count + ')</b>'; 
       } 
      } 
     } 
    } 

我想在列/中心的上方的中央顯示5%,1%,0%(N = 600)Highchart:中心文本在情節選項在柱形圖

Here is the image

這裏是jsfiddle

回答

3

添加useHTML並居中元素。

參考Highcharts Labels and String Formatting

dataLabels: { 
    enabled: true, 
    useHTML: true, 
    formatter: function() { 
    return '<center><b>'+Math.round(this.point.y)+'%</b></center>' 
     +'<br><center><b>(N='+ this.point.count + ')</b><center>'; 
} 

如果你想導出,然後加入出口以下allowHTML。

exporting: { 
    allowHTML: true 
} 

參考Highcharts exporting API

+0

它工作正常的屏幕,但在出口談到點點右側。 –

2

基於Rockie Yang的代碼,我發現你需要補充出口財產allowHTML並使其實現。默認情況下爲false,允許HTML允許您在導出的圖表中保留HTML結構。

的jsfiddle:http://jsfiddle.net/henrikskar/oos3bqov/

exporting: { 
     enabled: true, 
     allowHTML: true 
    }