Is it possible to position Highcharts dataLabels depending on the value?

后端 未结 4 482
温柔的废话
温柔的废话 2020-12-14 11:32

I\'m using Highcharts to display a bar chart, with 2 bars overlaying each other, and a dataLabels at the right of them, displaying the exact value.

The problem here

4条回答
  •  鱼传尺愫
    2020-12-14 12:15

    Although Bhesh's answer solves the problem for x/y positioning, Highcharts ignores any changes to the style property of dataLabels (see the problem here). However, you can override the styles of an individual point by passing it through the data object:

    series: [{ data: [29.9, 106, { y: 135, dataLabels: { style: { fontSize: 20 } } }]
    

    example from Highcharts docs

    I was able to get dynamic styles by iterating over my data before passing the whole object to Highcharts to render.

提交回复
热议问题