This is the fallback for a plot whose scale function is gone — one parsed
out of saved HTML, or cloned through innerHTML. Plot draws every tick as a
<text> positioned by its own transform, in the same pixel space the marks
use, so a numeric axis can be recovered from two ticks and a categorical one
from all of them.
Which of the two an axis is has to be read off the axis rather than guessed
from its labels, because guessing is how a chart gets transposed: an axis
labelled 10, 100, 1k, 10k has labels that mostly do not parse as numbers,
and reading it as a set of categories turns a scatter plot into a horizontal
dot plot whose x values are the y axis's tick text. Plot sets
font-variant="tabular-nums" on a quantitative axis's labels and not on a
categorical one's, which settles it.
The result is deliberately shaped like a real PlotScale so the rest
of the adapter cannot tell the difference.
Parameters
svg: Element
The plot's <svg>.
axis: "x"|"y"|"fx"|"fy"
Which axis to fit, matching Plot's aria-label prefix.
Fits a scale from the axis ticks Plot rendered.
This is the fallback for a plot whose
scalefunction is gone — one parsed out of saved HTML, or cloned throughinnerHTML. Plot draws every tick as a<text>positioned by its owntransform, in the same pixel space the marks use, so a numeric axis can be recovered from two ticks and a categorical one from all of them.Which of the two an axis is has to be read off the axis rather than guessed from its labels, because guessing is how a chart gets transposed: an axis labelled
10, 100, 1k, 10khas labels that mostly do not parse as numbers, and reading it as a set of categories turns a scatter plot into a horizontal dot plot whose x values are the y axis's tick text. Plot setsfont-variant="tabular-nums"on a quantitative axis's labels and not on a categorical one's, which settles it.The result is deliberately shaped like a real PlotScale so the rest of the adapter cannot tell the difference.