question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tooltip colors for Pie/Donut charts don't reflect custom colors

See original GitHub issue

Description

Can’t seem to change the color of the tooltip and the donut labels displayed inside the chart. I updated the colors for the legend and the actual slices but not the tooltip and inside label.

Steps to Reproduce

  1. Pass in custom colors for the chart
  2. Modify the legend and tooltip to use them
  3. See that the tooltip is not reflected including the labels

Chart options that reproduce the issue:

var options = {
  chart: {
    height: 380,
    width: "100%",
    type: "donut",
    labels: ["Apple", "Orange", "Mango"]
  },
  fill: {
    colors: ["#f44336", "#ff9800", "#4caf50"]
  },
  series: [1, 5, 10],
  legend: {
    // Show the legend
    show: true,
    markers: {
      // Set the legend colors as the ones passed in
      fillColors: ["#f44336", "#ff9800", "#4caf50"]
    }
  },
  tooltip: {
    enabled: true,
    fillSeriesColor: true
  }
};

Expected Behavior

The tooltip and the inside labels should use the same colors as the chart slices and legend.

Screenshots

Screen Shot 2022-02-14 at 11 42 22

Reproduction Link

See the code here: https://codepen.io/stanivanov/pen/WNXZvZE

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
GonzaloBlanco7commented, Jun 6, 2022

Had the same problem when forcing chart colours as you did. To fix this issue I had assigned the same colours array used in options.fill.colors to options.colors

var options = {
  chart: {
    height: 380,
    width: "100%",
    type: "donut",
    labels: ["Apple", "Orange", "Mango"]
  },
  fill: {
    colors: ["#f44336", "#ff9800", "#4caf50"]
  },
  series: [1, 5, 10],
  legend: {
    // Show the legend
    show: true,
    markers: {
      // Set the legend colors as the ones passed in
      fillColors: ["#f44336", "#ff9800", "#4caf50"]
    }
  },
  tooltip: {
    enabled: true,
    fillSeriesColor: true
  },
  colors: ["#f44336", "#ff9800", "#4caf50"] //Add this line
};
0reactions
stanimirivanovdecommented, Jun 15, 2022

You are right about using the color array, but I also had to remove the fillSeriesColor option in the tooltip array.

This didn’t work:

fill: {
    colors: this.colors,
},
colors: this.colors,
tooltip: {
    enabled: true,
    fillSeriesColor: true,
}, 

But this does and fixes the issue:

fill: {
    colors: this.colors,
},
colors: this.colors,
tooltip: {
    enabled: true,
}, 
Read more comments on GitHub >

github_iconTop Results From Across the Web

Apex Chart donut chart the tooltip color isn't same with series
I am trying to change ApexChart tooltip background colors but i couldn't do it. They aren't same with the series colors.
Read more >
series.pie.colors | highcharts API Reference
The center of the pie chart relative to the plot area. ... Changes to the series' color will also be reflected in a...
Read more >
Tooltip - Chart.js
The bubble, doughnut, pie, polar area, and scatter charts override the tooltip defaults ... Color boxes are always aligned to the left edge....
Read more >
Chart TOOLTIP on Mouse HOVER - An Entire Dashboard in ...
But, when we hover with the mouse over any column, a dynamic tooltip appears showing related information in a donut and a Bar...
Read more >
How to Change the Font Colors of the Tooltip Labels in Chart.js
With chart js you can make line chart, bar chart, pie chart, doughnut chart, scatter chart, polar area chart, radar chart, gauge chart...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found