javascript – 如何在jqplot中显示饼图外的标签?

Jqplot的图表如下

jqplot Chart

我的问题是如何在jqplot图表外显示标签,如下面的高图,

高图表可在此处获得

高图

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

如何用jqplot中的行显示图表外的标签?

最佳答案 dataLabelPositionFactor控制标签在切片上的位置.增加将标签滑向饼的边缘,减少将标签滑向饼的中心.

dataLabelPositionFactor:1.2,

default dataLabelThreshold值为3,因此不显示值< = 3,因此将其设为0 dataLabelThreshold:0

 $(document).ready(function(){
  var data = [
    ['Heavy Industry', 12],['Retail', 9], ['Light Industry', 14], 
    ['Out of home', 16],['Commuting', 7], ['Orientation', 9]
  ];
  var plot1 = jQuery.jqplot ('chart1', [data], 
    { 
      seriesDefaults: {
        // Make this a pie chart.
        renderer: jQuery.jqplot.PieRenderer, 
        rendererOptions: {
          // Put data labels on the pie slices.
          // By default, labels show the percentage of the slice.
          showDataLabels: true, 
         //dataLabelPositionFactor controls position of label on slice.  Increasing will slide label toward edge of pie, decreasing will slide label toward center of pie.
         dataLabelPositionFactor : 1.2,
         // default dataLabelThreshold  value is 3,  hence values <=3 are not displayed hence make it to 0
         dataLabelThreshold : 0
        }
      }, 
      legend: { show:true, location: 'e' }
    }
  );
});

《javascript – 如何在jqplot中显示饼图外的标签?》

点赞