Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label treemap auto color #595

Closed
justine-mlss opened this issue Sep 2, 2022 · 2 comments
Closed

Label treemap auto color #595

justine-mlss opened this issue Sep 2, 2022 · 2 comments
Labels

Comments

@justine-mlss
Copy link

Hello,

In this demoo : https://www.amcharts.com/demos/drill-down-treemap, especially datas of mercedes, I notice that the color of the labels does not seem to be automatically adjusted with respect to the background color. In this case, it would be more appropriate if the labels were in black. Is there a way to get this adjustment?

mercedes

I took this example but I've the same issue in my project

Thanks

@martynasma
Copy link
Collaborator

It can be achieved with an adapter:

series.labels.template.adapters.add("fill", function(fill, target) {
  if (target.dataItem) {
    var bgcolor = target.dataItem.get("rectangle").get("fill");
    return am5.Color.alternative(bgcolor, am5.color(0x000000), am5.color(0xffffff))
    
  }
  return fill;
});

https://codepen.io/team/amcharts/pen/mdLdRoL

@justine-mlss
Copy link
Author

it works, thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants