我试图在AMMAP上使用dataloader
功能,但我可以获得。
这是我尝试的方法:
var dogum_map = AmCharts.makeChart( "il_bazinda_dogum_say_dagilim", {
"type": "map",
"data": {
"map": "turkeyLow"
},
"theme": "light",
"colorSteps": 10,
"dataLoader": {
"url": "/dogum/dogum_frekans_verilerini_il_bazinda_hesapla",
"format": "json",
"showErrors": true
},
"areasSettings": {
"autoZoom": false,
"balloonText": "[[value]]",
"selectable":true
},
"valueLegend": {
"right": 10,
"minValue": "En Az",
"maxValue": "En Çok"
},
"export": {
"enabled": true,
"fileName":"İl Bazında Doğum Sayıları"
}
} );
JSON URL没有问题。此URL像这样返回JSON数据:
[{"id":"TR-01","ndogum":1111,"mdogum":22,"sdogum":693,"pdogum":336,"total":2162},{"id":"TR-02","ndogum":423,"mdogum":0,"sdogum":325,"pdogum":147,"total":895},{"id":"TR-03","ndogum":199,"mdogum":1,"sdogum":113,"pdogum":42,"total":355},{"id":"TR-04","ndogum":681,"mdogum":17,"sdogum":180,"pdogum":117,"total":995}]
我想在地图total
上用作value
。
我如何在AMMAP上使用dataloader
?
谢谢
要将数据加载程序与地图库一起使用,您的数据必须与地图的dataProvider
对象相同,其中包括map
属性和areas
数组。如果您的数据未格式化,则可以使用DataLoader的postProcess
回调来创建dataProvider
对象并将其与数据一起返回。您还需要将总财产重新估算到数据中的价值,以便您的气球和传奇能够起作用。
这是数据加载器代码:
"dataLoader": {
"url": "/dogum/dogum_frekans_verilerini_il_bazinda_hesapla",
"postProcess": function(data) {
var dataProvider = {
"map": "turkeyLow"
};
//create new areas array, while adding a value property
//to each area containing the value stored in total
dataProvider.areas = data.map(function(area) {
area.value = area.total;
return area;
});
return dataProvider;
}
},
codepen demo