I continue to learn Observable by porting examples from bl.ocks. Currently I am working on a port of d3noob’s ‘Sankey Diagram with v4’, which I would like to get working with d3 version 5.
With Tom and Mike’s help, I’ve learned a few ways to append an object to the DOM. I have tried out a couple different approaches , but to no avail.
When I try:
var svg = d3.select(DOM.element('svg'))
... // code goes here
return svg.node();
I am returned a message reading SVGGElement {}
When I try:
var container = html`<svg></svg>`;
var svg = d3.select(container)
... // code goes here
return container;
I get an empty box.
Could someone please help me to better understand what’s going on? Might this be a problem with how the chart referring in data?
Here’s my workbook attempt:
I have tried to look at the Sankey examples already on Observable, but haven’t yet figured it out. For reference, these are:
With regard to the data line, any guidance on referencing the JSON locally? I would like to play around with the data and find it easier to do so within Observable than working through gists.