我想饼图里面和外面的数据标签饼图。 我知道,它具有负距离,它显示了馅饼内的标签。但我想要它内外。 外面我想显示的百分比,并在该点的总和内。Highcharts饼图数据标签内外
6
A
回答
4
您不可能设置双倍的数据标签,但是您可以使用解决方法,这并不完美,但可能会有所帮助。所以你可以设置useHTML,然后在formater中返回两个div,第一个适当的datalabel(外部),第二个用inside。然后将id设置为counter,将每个div的id定义为唯一,那么只需要设置合适的CSS。位置的一个datalabel的实例是可在这里:http://jsfiddle.net/4RKF4/
$(function() {
var chart,
counter = 0;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Browser market shares at a specific website, 2010'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage}%</b>',
percentageDecimals: 1
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
useHTML:true,
formatter: function() {
counter++;
return '<div class="datalabel"><b>'+ this.point.name +'</b>: '+ this.percentage +' %</div><div class="datalabelInside" id="datalabelInside'+counter+'"><b>'+ this.point.name +'</b>: '+ this.percentage +' %</div>';
}
}
}
},
series: [{
type: 'pie',
name: 'Browser share',
data: [
['Firefox', 45.0],
['IE', 26.8],
{
name: 'Chrome',
y: 12.8,
sliced: true,
selected: true
},
['Safari', 8.5],
['Opera', 6.2],
['Others', 0.7]
]
}]
});
});
});
CSS样式:
.datalabelInside {
position:absolute;
}
#datalabelInside1 {
color:#fff;
left:-150px;
}
+0
我测试了铬和你的小提琴不工作,实际上。只有在我身边? –
4
有它
一个轻松的工作以防万一被你覆盖2馅饼diferent datalabels
$(function() {
// Create the chart
$('#container').highcharts({
chart: {
type: 'pie',
backgroundColor: 'rgba(0,0,0,0)',
y:100
},
title: {
text: 'sfs '
},
yAxis: {
title: {
text: ' '
}
},
plotOptions: {
pie: {
// y:1,
shadow: false,
// center: ['50%', '50%'],
borderWidth: 0,
showInLegend: false,
size: '80%',
innerSize: '60%'
,
data: [
['allo', 18],
['asdad', 14],
['asdad', 11],
['asdasd', 10],
['adad', 8],
['asdada', 7],
['adada ada', 7],
['adad', 5],
['asdas',7],
['ada', 3]
]
}
},
tooltip: {
valueSuffix: '%'
},
series: [
{
type: 'pie',
name: 'Browser share',
dataLabels: {
color:'white',
distance: -20,
formatter: function() {
if(this.percentage!=0) return Math.round(this.percentage) + '%';
}
}
},
{
type: 'pie',
name: 'Browser share',
dataLabels: {
connectorColor: 'grey',
color:'black',
// y:-10,
softConnector: false,
connectorWidth:1,
verticalAlign:'top',
distance: 20,
formatter: function() {
if(this.percentage!=0) return this.point.name;
}
}
}
]
});
});
相关问题
- 1. Highcharts饼图标签阈值
- 2. Highcharts:饼图标签重叠
- 3. Highcharts - 饼图内部和外部的标签
- 4. highcharts - 甜甜圈图 - 内外标签
- 5. highcharts:从饼图中缩进标签
- 6. Highcharts:饼图标签的位置
- 7. 处理饼图标签重叠[Highcharts]
- 8. Highcharts转换:不显示饼图数据标签
- 9. Highcharts:数据标签放置在饼图的部分中间
- 10. Highcharts:在饼图的数据标签上添加单击事件
- 11. Highcharts中的径向饼图数据标签
- 12. Highcharts饼图数据损坏
- 13. Highcharts饼不显示标签(对于某些数据系列)
- 14. 添加数据标签到Excel饼图
- 15. jqPlot数据标签颜色饼图
- 16. SSRS 3.0饼图数据标签位置
- 17. Primefaces饼图重叠数据标签
- 18. Flex 4饼图的自定义数据标签饼图
- 19. Highcharts条件数据标签
- 20. Highcharts - 数据标签切断
- 21. chart.js之:饼图外显示标签
- 22. 如何移动标签外饼图D3
- 23. HighCharts填充饼图与SQL数据库
- 24. Highcharts饼图数据格式通过php
- 25. 的Ajax highcharts饼图不显示数据
- 26. Highcharts饼图
- 27. Highcharts饼图
- 28. highcharts馅饼动态标签内部和外部的每个切片
- 29. 在d3饼图外部添加标签饼图不起作用
- 30. 在饼图中隐藏数据标签在400px以下宽度 - Highcharts
请显示一些代码。 – FrediWeber
这篇文章可能对你有用https://stackoverflow.com/questions/15235666/highcharts-pie-chart-add-text-inside-each-slice/29063822#29063822 – TechnoCrat