Reputation: 75
I am trying to make this chart using Highchart.js. Now I have to add labels in the format shown in the following picture. Can anyone help me out please. I am using ASP.net MVC and jquery for this.
The view is
<div id="hourlyChart"></div>
And JS file is
Highcharts.chart('hourlyChart', {
chart: {
type: 'column'
},
credits: false,
title: {
text: ''
},
legend: { enabled: false },
xAxis: {
categories: label
},
yAxis: [{
min: 0,
title: {
text: ''
}
}],
legend: {
shadow: false
},
tooltip: {
shared: true
},
plotOptions: {
column: {
grouping: false,
shadow: false,
borderWidth: 0
}
},
series: [{
name: 'Target',
color: 'rgba(189, 195, 199, 1)',
data: target,
showInLegend: false,
}, {
name: 'Achieved',
color: 'rgb(242, 38, 19)',
data: achieved,
pointPadding: 0.2,
showInLegend: false
}
]
});
From this I am getting this much result
Thank you in advance.
Upvotes: 0
Views: 1008
Reputation: 39079
Use data-labels and position them by y
property. Example:
plotOptions: {
column: {
...,
dataLabels: {
verticalAlign: 'bottom',
allowOverlap: true,
enabled: true,
inside: true
},
}
},
series: [{
dataLabels: {
color: 'rgba(189, 195, 199, 1)',
y: -310
},
...
}, {
dataLabels: {
color: 'rgb(242, 38, 19)',
y: -330
},
...
}]
Live demo: http://jsfiddle.net/BlackLabel/hvxbpqj5/
API Reference: https://api.highcharts.com/highcharts/series.column.dataLabels
Upvotes: 1