sy-stem-leaf-chart

Stem Leaf

Read a distribution while retaining raw values.

sy-stem-leaf-chart

Inspect the digit distribution of a small numeric sample.

Choose the digit split and rounding unit first. Use Histogram for very large samples.

Base chart tier: Community. Features such as additional renderers and custom branding have separate entitlement requirements.

InputData description
valuesAn array of raw numeric samples, displayed as stems and leaves.

Complete implementation example

html
<div id="chart-container" style="width: 100%; min-width: 0;"></div>

<script type="module">
  import { defineCustomElement as define0 } from '@syidax/advanced/components/sy-stem-leaf-chart.js';
  define0();

  const specs = [
    {
      "id": "example-chart",
      "tag": "sy-stem-leaf-chart",
      "props": {
        "engine": "standard",
        "values": [23, 25, 28, 29, 30, 31, 31, 32, 32, 33, 34, 34, 35, 35, 36, 37, 38, 39, 42, 45, 48, 52],
        "width": 640,
        "height": 360,
        "brandPosition": "bottom-right",
        "brandLogo": ""
      }
    }
  ];
  const container = document.querySelector('#chart-container');
  const elements = specs.map(({ tag, id, props }) => {
    const element = document.createElement(tag);
    element.id = id;
    Object.assign(element, props);
    element.setAttribute('aria-label', 'stem-leaf example chart');
    return element;
  });
  container.replaceChildren(...elements);
  const chart = elements.at(-1);
  const onEvent = event => {
    console.log('pointClick', event.detail);
  };
  chart.addEventListener('pointClick', onEvent);
  const observer = new ResizeObserver(([entry]) => {
    const width = Math.max(160, Math.floor(entry.contentRect.width));
    elements.forEach(element => { element.width = width; });
  });
  observer.observe(container);

  // In an SPA, call this function when the view is disposed.
  function disposeChart() {
    observer.disconnect();
    chart.removeEventListener('pointClick', onEvent);
    container.replaceChildren();
  }
</script>

Properties

values

An array of raw numeric samples, displayed as stems and leaves.

ItemValue
JavaScript propertyvalues
HTML attributePass objects, arrays, and callbacks as JavaScript properties
TypeStemLeafValues
Default[]

width

Chart width in pixels. If the container width changes, update width from a ResizeObserver.

ItemValue
JavaScript propertywidth
HTML attributewidth
Typenumber
Default520

height

Chart height in pixels. Allow space for axes, titles, and the legend.

ItemValue
JavaScript propertyheight
HTML attributeheight
Typenumber
Default400

brandPosition

The corner where the logo is anchored. Community and Pro both support all four corners, using the same position on screen and in image exports.

ItemValue
JavaScript propertybrandPosition
HTML attributebrand-position
Type'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
Default'bottom-right'
Allowed valuestop-left, top-right, bottom-left, bottom-right

unit

Stem unit — one stem spans this much (default 10: stems are the tens digit).

ItemValue
JavaScript propertyunit
HTML attributeunit
Typenumber
Default10

split

1 (default) or 2: each stem splits into 0–4 / 5–9 half-rows.

ItemValue
JavaScript propertysplit
HTML attributesplit
Type1 | 2
Default1

color

Ink colour (single CSS colour / array / comma string — first colour wins).

ItemValue
JavaScript propertycolor
HTML attributePass objects, arrays, and callbacks as JavaScript properties
Typestring | ReadonlyArray<string>
Default'#111827'

activeColor

Accent for the hovered/focused leaf.

ItemValue
JavaScript propertyactiveColor
HTML attributeactive-color
Typestring
Default'#2563eb'

showKey

Show the reading key (2 | 3 = 23) under the plot.

ItemValue
JavaScript propertyshowKey
HTML attributeshow-key
Typeboolean
Defaulttrue

chartTitle

The title inside the chart. Explain the data's unit and meaning alongside it.

ItemValue
JavaScript propertychartTitle
HTML attributechart-title
Typestring
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

chartSubtitle

The subtitle inside the chart.

ItemValue
JavaScript propertychartSubtitle
HTML attributechart-subtitle
Typestring
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

tooltipShow

Whether to display the built-in tooltip.

ItemValue
JavaScript propertytooltipShow
HTML attributetooltip-show
Typeboolean
Defaulttrue

tooltipFormat

Pass as a JavaScript property. type: (leaf: StemLeafPointEventDetail) => string.

ItemValue
JavaScript propertytooltipFormat
HTML attributePass objects, arrays, and callbacks as JavaScript properties
Type(leaf: StemLeafPointEventDetail) => string
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

tooltip

Rich tooltip configuration object (family mirror). Property-only.

ItemValue
JavaScript propertytooltip
HTML attributePass objects, arrays, and callbacks as JavaScript properties
TypeStemLeafTooltipInput
Defaultundefined
Literals in the typeauto, off

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

enableMouseTracking

Set as an HTML attribute or JavaScript property. type: boolean.

ItemValue
JavaScript propertyenableMouseTracking
HTML attributeenable-mouse-tracking
Typeboolean
Defaulttrue

zoom

Zoom (Storybook parity, 2026-09-10) — the shared zoom surface as a VIEWPORT zoom: the plot area of the stems and leaves (the chart box minus the title band, the margins and the key band) is the plot, x 0 → 1 left to right and y 0 → 1 bottom to top. 'x' | 'y' | 'xy' | true (x) enable the drag rectangle, the pan, Ctrl + wheel, the pinch and the keyboard (+ / - / Escape); an object refines the switches. Off by default; zoomTo / zoomBy / panBy / resetZoom work regardless.

ItemValue
JavaScript propertyzoom
HTML attributePass objects, arrays, and callbacks as JavaScript properties
TypeCartesianZoomInput
Defaultundefined
Literals in the typeauto, off, true, false, x, y, xy, inside

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

engine

Renderer selection: auto, standard, or pro. Engine selection is separate from permission to use a Pro chart type.

ItemValue
JavaScript propertyengine
HTML attributeengine
TypeStemLeafEngineMode
Default'auto'
Allowed valuesauto, standard, pro

unavailable

Allowed values: fallback, error, throw. Default: 'fallback'.

ItemValue
JavaScript propertyunavailable
HTML attributeunavailable
TypeStemLeafUnavailableBehaviour
Default'fallback'
Allowed valuesfallback, error, throw

streamSource

A stream source for live data. Check the contract for the specific type.

ItemValue
JavaScript propertystreamSource
HTML attributePass objects, arrays, and callbacks as JavaScript properties
TypeStemLeafStreamSource
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

streamWindow

The streaming data range to keep visible.

ItemValue
JavaScript propertystreamWindow
HTML attributestream-window
Typenumber
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

streamMax

The maximum number of streaming data points to retain.

ItemValue
JavaScript propertystreamMax
HTML attributestream-max
Typenumber
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

animated

Whether to animate initial display and data changes.

ItemValue
JavaScript propertyanimated
HTML attributeanimate
Typeboolean
Defaultfalse

animationDuration

Animation duration in milliseconds.

ItemValue
JavaScript propertyanimationDuration
HTML attributeanimation-duration
Typenumber
Default600

animationEasing

Allowed values: linear, ease-out, ease-in, ease-in-out. Default: 'ease-out'.

ItemValue
JavaScript propertyanimationEasing
HTML attributeanimation-easing
TypeStemLeafEasing
Default'ease-out'
Allowed valueslinear, ease-out, ease-in, ease-in-out

animationType

Allowed values: initial, update. Default: undefined.

ItemValue
JavaScript propertyanimationType
HTML attributeanimation-type
TypeStemLeafAnimationType
Defaultundefined
Allowed valuesinitial, update

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

Events

rendered

Emits rendering results in detail when chart drawing completes.

Event name: rendered. Names are case-sensitive. Read the payload from detail on CustomEvent<StemLeafRenderResult & { tier: StemLeafEngineTier }>.

javascript
chart.addEventListener('rendered', event => {
  console.log(event.detail); // StemLeafRenderResult & { tier: StemLeafEngineTier }
});

pointClick

A point selection event. Read the selected data and index from CustomEvent.detail.

Event name: pointClick. Names are case-sensitive. Read the payload from detail on CustomEvent<StemLeafPointEventDetail>.

javascript
chart.addEventListener('pointClick', event => {
  console.log(event.detail); // StemLeafPointEventDetail
});

pointHover

CustomEvent.detail type: StemLeafPointEventDetail | null. Event names are case-sensitive.

Event name: pointHover. Names are case-sensitive. Read the payload from detail on CustomEvent<StemLeafPointEventDetail | null>.

javascript
chart.addEventListener('pointHover', event => {
  console.log(event.detail); // StemLeafPointEventDetail | null
});

pointContextMenu

CustomEvent.detail type: ChartPointContextMenuEventDetail<StemLeafPointEventDetail>. Event names are case-sensitive.

Event name: pointContextMenu. Names are case-sensitive. Read the payload from detail on CustomEvent<ChartPointContextMenuEventDetail<StemLeafPointEventDetail>>.

javascript
chart.addEventListener('pointContextMenu', event => {
  console.log(event.detail); // ChartPointContextMenuEventDetail<StemLeafPointEventDetail>
});

appended

CustomEvent.detail type: { count: number }. Event names are case-sensitive.

Event name: appended. Names are case-sensitive. Read the payload from detail on CustomEvent<{ count: number }>.

javascript
chart.addEventListener('appended', event => {
  console.log(event.detail); // { count: number }
});

windowSlid

CustomEvent.detail type: { dropped: number }. Event names are case-sensitive.

Event name: windowSlid. Names are case-sensitive. Read the payload from detail on CustomEvent<{ dropped: number }>.

javascript
chart.addEventListener('windowSlid', event => {
  console.log(event.detail); // { dropped: number }
});

chartAnimationStart

CustomEvent.detail type: void. Event names are case-sensitive.

Event name: chartAnimationStart. Names are case-sensitive. Read the payload from detail on CustomEvent<void>.

javascript
chart.addEventListener('chartAnimationStart', event => {
  console.log(event.detail); // void
});

chartAnimationEnd

CustomEvent.detail type: void. Event names are case-sensitive.

Event name: chartAnimationEnd. Names are case-sensitive. Read the payload from detail on CustomEvent<void>.

javascript
chart.addEventListener('chartAnimationEnd', event => {
  console.log(event.detail); // void
});

chartAnimationInterrupted

CustomEvent.detail type: void. Event names are case-sensitive.

Event name: chartAnimationInterrupted. Names are case-sensitive. Read the payload from detail on CustomEvent<void>.

javascript
chart.addEventListener('chartAnimationInterrupted', event => {
  console.log(event.detail); // void
});

tooltipShow

Whether to display the built-in tooltip.

Event name: tooltipShow. Names are case-sensitive. Read the payload from detail on CustomEvent<StemLeafTooltipShowEventDetail>.

javascript
chart.addEventListener('tooltipShow', event => {
  console.log(event.detail); // StemLeafTooltipShowEventDetail
});

tooltipHide

CustomEvent.detail type: void. Event names are case-sensitive.

Event name: tooltipHide. Names are case-sensitive. Read the payload from detail on CustomEvent<void>.

javascript
chart.addEventListener('tooltipHide', event => {
  console.log(event.detail); // void
});

tooltipAction

CustomEvent.detail type: StemLeafTooltipActionEventDetail. Event names are case-sensitive.

Event name: tooltipAction. Names are case-sensitive. Read the payload from detail on CustomEvent<StemLeafTooltipActionEventDetail>.

javascript
chart.addEventListener('tooltipAction', event => {
  console.log(event.detail); // StemLeafTooltipActionEventDetail
});

zoomChange

Fired after every zoom change (drag / pan / wheel / pinch / keyboard / api / reset) with the new viewport windows.

Event name: zoomChange. Names are case-sensitive. Read the payload from detail on CustomEvent<CartesianZoomChangeEventDetail>.

javascript
chart.addEventListener('zoomChange', event => {
  console.log(event.detail); // CartesianZoomChangeEventDetail
});

Methods

redraw

Redraw the chart using its current data and options. Inspect the rendered result after the returned Promise resolves.

typescript
redraw(): Promise<StemLeafRenderResult>

Return type: Promise<StemLeafRenderResult>. Call the method after element registration and await its Promise result.

getActiveTier

An asynchronous method. Check the argument and return types below.

typescript
getActiveTier(): Promise<StemLeafEngineTier>

Return type: Promise<StemLeafEngineTier>. Call the method after element registration and await its Promise result.

setData

Replace the bar set.

typescript
setData(values: StemLeafValues): Promise<void>
ArgumentsTypeRequired
valuesStemLeafValuesRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.

appendPoint

Append one value to the stream. Check the argument type and the licensing requirements for streaming.

typescript
appendPoint(value: number): Promise<void>
ArgumentsTypeRequired
valuenumberRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.

appendBatch

Append multiple values to the stream. Check the argument type and the licensing requirements for streaming.

typescript
appendBatch(values: ReadonlyArray<number>): Promise<void>
ArgumentsTypeRequired
valuesReadonlyArray<number>Required

Return type: Promise<void>. Call the method after element registration and await its Promise result.

shift

Drop the oldest streamed categories (the data boxes are not the stream).

typescript
shift(count?: number): Promise<void>
ArgumentsTypeRequired
countnumberOptional

Return type: Promise<void>. Call the method after element registration and await its Promise result.

replace

Swap the streamed set (replace([]) clears it); the base values never leave. Without chart.streaming the dies upsert into the base like a batch (quietly: no appended, no binChanged, as a ring replace).

typescript
replace(values: ReadonlyArray<number>): Promise<void>
ArgumentsTypeRequired
valuesReadonlyArray<number>Required

Return type: Promise<void>. Call the method after element registration and await its Promise result.

getStreamSource

The stream session's source (Chart Pro): like the stream methods it waits for a license still being confirmed.

typescript
getStreamSource(): Promise<StemLeafStreamSource | undefined>

Return type: Promise<StemLeafStreamSource | undefined>. Call the method after element registration and await its Promise result.

setAnimation

An asynchronous method. Check the argument and return types below.

typescript
setAnimation(options: { duration?: number; easing?: StemLeafEasing; enabled?: boolean; type?: StemLeafAnimationType }): Promise<void>
ArgumentsTypeRequired
options{ duration?: number; easing?: StemLeafEasing; enabled?: boolean; type?: StemLeafAnimationType }Required

Return type: Promise<void>. Call the method after element registration and await its Promise result.

pauseAnimation

Pause the current animation.

typescript
pauseAnimation(): Promise<void>

Return type: Promise<void>. Call the method after element registration and await its Promise result.

resumeAnimation

Resume a paused animation.

typescript
resumeAnimation(): Promise<void>

Return type: Promise<void>. Call the method after element registration and await its Promise result.

replayAnimation

Replay the initial sweep from min → value(s). No-op when animation is off / reduced.

typescript
replayAnimation(): Promise<void>

Return type: Promise<void>. Call the method after element registration and await its Promise result.

hitTestLeaf

Stem-leaf-only — hit-test the leaf at canvas-relative coordinates.

typescript
hitTestLeaf(cssX: number, cssY: number): Promise<{ sourceIndex: number; value: number; stemLabel: string; digit: number } | null>
ArgumentsTypeRequired
cssXnumberRequired
cssYnumberRequired

Return type: Promise<{ sourceIndex: number; value: number; stemLabel: string; digit: number } | null>. Call the method after element registration and await its Promise result.

showTooltipAtLeaf

Stem-leaf-only — programmatic tooltip open on a leaf by source index.

typescript
showTooltipAtLeaf(sourceIndex: number): Promise<StemLeafPointEventDetail | null>
ArgumentsTypeRequired
sourceIndexnumberRequired

Return type: Promise<StemLeafPointEventDetail | null>. Call the method after element registration and await its Promise result.

hideTooltip

Close the currently visible tooltip.

typescript
hideTooltip(): Promise<void>

Return type: Promise<void>. Call the method after element registration and await its Promise result.

zoomTo

Zoom to explicit viewport windows: x / y as { min, max } or [min, max] over 0..1 (null clears that orientation).

typescript
zoomTo(request: CartesianZoomRequest): Promise<CartesianZoomChangeEventDetail | null>
ArgumentsTypeRequired
requestCartesianZoomRequestRequired

Return type: Promise<CartesianZoomChangeEventDetail | null>. Call the method after element registration and await its Promise result.

zoomBy

Scale the current windows by factor (< 1 zooms in) around anchorFraction (0..1, default centre).

typescript
zoomBy(factor: number, anchorFraction?: number): Promise<CartesianZoomChangeEventDetail | null>
ArgumentsTypeRequired
factornumberRequired
anchorFractionnumberOptional

Return type: Promise<CartesianZoomChangeEventDetail | null>. Call the method after element registration and await its Promise result.

panBy

Slide the zoomed windows by viewport units ({ x?, y? }, 1 = the whole plot); a no-op at the full extent.

typescript
panBy(delta: { x?: number; y?: number }): Promise<CartesianZoomChangeEventDetail | null>
ArgumentsTypeRequired
delta{ x?: number; y?: number }Required

Return type: Promise<CartesianZoomChangeEventDetail | null>. Call the method after element registration and await its Promise result.

resetZoom

Reset the zoomed or panned range to the original data range.

typescript
resetZoom(): Promise<CartesianZoomChangeEventDetail | null>

Return type: Promise<CartesianZoomChangeEventDetail | null>. Call the method after element registration and await its Promise result.

getZoom

Read the current zoom range. Check the return type's nullability and the range for each axis.

typescript
getZoom(): Promise<CartesianZoomState | null>

Return type: Promise<CartesianZoomState | null>. Call the method after element registration and await its Promise result.

getZoomExtent

The full extent (0..1 on both orientations, key '0').

typescript
getZoomExtent(request?: CartesianZoomExtentRequest): Promise<CartesianZoomExtentDetail | null>
ArgumentsTypeRequired
requestCartesianZoomExtentRequestOptional

Return type: Promise<CartesianZoomExtentDetail | null>. Call the method after element registration and await its Promise result.

getEngineStatus

Requested engine vs what runs, and why (CHART-ADD-08): always Standard (this type has no WebGPU renderer); read without side effects, never consults the license.

typescript
getEngineStatus(): Promise<ChartEngineStatus>

Return type: Promise<ChartEngineStatus>. Call the method after element registration and await its Promise result.