I'm trying to display the label values within a Highcharts bar chart by utilizing the dataLabels.Formatter
function.
However, I've noticed that when the bar size is inconsistent, the labels are sometimes displayed inside the bar, which looks good. But in other cases, when the bar is very small compared to the label, the label appears outside of the bar.
To see an example of this issue, you can view my code pen here: https://codepen.io/JGSpark/pen/YzzBydv?editors=1010
On the last bar, which is very small, the label "40" is displayed outside. Since I have set color: 'white'
for all labels, it still shows up in white even when it's outside of the bar.
My question is, how can I change the color of a label if it's displayed outside of the bar?
In the given example, I specifically want to change the color of the label "40" to black. Any suggestions on how to achieve this?