我在高图中创建了一个饼图,但是我遇到了两个困难:
我在不同的论坛和高清网页上搜索过,但我找不到解决方案。你能帮我解决这个问题吗?你能找到解决方案的地方,因为我是高级图表的新手,还在学习。
添加了我的基本jsfiddle。提前致谢
http://jsfiddle.net/uhydP/209/
$(function () {
var chart = new Highcharts.Chart({
tooltip: {
enabled: false
},
chart: {
renderTo: 'container', //Dat is waar hij heen moet
type:'pie', // Type die we hebben gekozen
backgroundColor: '#281e82',
borderColor: '#281e82',
borderWidth: 0
},
xAxis: {
categories: ['Sparen', 'Aflossen'], // De namen
color: 'black',
},
credits: {
enabled: false // Geen verwijzing naar highchart
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
formatter: function() {
return Math.round(this.percentage*100)/100 + ' %';
},
distance: -60, // Hoe ver naar binnen de teksten staan
color:'black' // De kleur van de percentages
},
animation: {
duration: 2000
}
}
},
title: {
text: 'Testje',
style: {
color: 'white',
fontWeight: 'bold'
}
},
series: [{
data: [{y: 30, color: 'white'}, {y: 70, color: '#E50000'}]
}]
});
});
答案 0 :(得分:1)
可以在datalabels formatter中添加名称,
formatter: function() {
var cat = this.series.chart.xAxis[0].categories,
x = this.point.x;
return 'name: ' + cat[x] + '<br>' + Math.round(this.percentage*100)/100 + ' %';
},