Converts a rendered Observable Plot chart into MAIDR's schema.
The adapter reads the drawn chart rather than the options that produced it,
because in the setting it was written for — an {ojs} cell in a Quarto
document — the options are not reachable. What is reachable is the <svg>
Plot inserted and the scale function it hung off that node, and between
them they carry everything a layer needs: an element's geometry says where
it was drawn, and running that back through the scale says what it means.
What is recovered, and how exactly
Inverting a pixel is exact to within float noise, which cleanNumber
removes, so a bar drawn for 3.14159 is announced as 3.14159. Three things
are less exact than that, and none of them is presented as though it were:
Marks whose value lives in a colour. A cell mark encodes its
magnitude as an 8-bit fill, so several distinct values render as one
colour and no inversion can tell them apart. contour is the same
problem — the level is carried only by the band's fill, sampled from a
continuous scale rather than a thresholded one — and density is worse,
drawing every isoline in one stroke colour so the level is not encoded at
all. All three are skipped rather than announced approximately (#1084).
Lines drawn with a non-interpolating curve.curveBasis and
curveBundle draw through control points that are not data points. The
adapter detects the mismatch — Plot binds the datum indices to the path,
so the expected count is known — and skips the mark instead of announcing
the control polygon.
Every line and area, a little. Their vertices are read back out of the
path's d attribute, where the serializer already rounded each
coordinate, so the value is rounded to the precision that quantum buys and
no finer. On an ordinary chart it comes back exact.
Converts a rendered Observable Plot chart into MAIDR's schema.
The adapter reads the drawn chart rather than the options that produced it, because in the setting it was written for — an
{ojs}cell in a Quarto document — the options are not reachable. What is reachable is the<svg>Plot inserted and thescalefunction it hung off that node, and between them they carry everything a layer needs: an element's geometry says where it was drawn, and running that back through the scale says what it means.What is recovered, and how exactly
Inverting a pixel is exact to within float noise, which cleanNumber removes, so a bar drawn for
3.14159is announced as3.14159. Three things are less exact than that, and none of them is presented as though it were:cellmark encodes its magnitude as an 8-bit fill, so several distinct values render as one colour and no inversion can tell them apart.contouris the same problem — the level is carried only by the band's fill, sampled from a continuous scale rather than a thresholded one — anddensityis worse, drawing every isoline in one stroke colour so the level is not encoded at all. All three are skipped rather than announced approximately (#1084).curveBasisandcurveBundledraw through control points that are not data points. The adapter detects the mismatch — Plot binds the datum indices to the path, so the expected count is known — and skips the mark instead of announcing the control polygon.dattribute, where the serializer already rounded each coordinate, so the value is rounded to the precision that quantum buys and no finer. On an ordinary chart it comes back exact.