plot icon indicating copy to clipboard operation
plot copied to clipboard

Clipping a Text mark?

Open mbostock opened this issue 4 years ago • 3 comments

Should the Text mark support a clipping rect? A clipping circle? A way to reference another mark and use it as a clipping mask?

untitled-25

mbostock avatar Mar 03 '21 03:03 mbostock

Maybe we could do this by having one mark generate an id, and then the text mark could reference that id for clipping. For example, if you said:

Plot.rect(data, {id: "rect", ...options})

then you could say:

Plot.text(data, {clip: "rect", ...options})

and Plot would automatically pair by index (and also scope the id to each plot so that it doesn’t interfere with other plots on the page).

mbostock avatar Mar 17 '21 00:03 mbostock

Maybe introduce a clip: "rect" option that consumes x1, x2, y1, y2 and adds a clip-path: polygon(…)

Fil avatar Apr 04 '23 03:04 Fil

browser support for clip-path: polygon in SVG is not great… Current best effort notebook: https://observablehq.com/@observablehq/plot-treemap-clip

Edit: Jan. 2025 it seems like all three majors browsers now have correct support for clip-path: polygon / path.

Fil avatar Nov 01 '23 15:11 Fil