Search code examples
csvd3.jschord-diagram

how to draw a chord with some specific CSV data


I am focusing on example https://github.com/sghall/d3-chord-diagrams/blob/master/trade-p.html and it is using data in csv format which is here https://github.com/sghall/d3-chord-diagrams/blob/master/data/trade.csv what i want is to draw chord from same data but when importer1===Panama only. Can anyone help me i am new to d3 and did not know how to extract specifc data from csv file as i am trying if(importer1===Panama) {draw chords....

}

but its not working. thanks in advance


Solution

  • Simple use filters as shown below this will filter record for Panama

     d3.csv('trade.csv', function (error, data) {
            var data = data.filter(function(d){ return d.importer1 == "Panama"});
            var mpr = chordMpr(data);
    

    Working code here

    Hope this helps!