How to display the labels outside the pie chart in jqplot?

笑着哭i 提交于 2019-12-06 05:44:06

问题


Jqplot has the chart like following

jqplot Chart

my question is how to display the labels outside a jqplot chart like the following high chart,

high chart is available at here fiddle

hight charts

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

How to achieve displaying labels outside the chart with lines in jqplot?


回答1:


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

 $(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' }
    }
  );
});




回答2:


I used the following way to place the legend outside the pie chart and it worked for me

legend: {show: true, location: 'ne',placement: 'outside'},




回答3:


I think what you're looking for is this page.

Check out the info under the dataLabels subheading.



来源:https://stackoverflow.com/questions/21448072/how-to-display-the-labels-outside-the-pie-chart-in-jqplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!