gpt4 book ai didi

javascript - jqplot如何显示饼图外的标签?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:17:49 25 4
gpt4 key购买 nike

Jqplot有如下图表

enter image description here

jqplot Chart

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

enter image description here

高位图表可在此处获得 fiddle

排行榜

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

jqplot如何实现在图表外用线条显示标签?

最佳答案

dataLabelPositionFactor 控制标签在切片上的位置。增加将使标签向饼图边缘滑动,减少将使标签向饼图中心滑动。

dataLabelPositionFactor : 1.2,

默认 dataLabelThreshold 值为 3,因此不显示值 <=3,因此将其设置为 0

数据标签阈值: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' }
    }
  );
});

enter image description here

关于javascript - jqplot如何显示饼图外的标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21448072/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com