Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

340
Views
Highcharts same legend color as of the Pie chart slice color?

I want to have the same colour for legend text as the corresponding slice colour have in Pie chart. I have seen by default the dot before legend text takes the colour of slice colour but not text of legend. How can we do the same for legend text?

I have pinned below the demo link from highcharts site.

https://www.highcharts.com/demo/pie-basic

I have also attached the screenshot on which am working on.

for example here in this pie chart I want the legends to have the colour for their corresponding pie section

for example here in this pie chart I want the legends to have the colour for their corresponding pie section

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Such a feature is not supported in Highcharts by default, but you can simply add it, for example by using the below plugin:

(function(H) {
  H.wrap(H.Legend.prototype, 'renderItem', function(proceed, point) {
    proceed.apply(this, Array.prototype.slice.call(arguments, 1));

    point.legendItem.css({
      color: point.color
    });
  });
  // Handle hover and click event
  H.wrap(H.Point.prototype, 'setState', function(proceed) {
    proceed.apply(this, Array.prototype.slice.call(arguments, 1));

    this.legendItem.css({
      color: this.color
    });
  });
}(Highcharts));

Live demo: https://jsfiddle.net/BlackLabel/o4wyzbqt/

Docs: https://www.highcharts.com/docs/extending-highcharts/extending-highcharts

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!