D3 Choropleth Map

204 views Asked by At

I am building a D3 US choropleth map,i need to bind data for map from asmx webservice(output given as Json).

        d3.queue()
        .defer(d3.json, "https://d3js.org/us-10m.v1.json")
        .(d3.json,'Geodata.asmx/GetGeodtls',
                function (error, jsondata) {
                  (unemployment.set((jsondata.map(function (d) { return d.ZIP_CODE })), +jsondata.map(function (d) { return d.TRV })));                       


                })
        .await(ready);

        function ready(error, us) {
            if (error) throw error;

            svg.append("g")
                .attr("class", "counties")
              .selectAll("path")
              .data(topojson.feature(us, us.objects.counties).features)
              .enter().append("path")
                .attr("fill", function (d) { alert(d.TRV); return color(d.TRV = unemployment.get(d.ZIP_CODE)); })
                .attr("d", path)
              .append("title")
                .text(function (d) { return d.TRV + "%"; });

            svg.append("path")
                .datum(topojson.mesh(us, us.objects.states, function (a, b) { return a !== b; }))
                .attr("class", "states")
                .attr("d", path);
        }

How to proceed, any idea ?

Then I did something like below

         d3.queue()
        .defer(d3.json, "https://d3js.org/us-10m.v1.json")
        .defer(d3.json, 'Geodata.asmx/GetGeodtls')
        .await(ready);

        function ready(error, us,un) {
            if (error) throw error;

            un.forEach(function (d) {
                //alert("foreach" +d.ZIP_CODE);
                unemployment.set(d.ZIP_CODE, +d.TRV);

            });

            svg.append("g")
                .attr("class", "counties")
              .selectAll("path")
              .data(topojson.feature(us, us.objects.counties).features)
              .enter().append("path")
                .attr("fill", function (d) { return color(d.TRV = unemployment.get(d.ZIP_CODE)) ? color(d.TRV = unemployment.set(d.ZIP_CODE)) :"darkgreen"  })
                .attr("d", path)
              .append("title")
                .text(function (d) { return d.TRV + "%"; });

            svg.append("path")
                .datum(topojson.mesh(us, us.objects.states, function (a, b) { return a !== b; }))
                .attr("class", "states")
                .attr("d", path);

I am getting nothing in this unemployemnt.set(d.ZIP_CODE,+d.TRV) , I just want to use ZIP_CODE and TRV as my dataset in map.

0

There are 0 answers