This message was deleted.
# help
s
This message was deleted.
a
you almost had it!
Copy code
Plot.plot({
  color: { legend: true },
  height: 500,
  width: 1200,
  facet: {
    data: total,
    x: "segments"
  },
  marks: [
    Plot.dot(total, {
      x: "year",
      y: "general renevue",
      stroke: "company"
    }),
    
    Plot.rect(
      total,
      Plot.selectLast({
        x1: d => d["year"] - 10,
        y1: d => d["general renevue"] - 500,
        x2: d => d["year"] + 10,
        y2: d => d["general renevue"] + 500,
        fill: "yellow",
      })
    ),

    Plot.text(
      total,
      Plot.selectLast({
        x: "year",
        y: "general renevue",
        text: "general renevue",
        fill: "black",
        frameAnchor: "bottom"
      })
    )
  ]
})
❤️ 2
swapped rect and text around for paint order and replaced rect x and y with x1 y1 x2 y2
f
I would suggest a rect with negative insets (and rx for rounded corners):
Copy code
Plot.rect(
      total,
      Plot.selectLast({
        inset: -60,
        insetTop: -16,
        insetBottom: -16,
        rx: 15,
        fill: "pink",
        x: "year",
        y: "general renevue",
        text: "general renevue",
        frameAnchor: "bottom"
      })
    ),
and to make it well-balanced, use
lineAnchor: "middle"
in the text mark
❤️ 2
a
ah, much cleaner!