chart = null on cell embedding

Hi,
I have created a chart visualizing JSON data, which in the notebook looks great and works well. However, when I try to embed the cell the preview always returns chart = null. I looked at many example codes which all look similar to mine, yet I get this issue. Any idea what could be the reason?

Thanks,
Tassilo

1 Like

Note that the chart in your notebook doesnā€™t return or yield an image; rather it d3.selects another node (by id) and places the image there. A quick fix (that I donā€™t recommend) would be to name the other node and embed that.

Note, though, that the global d3.select by id is not generally recommended in Observable. Iā€™d recommend creating an SVG and yielding that right from the same cell. Hereā€™s a fork of your notebook that seems to embed the graphic well:

1 Like

Perfect. Thanks a lot for the info and the support!

1 Like