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

Treemap change rectangle colours #385

Closed
alienbuild opened this issue Apr 25, 2022 · 2 comments
Closed

Treemap change rectangle colours #385

alienbuild opened this issue Apr 25, 2022 · 2 comments
Labels

Comments

@alienbuild
Copy link

Any advice on how I can selectively change the rectangle colours within a tree map? The documentation to its credit does show how to change for all rectangles ie:

        series.labels.template.setAll({
            fill: am5.color(0x550000),
        });

As well as creating a default or hover state such as:

      series.rectangles.template.states.create("default", {
            fill: am5.color(0x677935),
            fillOpacity: 1
        });

However for my use case i would like to check the value to see if it is a positive or negative number and then change the background based on that outcome (red/green)

Any advice appreciated.

@alienbuild alienbuild changed the title Treemap change recentangle colours Treemap change rectangle colours Apr 25, 2022
@alienbuild
Copy link
Author

I've made some progress using an adapter and it does colour the label backgrounds correctly, however it colours all rectangles with the same color

        series.rectangles.template.adapters.add("fill", function(fill, target) {
            if (target.dataItem.get("value") < 10000) {
                return am5.color(0xb30000);
            }
            else {
                return am5.color(0x50b300);
            }
        });

@alienbuild
Copy link
Author

Above code does work, I had a custom theme declared at the start that was overwriting it.

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