red5
red5

Reputation: 312

Highcharts Pie Chart Add Value to the Legend

I'm trying to use labelFormat in my Highcharts Pie chart to add the y value of my series to the legend name. I haven't been able to. My question is very similar to this one, except I want the actual y value instead of a percentage. Thank you for your time.

Here's what I have so far, except I don't want percentage. I want the actual value:

legend: {
        labelFormat: '{name} ({percentage:.0f})',
    },

Upvotes: 0

Views: 1347

Answers (1)

Sebastian Wędzel
Sebastian Wędzel

Reputation: 11633

Try to use this code instead, where 2f is a number of decimals value:

Demo: https://jsfiddle.net/BlackLabel/ukc1tf3p/

legend: {
  labelFormat: '{name} {y:.2f}',
},

API: https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#format-strings

Upvotes: 1

Related Questions