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

146
Views
How to set countrySeries fill colors in amcharts5 Maps

I'm currently using amcharts5 for their maps for a project and I'm having issues setting a fill color for specific nations/states.

I'm using the Drill-Down to Countries setup. When you click on a country it zooms in and shows all the sections of that country. I can set a fill color for all of them, however I cannot seem to figure out how to set them to have a different fill color each.

The code that currently sets the fill color is:

worldSeries.mapPolygons.template.events.on('click', (ev) => {
  var dataItem = ev.target.dataItem;
  var data = dataItem.dataContext;
  var zoomAnimation = worldSeries.zoomToDataItem(dataItem);

  Promise.all([
    zoomAnimation.waitForStop(),
    am5.net.load('https://cdn.amcharts.com/lib/5/geodata/json/' + data.map + '.json', chart)
  ]).then((results) => {
    var geodata = am5.JSONParser.parse(results[1].response);
    countrySeries.setAll({
      geoJSON: geodata,
      fill: data.polygonSettings.fill,
      fill: am5.color('#0099cc')
    });

    countrySeries.show();
    worldSeries.hide(100);
    backContainer.show();
  });
});

With this, I was able to color everything #0099cc. I attempted to review the docs on colors for amscharts5 colors but can't seem to get it to do what I want it to do.

I assume that there will need to be some sort of loop that can set each fill color independently but I can't figure out where to put it.

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!