Skip to content

Fountain (Jet d'Eau) API

One chart, two modes: apex height = value, blooming plume = uncertainty. Categorical x = snapshot/comparison; temporal or numeric x = trend - see the Fountain demo.

Import

ts
import "@michi-vz/wc/fountain-chart";
// <michi-vz-fountain-chart> is now defined
ts
import { mountFountainChart } from "@michi-vz/core";

const chart = mountFountainChart(el, props);

Props

PropTypeDefaultDescription
dataSet*FountainDataItem[]Array of jets; each item renders one fountain
titlestringOptional chart title rendered above the plot
style"jet" | "plume""jet"Silhouette style: "jet" (default) is the faithful asymmetric Jet d'Eau (vertical column + wind-blown diagonal + a triangular droplet spray curtain); "plume" is the symmetric blooming column.
xAxisDataTypeFountainXAxisTypeHow the x-axis is parsed: a temporal/numeric type renders TREND mode; "band" (or omitted) renders SNAPSHOT mode
yAxisDomain[number, number]Explicit [min, max] for the value (y) axis; overrides the auto domain from value + spread
xAxisFormat(d: number | string) => stringFormats an x tick value into its display label
yAxisFormat(d: number | string) => stringFormats a y tick value into its display label
ticksnumber5Approximate number of axis ticks to generate
tickValuesArray<number | Date>Explicit tick values, overriding the generated ones (trend mode)
frothLayersnumber14Number of graduated-opacity froth layers per jet (default 8, max 20); a per-item density overrides it
bloomExponentnumber5Exponent in the bloom easing w(h)=stemHalf+spread*(h/H)^p; larger = tighter column, sharper crown (default 3)
stemFractionnumber0.045Stem half-width at the base as a fraction of the jet's slot width (default 0.08)
showDropletsbooleantrueDraw ballistic droplet arcs above each apex (default true)
showMistbooleantrueDraw the misty falling skirt around each nozzle (default true)
showTrendLinebooleantrueDraw a connecting line through the apexes in trend mode (default true)
tooltipFormatter(d: FountainDataItem) => stringReturns custom tooltip HTML for a hovered jet (sanitized before it is inserted)
onHighlightItem(labels: string[]) => voidCalled when the hovered/highlighted label(s) change
Common props — shared by every chart (14)
PropTypeDefaultDescription
widthnumber900Chart width in pixels
heightnumber480Chart height in pixels
marginMargin{ top: 50, right: 40, bottom: 50, left: 60 }Inner margins (top/right/bottom/left, in px) reserved for axes, titles, and labels
colorsstring[]Categorical palette for series/labels without an explicit colour or colorsMapping entry
colorsMappingRecord<string, string>Explicit label -> colour map; takes precedence over the palette and per-item colours
highlightItemsstring[]Labels to emphasise; all other marks dim
disabledItemsstring[]Labels to hide and exclude from scales/stacks
renderer"svg" | "canvas""svg"Render as inline SVG (default) or to a canvas (faster for large datasets); getContext() is identical either way
localestringBCP-47 locale used for number and date formatting
skipColorMappingDispatchbooleanfalseExternal-CSS mode: unmapped labels resolve to transparent and onColorMappingGenerated is not emitted, so mark colours come from your CSS via the data-label-safe contract
enableTransitionsbooleantrueAnimate updates with CSS transitions (default true)
onColorMappingGenerated(mapping: Record<string, string>) => voidCalled with the resolved label -> colour map after the chart assigns colours
onChartDataProcessed(context: ChartContext) => voidCalled with the renderer-agnostic ChartContext whenever the data is (re)processed
onDataWarning(warnings: DataWarning[]) => voidCalled with any non-fatal data warnings (duplicate labels, non-finite values, gaps, ...)

Two modes, one data shape

Set xAxisDataType: "band" (or omit it) for Snapshot mode - each item gets its own x-band, side by side. Provide a temporal or numeric xAxisDataType plus a date on each item for Trend mode - the jets are placed along the time axis and a trend line threads their apexes. A predicted: true item renders dashed with a frothier crown.

Events

The web component dispatches these bubbling CustomEvents (the engine exposes the same via the on* callbacks in the table above):

EventDetailFires when
michi-vz:highlightstring[]hover highlight changes (jet label)
michi-vz:colormappingRecord<string, string>a color mapping is generated
michi-vz:dataprocessedChartContextdata is (re)processed
michi-vz:datawarningDataWarning[]input warnings are detected (e.g. non-finite value or spread)

getContext()

mountFountainChart(el, props).getContext() returns a renderer-agnostic FountainChartContext:

  • mode - "snapshot" for a categorical/band x, "trend" for a temporal/numeric x.
  • jets - one entry per visible jet: { label, code?, color, value, spread, upperBound, spreadRatio, predicted, xPosition }. upperBound = value + spread; spreadRatio = spread / value (relative uncertainty); xPosition is the raw date/number in trend mode, or null in snapshot mode.
  • stats - summary object:
    • jetCount - number of visible jets.
    • tallest - { label, value } of the highest jet, or null if empty.
    • frothiest - { label, spreadRatio } of the most uncertain jet, or null if empty.
    • trendSlope - slope of a linear regression through the jet values by index in trend mode; null in snapshot mode.
    • valueRange - [min, max] of the jet values, or null if empty.
    • predictedCount - number of forecast jets.

See LLM context for how to use the context in prompts and reports.

Source

Props are typed as FountainChartProps in @michi-vz/core.

Free and open source. MIT licensed.