Is there a way to get the id of the current cell (e.g. r#) so that I can tell my custom visualization library (https://github.com/ismms-himc/clustergrammer-gl) where to insert the visualization into the HTML DOM?
You can see the problem here https://observablehq.com/@cornhundred/clustergrammer-test
I did not pass in an CSS id and it defaulted to full screen.
It’s possible to get the
r# ID by creating an HTML element in a cell and then querying for its parent ID (see e.g. this notebook), but this is kind of a hack so I wouldn’t rely on it. I think it would be more reliable to define a named cell as in this fork:
There I used the fact that you can pass a reference to an HTML element as
args.container. I also added some code to clean up the
something div so that rerunning
cgm(args) won’t keep appending more copies of the graphic to that cell.
Thanks for the help. I merged in some changes from Tom MacWright (https://observablehq.com/@cornhundred/clustergrammer-test), but I need to spend some time comparing solutions.