Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am building a D3 US choropleth map,i need to bind data for map from asmx webservice(output given as Json).


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.

What I have tried:

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);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900