I have been experimenting with a Sankey chart using the code available at this link: https://gist.github.com/d3noob/c2637e28b79fb3bfea13
Interestingly, I can view the chart in Firefox, but not in Chrome. I suspect this may be due to Chrome's restrictions on accessing data from external sources.
To resolve this, I attempted to integrate the JSON code directly into the script. However, despite my efforts, the chart still does not appear in Firefox.
I defined a variable containing the JSON dataset like so:
var dataset = {"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}]};
Then, I replaced the original line of code:
d3.json("sankey-formatted.json", function(error, graph) {
With this modified version (substituting the file name with the dataset variable):
d3.json(dataset, function(error, graph) {
Unfortunately, the chart still fails to display. I am puzzled as to why the Sankey chart is not visible. Any suggestions or insights are greatly appreciated.
Thank you