简体   繁体   English

如何在ammap上使用Dataloader

[英]How to use dataloader on ammap

I am trying to use dataloader functionality on ammap but I couldt gain. 我想使用dataloader的功能ammap但我couldt收获。

Here is how to I try: 这是我的尝试方法:

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ı"
                  }

                } );

There is no problem with json url.This url returns json datas like this: 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}]

I want to use as a value on map total . 我想用作地图total上的value

How can I use with dataloader on ammap? 如何在dataloader上使用dataloader加载器?

Thanks 谢谢

To use the dataLoader with the maps library, your data needs to be the same format as the map's dataProvider object, which includes the map property and areas array. 要将dataLoader与地图库一起使用,您的数据必须与地图的dataProvider对象具有相同的格式,该对象包括map属性和areas数组。 If your data is not formatted that way, then you can use the dataLoader's postProcess callback to create a dataProvider object and return that along with your data. 如果未采用这种方式格式化数据,则可以使用dataLoader的postProcess回调创建dataProvider对象,并将其与数据一起返回。 You also need to remap your total property to value in your data so that your balloon and legend will work. 您还需要重新映射总属性以在数据中赋值,以便气球和图例起作用。

Here's the dataLoader code: 这是dataLoader代码:

  "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 Codepen示范

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM