The packages are released with
hatchmark at the same version; install the version your serve runs,
so the payloads and the renderer match. The served script always matches its serve. Palettes other
than the default, map and cohort drawing, and map boundaries load on first use.
Elements
<hatchmark-scope>
Charts inside share its endpoint and theme, filter each other with picks and show one build.
While a pick holds, the scope shows it as a chip with a button that clears it, above its charts or
floating at the bottom of a phone’s screen, as a dashboard’s header does; style it with
hatchmark-scope::part(picks).
Setting picks makes the scope controlled: a click or the chip’s clear button then only fires
hatchmark-pick, and the app sets picks to apply it. A page drawn on the server with picks sets
the picks attribute, so the charts take over the drawn payloads without fetching them again.
<hatchmark-chart>
A chart draws at the width its container gives it and redraws when the width changes. It takes the
dashboard’s phone layout when the screen is a phone’s, as a dashboard does, whatever the chart’s own
width. Its card fills the element’s height, so charts in a row your layout stretches line up.
Events
Both bubble out of shadow roots.React
fetchBlock takes period, filters, picks, endpoint (default HATCHMARK_URL), headers and
signal, and throws HatchmarkError with the API’s code when the API answers an error. A
HatchmarkChart given a payload is drawn on the server, except maps with boundaries, which draw
once their boundaries load.
Types
/api/v1/types.d.ts holds the build’s blocks as TypeScript, except those of a dashboard on which
no block reads data, which have no payload. Saved anywhere your app compiles, it
types block, period and filters on HatchmarkChart, useHatchmarkBlock and fetchBlock, and
block on <hatchmark-chart>, so a name the build doesn’t have fails to compile:
periodlists the dashboard’s presets, plus{ start, end }and"<first>..<last>"when it offers custom ranges. It isneveron a dashboard without a period filter. A period filter with another id thanperiodis set throughfiltersunder its id instead.filterstakes grain keys as written in the build, a segment filter as a comma-separated string, and select values as strings, since the data decides them. A filter set toundefinedis left out of the request.- A block whose id comes from its position is marked
@deprecated: the id changes when blocks move, so give it anid:in its dashboard file.
_hatchmark/api/types.d.ts in its output, so an app in the same repository can include it from
there.
Drawing on any JavaScript server
@hatchmark/elements/server draws a chart to HTML with no DOM, for servers that aren’t React:
<hatchmark-chart> with its drawing in a declarative shadow root. A map with boundaries
needs them in geographies, from await geographiesFor(payload).
payloadShadowHtml(payload) returns a shadow root with only the payload, for a chart the browser
should draw without fetching it again.