Reputation: 648
I have a simple bar graph and I wanted to add percentage change over the top of those bars.
Check the inline image.
I read the highcharts documentation and I did not see anything similar. So can we create such chart with highcharts with some hacks, if yes I would appreciate a code sample since my javascript skills are rudimentary. If not then can you suggest some alternative.
Upvotes: 1
Views: 141
Reputation: 108567
With code all things are possible :)
Here's an example which uses a secondary value as the data label:
$('#container').highcharts({
chart: {
type: 'column'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
formatter: function(){
return this.series.userOptions.someValues[this.point.x] + '%';
}
}
}
},
series: [{
someValues: [10, 22, 35, 16, 61, 34, 13, 73, 43, 51, 12, 37],
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
Produces (fiddle here):
Upvotes: 2