如果面积非常小,那么标签在圆环图中会重叠。 如何将数据标签放在圆环图外面。 目前我能够在图表中绘制标签。从这里找到示例代码:
$(document).ready(function(){
var s1 = [['a',6], ['b',8], ['c',14], ['d',20]];
var plot3 = $.jqplot('chart4', [s1], {
seriesDefaults: {
// make this a donut chart.
renderer:$.jqplot.DonutRenderer,
rendererOptions:{
// Donut's can be cut into slices like pies.
sliceMargin: 3,
// Pies and donuts can start at any arbitrary angle.
startAngle: -90,
showDataLabels: true,
// By default, data labels show the percentage of the donut/pie.
// You can show the data 'value' or data 'label' instead.
dataLabels: 'value'
}
}
});
});
这是我的预期输出:
非常感谢
答案 0 :(得分:3)
好的,你需要设置的是:
dataLabelPositionFactor: 2
请在这里查看jsFiddle:
此处有更多信息:
http://www.jqplot.com/docs/files/plugins/jqplot-donutRenderer-js.html
<强>更新强>
我也设置了填充以避免重叠,即
padding: 50
答案 1 :(得分:0)
在rendererOptions中使用dataLabelPositionFactor:1.2。
以下是我在项目中使用的示例:
rendererOptions:{ 填充:8, showDataLabels:true, dataLabels:百分比, dataLabelFormatString:'%s %%', 直径:300, dataLabelPositionFactor:1.1, sliceMargin:4, startAngle:-90, 颜色:'#DCDCDC' }