Search code examples
d3.jschartsgeojson

how to draw a d3 bar chart for a local geojson file


i am trying to plot the bar, pie and bubble chart for the following geojson data stored locally in a myfile.geojson. Through stack overflow i got to know how to do pie chart. Taking it as a reference i am trying to do the bar chart. I tried but i am not getting it. here is the code of geojson file.

{
"type": "FeatureCollection",
"features": [{
    "type": "Feature",
    "properties": {
        "profit": 326,
        "npa": 174.000000
}
}, {
    "type": "Feature",
    "properties": {
        "profit": 1762,
        "npa": 1683.000000
}
}]
}

The code which i tried is in this plunker link

I am new to d3. Up to my knowledge i tried. Thanks in advance


Solution

  • I wasn't able to completely solve but a few suggestions. Hope it helps and others can edit this or contribute better answer.

    1. d3.layout.stack() does not have function .sort and has .values instead of .value
    2. load .geojson file with d3.json
    3. you have .append(text) and should be .append("text")
    4. if you are just trying to create bar chart, then I don't think stack layout is needed