I’ve generated a plot using barX
and text
marks.
Now I want to stop using the text labels and replace them with a word cloud svg:
I guess one option would be to redo the plot using D3, but I wanted to ask in case there is an easy way to generate SVG marks or to somehow select the <rects>
and wrap them in a <g>
node along with the word cloud.
1 Like
You can pass a render function as a mark and return SVG elements from it. Here is an example:
Render functions are documented here:
/**
* A bare renderable mark implementation. Given the mark’s *index*, an object of
* the plot’s *scales*, the mark’s (possibly scaled) channel *values*, the
* plot’s *dimensions* and *context*, returns a new SVGElement, or null if the
* mark should display nothing.
*/
export type RenderFunction = (
/** The mark’s (filtered and transformed) index. */
index: number[],
/** The plot’s scale functions. */
scales: ScaleFunctions,
/** The mark’s (possibly scaled and transformed) channel values. */
values: ChannelValues,
/** The plot’s dimensions. */
dimensions: Dimensions,
/** The plot’s context. */
context: Context,
/** The next render function; for render transforms only. */
next?: RenderFunction
) => SVGElement | null;
1 Like
Thanks, Mike.
There’s a lot left to improve, but this is what I have so far
2 Likes