score:11

Accepted answer

that's neither a standard javascript object nor a d3 method. that's an observable method.

if you look at the introduction, you'll see that dom is a collection of functions:

object {
  canvas: ƒ(e, t)
  context2d: ƒ(e, t, n)
  download: ƒ(…)
  element: ƒ(e, t)
  input: ƒ(e)
  range: ƒ(e, t, n)
  select: ƒ(e)
  svg: ƒ(e, t)
  text: ƒ(e)
  uid: ƒ(e)
}

so, in an observable notebook, one can do...

dom.text("i am a text node.")

...to create a text node or, as you just found,

dom.svg(500, 50)

...to create an svg. however, that only works in an observable notebook.

score:4

to expand on the previous answer, dom is indeed part of the standard library in observable. you can use it and the rest of the standard library methods outside of observable by exporting or embedding a notebook, as described in the downloading and embedding notebooks documentation page.


Related Query