Is there a way to hide one bar but keep the data labels in HighCharts? I have 3 bars:
- Target
- Realization
- Percentage
I want to display only the first and second bars, with only 1 data label which is the percentage. So, I made some adjustments to my code:
Here is a sample:
var target = [50,100];
var realization = [10,40];
var percentage = [];
for(i = 0; i < target.length; i++) {
var divide = (realization[i] / target[i]) * 100;
if (divide == Number.POSITIVE_INFINITY || divide == Number.NEGATIVE_INFINITY || isNaN(divide)) {
percentage.push(0);
} else {
percentage.push(divide);
}
}
series: [
{
name: 'Target )',
color: '#009933',
data: target,
},
// I used a trick on the second series to achieve the desired display
{
name: 'Percentage',
data: percentage,
color: 'rgba(255, 255, 255, .4)',
showInLegend: false,
pointWidth: 1,
lineColor: 'transparent',
marker: {
fillColor: 'transparent',
states: {
hover: {
enabled: false
}
}
}
},
{
name: 'Realization',
color: '#00ff00',
data: percentage,
}]
It will look like this https://i.sstatic.net/DL0C8.png
The trick I used is to place the percentage in the middle and change the bar color to transparent.
Here is the expected result https://i.sstatic.net/QkTpw.png
This is my full code :
https://jsfiddle.net/xanrdswq/
This is just a temporary solution for now.