MAIDR Documentation - v4.4.0
    Preparing search index...

    Module adapters/observable/scales

    Scale access and pixel-to-value inversion for the Observable Plot adapter.

    Plot draws marks at pixel coordinates and keeps the scales that produced them on the returned node. Recovering a datum is therefore a matter of reading an element's geometry and running it back through the right scale — invert for a continuous axis, a walk of the domain for a band one.

    Two things make that less mechanical than it sounds, and both are handled here:

    1. Float noise. Inverting a pixel is a divide followed by a multiply, so a bar drawn for 3.14159 inverts to 3.141589999999809. Announcing that to a screen reader is a defect, not a rounding detail, so every inverted number goes through cleanNumber.
    2. A missing scale. The function is an own property of the node Plot returned; it does not survive serialization. A plot found in a static HTML file has the markup and not the scales, so deriveScale fits one from the axis ticks Plot rendered.

    Functions

    findScaleSource
    readScales
    isContinuous
    isDiscrete
    isTemporal
    scaleSpan
    cleanNumber
    cleanToGeometry
    bandIntervals
    valueAtPixel
    valueAtColor
    deriveScale
    toNumber
    asKey