【发布时间】:2018-10-30 13:57:44
【问题描述】:
我正在测试 amcharts 4 地图(PieChart() 和 MapPolygonSeries()),我有一个这样的 response.data:
{
"status": 200,
"legal_country": [
{
"legal_country": "US",
"count(*)": 171576
},
{
"legal_country": "GB",
"count(*)": 130246
},
{
"legal_country": "DE",
"count(*)": 112459
},
{
"legal_country": "NL",
"count(*)": 96554
}
]
}
我将 legal_country 数组存储在两个变量中:
var getAjaxRecords1 = data.legal_country;
var getAjaxRecords2 = data.legal_country;
现在对于 am4charts.PieSeries(),我可以像这样访问数据并定义值和类别:
var chart = am4core.create("lei_pie", am4charts.PieChart);
chart.data = getAjaxRecords2;
var series = chart.series.push(new am4charts.PieSeries());
series.dataFields.value = "count(*)";
series.dataFields.category = "legal_country";
一切正常。
但是如何使用 MapPolygonSeries() 中的数据呢?这不起作用:
// Create polygon series
var polygonSeries = chart.series.push(new am4maps.MapPolygonSeries());
polygonSeries.useGeodata = true;
...
polygonSeries.dataFields.value = "count(*)";
polygonSeries.dataFields.category = "legal_country";
polygonSeries.data = getAjaxRecords1;
...我在文档中找不到它:https://www.amcharts.com/docs/v4/reference/mappolygonseries/
【问题讨论】:
标签: javascript arrays amcharts