I have been trying to implement the pie chart using Highcharts but am encountering an issue with the datalabels on very low resolutions being cropped.
I have attempted adding a windows.resize withing the formatter: function() but that failed.
Here is the code I am currently using:
// Radialize the colors
Highcharts.getOptions().colors = $.map(Highcharts.getOptions().colors, function(color) {
return {
radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
stops: [
[0, color],
[1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
]
};
});
// Build the chart
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
backgroundColor: {
linearGradient: [0, 0, 500, 500],
stops: [
]
},
},
title: {
text: 'Header Here'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage}%</b>',
percentageDecimals: 0
},
plotOptions: {
pie: {
allowPointSelect: false,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage) +'%';
}
}
}
},
series: [{
type: 'pie',
name: 'Votes',
data: [
['Vote One', 50],
['Vote Two', 50],
['Vote three', 2]
]
}]
});
Is there anyway other than creating a new chart on resize that the labels can be set to false / hidden? and shown again above a certain resolution?
Many thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…