Reputation: 616
I am using amcharts (MapArea within DataLoader) to fetch data as json and render the map. However, I also want to send a dynamic title/subtitle in json (e.g. Total Population: X), which I'd want to render in the Map. Is it possible? I couldn't find the correct property to send it in, in https://docs.amcharts.com/3/javascriptmaps/MapArea
Upvotes: 0
Views: 518
Reputation: 16012
Assuming you're referring to the map title, the dataLoader doesn't allow you to set the title directly as it only loads the mapData properties in the dataProvider
(areas, lines, map type). You can store extra data in your JSON and use the dataLoader's complete
callback to assign what you want to the chart instance itself.
For example, if you set a custom title
property in your JSON response like so:
{
"map": "/* your map here */",
"title": "Your title text here",
// other properties omitted
}
You can add that title text in the complete
callback like so:
"dataLoader": {
"url": "/* your json endpoint */",
"complete": function(map) {
map.addTitle(map.dataProvider.title);
}
},
Upvotes: 1