2016-04-28 620 views
0

請看下面的例子:Highcharts:餅圖標籤的位置

http://jsfiddle.net/klodoma/2xgkzyh4/

是否有任何設置,將標籤貼更不恰當獨立地調整呢?

火狐應該是多了起來,其他人應該更向上和向右......

enter image description here

代碼:

$(function() { 
 
    $('#container').highcharts({ 
 
     title: { 
 
      text: 'Browser market shares at a specific website, 2014' 
 
     }, 
 
     plotOptions: { 
 
      pie: { 
 
       dataLabels: { 
 
        connectorWidth: 12, 
 
        style : { 
 
        fontSize: 25 
 
        } 
 
       } 
 
      } 
 
     }, 
 
     series: [{ 
 
      type: 'pie', 
 
      name: 'Browser share', 
 
      data: [ 
 
       ['Firefox', 45.0], 
 
       ['IE', 26.8], 
 
       ['Safari', 8.5], 
 
       ['Opera', 6.2], 
 
       ['Others', 0.7] 
 
      ] 
 
     }] 
 
    }); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://code.highcharts.com/highcharts.js"></script> 
 
<div id="container" style="height: 300px"></div>

+0

這是Highcharts的默認行爲。您可以[包裝](http://www.highcharts.com/docs/extending-highcharts/extending-highcharts)位置方法或禁用dataLabels並使用[渲染器](http://api.highcharts.com/highcharts#渲染器)添加自定義形狀。 –

回答

1

我總是發現標籤定位餡餅(以及極地和蜘蛛)圖表難以管理。根據你的數據和你想要的格式,他們可能會非常挑剔和不守規矩的位置,如你所願。

我建議完全刪除標籤並改爲使用圖例。我已經用這個概念更新了你的代碼片段。

請讓我知道這是否對你有幫助!

$(function() { 
 
    $('#container').highcharts({ 
 
     title: { 
 
      text: 'Browser market shares at a specific website, 2014' 
 
     }, 
 
     legend: { 
 
      enabled: true, 
 
      borderWidth: 1, 
 
      borderColor: 'gray', 
 
      align: 'center', 
 
      verticalAlign: 'top', 
 
      layout: 'horizontal', 
 
      x: 0, y: 50 
 
     }, 
 
     plotOptions: { 
 
      pie: { 
 
       allowPointSelect: true, 
 
       cursor: 'pointer', 
 
       dataLabels: { enabled: false }, 
 
       showInLegend: true 
 
      } 
 
     }, 
 
     series: [{ 
 
      type: 'pie', 
 
      name: 'Browser share', 
 
      data: [ 
 
       ['Firefox', 45.0], 
 
       ['IE', 26.8], 
 
       ['Safari', 8.5], 
 
       ['Opera', 6.2], 
 
       ['Others', 0.7] 
 
      ] 
 
     }] 
 
    }); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://code.highcharts.com/highcharts.js"></script> 
 
<div id="container" style="height: 300px"></div>

+0

感謝您提出的解決方案。不知道它是否會被接受(這不是我的電話)。 – klodoma

+1

沒問題。如果您需要關於其他備選方案的任何進一步輸入或想法,請隨時回覆此主題。 –