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

224
Views
how change color of block on the basis of a condition in anychart

I am creating a treemap using any chart js. But I am having an issue for a long time with coloring. What I want is a red block of color wherever the value of(change) object is negative and green where the change is positive. I am getting data from json in this form. json array format

And here you can see the change is negative but the chart is showing green color. treemap snapshot

This is my code below.

var chart = anychart.treeMap([data], "as-tree");

                    chart.maxDepth(2);
                    chart.hintDepth(1);
                    chart.hintOpacity(0.1);




                    chart.container("container");

                    chart.draw();
                    var customColorScale = anychart.scales.linearColor(data);
                    customColorScale.minimum(-5).maximum(5);
                    customColorScale.colors(["red", "green"]);

                    chart.colorScale(customColorScale);

Data is the array which I am passing to create tree map.

about 4 years ago · Juan Pablo Isaza
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!