Formatting Data From a JSON
Discover how to format and map JSON data for building Sankey diagrams in D3.js. Learn to use named nodes and automate mapping to simplify complex data visualization tasks, making your diagrams clearer and easier to create.
We'll cover the following...
We'll cover the following...
From a JSON file with numeric link values
As explained in the previous lesson, data used to form a Sankey diagram needs to be a combination of nodes and links.
{
"nodes":[
{"node":0,"name":"node0"},
{"node":1,"name":"node1"},
{"node":2,"name":"node2"},
{"node":3,"name":"node3"},
{"node":4,"name":"node4"}
],
"links":[
{"source":0,"target":2,"value":2},
{"source":1,"target":2,"value":2},
{"source":1,"target":3,"value":2},
{"source":0,"target":4,"value":2},
{"source":2,"target":3,"value":2},
{"source":2,"target":4,"value":2},
{"source":3,"target":4,"value":4}
]}
As we also noted earlier, the "node" entries in the ...