MAIDR Documentation - v4.4.0
    Preparing search index...
    • Reads one declared fact off an author's row.

      An explicit ref is used verbatim with no fallback: a name the author wrote that misses is their error, and reporting it — with warnUnresolvedRef, once the series is read — beats papering over it with a column they did not name. Only the defaulted path walks the chain, trying canonical first and then each alternative in order — the type's own chain from DECLARED_FIELD_REF_FALLBACKS where it has one, and FIELD_REF_FALLBACKS otherwise.

      Every name, explicit or defaulted, is looked for in three places in turn: the row's own key, the dotted path it spells, and the row's properties — see readFromRow. Name priority dominates: properties.name beats a top-level id on a GeoJSON feature, because a region is called by its name rather than by its FIPS code.

      undefined and null both mean "no ref given" here, exactly as they do in validateDeclaration: the slots this rides in are frequently untyped chart config, where null is how an author writes "not set", and reading row['null'] for one would be a puzzle with no explanation attached.

      Returns undefined when nothing resolves, and the field is then omitted from the payload. Never substitute a zero, a false or a placeholder: a missing weight is a forest plot without weights, while a weight of 0 is a study that counted for nothing.

      A falsy value that is present — 0, '', false, null — resolves and stops the walk. Only an undefined reading moves on to the next name.

      An array counts as a row here rather than being rejected: a d3-hexbin bin is the array of points that fell in it, which is why length is one of count's fallbacks.

      Type Parameters

      • T

      Parameters

      • row: unknown

        The row the charting library bound to the mark — a Chart.js datum, a Highcharts point.options, an amCharts dataItem.dataContext, a d3 element.__data__. Typed unknown because most of those arrive that way; anything that is not an object resolves to nothing.

      • ref: string | undefined

        The field the author named, or undefined to default.

      • canonical: string

        The grammar field name being filled, e.g. 'yMin'.

      • Optionaltype:
            | ALLUVIAL
            | BOXEN
            | CHOROPLETH
            | ERROR_BAR
            | FOREST
            | GANTT
            | HEXBIN
            | MANHATTAN
            | MOSAIC
            | PARALLEL
            | RIDGELINE
            | SCATTER
            | SURVIVAL
            | VOLCANO

        The declared type being read, where one of its fields defaults differently from the shared chain — 'value' on a choropleth. Omitted, the shared chain applies.

      Returns T | undefined

      The value read, or undefined when nothing resolves.