we bendthetrend
we bendthetrend

Reputation: 59

Highcharts format legend names

Here is my codepen : DEMO

I have a pie chart showing the status of vehicles. Legend shows 'slice' instead of the names of status. How to format this?

plotOptions: {
    pie: {
      allowPointSelect: true,
      cursor: "pointer",
      dataLabels: {
        enabled: false
      },
      showInLegend: true
    }
  }

Also, when the same used in my project, graph is plotted with default colors and not the ones mentioned in the array. However it works fine in codepen or fiddle.

    Highcharts.setOptions({
      colors: [
        "#50B432",


 "#ED561B",
    "#DDDF00",
    "#24CBE5",
    "#64E572",
    "#FF9655",
    "#FFF263",
    "#6AF9C4"
  ]
});

Upvotes: 0

Views: 3169

Answers (1)

Paweł Fus
Paweł Fus

Reputation: 45079

Use legend.labelFormat, for example: labelFormat: '{status}' demo: https://codepen.io/anon/pen/gKQxqo

Alternatively change status to name in your data options (default format for pie slice is {name}): https://codepen.io/anon/pen/gKQxEo

Second issue: it's hard to guess without live demo. You can work around the issue by setting plotOptions.pie.color. Just a guess, but maybe you have in your code Highcharts.setOptions() multiple times?

Upvotes: 1

Related Questions