Skip to content

Extending Observable Plot with D3 in Observable Framework #1981

Answered by Fil
seether9000 asked this question in Q&A
Discussion options

You must be logged in to vote

For the first example, here's a working version:

Plot.plot({
  marks: [
    Plot.lineY(
      [
        { x: 1, y: 2 },
        { x: 2, y: 3 },
        { x: 3, y: 0 }
      ],
      { x: "x", y: "y" }
    ),
    (_index, scales, _values, dimensions, context) => {
      const g = d3.create("svg:g");
      g.append("circle")
        .attr("cx", 100)
        .attr("cy", 50)
        .attr("r", 50)
        .attr("fill", "red");
      return g.node();
    }
  ]
})

I fixed the second example; it is supposed to log the arguments and display a text, which explains why you're only seeing a text :)

Here's a third example where I'm using the last argument "next" to have Plot generate the line chart, …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@seether9000
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by seether9000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants