Search code examples
amcharts4

How to match AmChart GeoJson data using string


I'm trying to plot some counts per State county using AmCharts and their GeoJson file. For example, loading FL counties and adding the counts. However, it seems I need to know the ID of the county, and not just the name. Is there a way to match the GeoJson using the county name?

I tried the simple idea of accessing the properties "name" in the GeoJson data and adding the count in polygonSeries.data but that doesn't work. It only works when providing the id.

When adding data, AmCharts allows something like this

polygonSeries.data =[
    { id: "12133", value: 60.524 }, // Washington
    { id: "12131", value: 300 }, // Walton
    { id: "12129", value: 500 }, // Wakulla
];

The above works. The below doesn't

polygonSeries.data = [
    { name: "Washington", value: 60.524 }, // Washington
    { name: "Walton", value: 300 }, // Walton
    { name: "Wakulla", value: 500 }, // Wakulla
];

The GeoJson data contains the relevant information like this

properties:{name:"Washington",id:"12133",STATE:"FL",TYPE:"County",CNTRY:"USA"},id:"12133"}

It apparently is matching the properties.id to find the object and that's why it works with the ids. However, that means I would need to know the ID for every county to begin with. So is there a way to match using the county name instead?

I would expect AmCharts to match the relevant properties and not just the ID since those are relatively unknown to people.


Solution

  • After speaking to amChart support, it's not possible to do this.