Histogram.

COMMUNITY

Summarize continuous measurements as interval frequencies.

Live preview22 feature examples

LIVE EXAMPLE

Frequency distribution

Match the page theme
Interact with the chart to see selection and range-change results here.
OptionsChanges are reflected in the preview and code.
Appearance and style5
Axes and grid lines15
Legend and interaction13
Title and dimensions3

Group raw measurements into six bins. All values are sample data.

View code
Current preview
<div id="chart-container" style="width: 100%; min-width: 0;"></div>

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

  const specs = [
    {
      "id": "example-chart",
      "tag": "sy-histogram-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],
        "bins": 6,
        "measure": "count",
        "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', 'histogram 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>

Usage and data

#

Explore distributions of response times, measurements, prices, and other numeric values.

The shape changes with the bin count. Check the raw sample count and bin width together.

Data contract

PropertyInput format
valuesRaw numeric samples, not pre-aggregated bin counts.
binsThe number of bins or the binning method.
measureThe vertical axis represents count, percent, or density.

Updating data

Assign a new array or object to the property instead of mutating values inside an array. Chart events provide selection results through event.detail. When disposing of the view, clean up ResizeObserver and event listeners registered by your app.

Add to your interface

#

The code tabs below the preview contain the full data, options, event bindings, and responsive sizing for the current example. Copy them into an app project, such as Vite, that can resolve the installed packages.

Shared sy-chart API versus direct tags

API reference

#

The full public API for sy-histogram-chart. Pass objects and arrays as JavaScript properties. Select a name to view usage code and type definitions.

Key properties

Attribute / PropertyType / DefaultDescription
HistogramValuesDefault: new Float32Array(0)Raw numeric samples, not pre-aggregated bin counts.
numberDefault: 640Chart width in pixels. Update with ResizeObserver when the container changes.
numberDefault: 360Chart height in pixels.
brandLogostringDefault: undefinedThe default is the Syidax logo. With the Pro chart.branding entitlement, use none or a PNG, JPEG, or WebP data URL.
brandPosition'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'Default: 'bottom-right'The corner where the logo is anchored. Applies equally to Community and Pro, on screen and in image exports.
HistogramBinsRuleDefault: 'square-root'The number of bins or the binning method.
edgeColorstringDefault: 'rgba(255,255,255,0.85)'1px separator between gapless bars.
valueAxisLabelstringDefault: undefinedSet as an HTML attribute or JavaScript property. type: string.
HistogramNormalizeDefault: 'count'The vertical axis represents count, percent, or density.
booleanDefault: falseSet as an HTML attribute or JavaScript property. type: boolean.
barGapnumberDefault: 0Set as an HTML attribute or JavaScript property. type: number.
xAxisCartesianAxisInput | ReadonlyArray<CartesianAxisInput>Default: undefinedAllowed values: auto, off. Default: undefined.
yAxisCartesianAxisInput | ReadonlyArray<CartesianAxisInput>Default: undefinedAllowed values: auto, off. Default: undefined.
gridLinesCartesianGridLinesInputDefault: undefinedAllowed values: auto, off. Default: undefined.
CartesianCrosshairInputDefault: undefinedCrosshair that follows the cursor across the plot.
CartesianZoomInputDefault: undefinedSettings for zooming and the visible range.
chartTitlestringDefault: undefinedThe title inside the chart. Explain the data's unit and meaning alongside it.
chartSubtitlestringDefault: undefinedThe subtitle inside the chart.
tooltipEnabledbooleanDefault: trueSet as an HTML attribute or JavaScript property. type: boolean.
CartesianTooltipInputDefault: undefinedTooltip settings for pointer-driven values, position, and content.
animatedbooleanDefault: falseWhether to animate initial display and data changes.
animationDurationnumberDefault: 600Animation duration in milliseconds.
animationEasingHistogramEasingDefault: 'ease-out'Allowed values: linear, ease-out, ease-in, ease-in-out. Default: 'ease-out'.
animationTypeHistogramAnimationTypeDefault: undefinedAllowed values: initial, update. Default: undefined.
Other properties 13
Attribute / PropertyType / DefaultDescription
binWidthnumberDefault: undefinedExplicit bin width — wins over `bins`.
domainMinnumberDefault: undefinedDomain overrides (observations outside clamp into the edge bins).
domainMaxnumberDefault: undefinedSet as an HTML attribute or JavaScript property. type: number.
string | ReadonlyArray<string>Default: '#2563eb'Bar fill. Accepts a single CSS colour, an array, or a comma string (first wins).
activeColorstringDefault: '#1d4ed8'Fill for the hovered bin.
tooltipFormat(detail: HistogramPointEventDetail) => stringDefault: undefinedPass as a JavaScript property. type: (detail: HistogramPointEventDetail) => string.
enableMouseTrackingbooleanDefault: trueSet as an HTML attribute or JavaScript property. type: boolean.
streamSourceHistogramStreamSourceDefault: undefinedA stream source for live data. Check the contract for the specific type.
streamWindownumberDefault: undefinedThe streaming data range to keep visible.
streamMaxnumberDefault: undefinedThe maximum number of streaming data points to retain.
HistogramEngineModeDefault: 'auto'Renderer selection: auto, standard, or pro. Engine selection is separate from permission to use a Pro chart type.
proThresholdnumberDefault: 50_000Set as an HTML attribute or JavaScript property. type: number.
HistogramUnavailableBehaviourDefault: 'fallback'Allowed values: fallback, error. Default: 'fallback'.
Events 15
EventsDetail typeDescription
HistogramRenderResult & { tier: HistogramEngineTier }Emits rendering results in detail when chart drawing completes.
HistogramPointEventDetailA point selection event. Read the selected data and index from CustomEvent.detail.
HistogramPointEventDetail | nullCustomEvent.detail type: HistogramPointEventDetail | null. Event names are case-sensitive.
CartesianCrosshairEventDetail | nullCustomEvent.detail type: CartesianCrosshairEventDetail | null. Event names are case-sensitive.
ChartPointContextMenuEventDetail<HistogramPointEventDetail>CustomEvent.detail type: ChartPointContextMenuEventDetail<HistogramPointEventDetail>. Event names are case-sensitive.
{ count: number }CustomEvent.detail type: { count: number }. Event names are case-sensitive.
{ dropped: number }CustomEvent.detail type: { dropped: number }. Event names are case-sensitive.
voidCustomEvent.detail type: void. Event names are case-sensitive.
voidCustomEvent.detail type: void. Event names are case-sensitive.
voidCustomEvent.detail type: void. Event names are case-sensitive.
CartesianTooltipEventDetailWhether to display the built-in tooltip.
voidCustomEvent.detail type: void. Event names are case-sensitive.
CartesianTooltipActionEventDetailCustomEvent.detail type: CartesianTooltipActionEventDetail. Event names are case-sensitive.
CartesianSeriesOutsideClickEventDetailCustomEvent.detail type: CartesianSeriesOutsideClickEventDetail. Event names are case-sensitive.
CartesianZoomChangeEventDetailFired after every zoom change (drag / pan / wheel / pinch / keyboard / api / reset) with the new state.
Methods 23

Stencil methods return Promises. Use await within an async function to read the result.

Method / ArgumentsReturn typeDescription
Promise<HistogramRenderResult>An asynchronous method. Check the argument and return types below.
Promise<HistogramEngineTier>An asynchronous method. Check the argument and return types below.
Promise<HistogramBinning>An asynchronous method. Check the argument and return types below.
values: HistogramValuesPromise<void>An asynchronous method. Check the argument and return types below.
value: numberPromise<void>An asynchronous method. Check the argument and return types below.
values: ReadonlyArray<number>Promise<void>An asynchronous method. Check the argument and return types below.
count: numberPromise<void>An asynchronous method. Check the argument and return types below.
values: ReadonlyArray<number>Promise<void>An asynchronous method. Check the argument and return types below.
Promise<HistogramStreamSource | undefined>The stream session's source (Chart Pro): like the stream methods it waits for a license still being confirmed.
Promise<ChartEngineStatus>The requested engine, the engine that draws and why (ROADMAP-loading §5.3). A Chart Pro license decision names `chart.webgpu` and its state; renderer causes (not in this build, no WebGPU, a failed GPU) stay apart.
options: { duration?: number; easing?: HistogramEasing; enabled?: boolean; type?: HistogramAnimationType }Promise<void>An asynchronous method. Check the argument and return types below.
Promise<void>An asynchronous method. Check the argument and return types below.
Promise<void>An asynchronous method. Check the argument and return types below.
Promise<void>An asynchronous method. Check the argument and return types below.
cssX: number, cssY: numberPromise<HistogramPointEventDetail | null>An asynchronous method. Check the argument and return types below.
binIndex: numberPromise<CartesianTooltipEventDetail | null>An asynchronous method. Check the argument and return types below.
Promise<void>An asynchronous method. Check the argument and return types below.
request: CartesianZoomRequestPromise<CartesianZoomChangeEventDetail | null>Zoom to explicit windows: `x` / `y` as `{ min, max }` or `[min, max]` (`null` clears that orientation); `xAxis` / `yAxis` name the axis by id or slot index.
factor: number, anchorFraction?: numberPromise<CartesianZoomChangeEventDetail | null>Scale the current windows by `factor` (< 1 zooms in) around `anchorFraction` (0..1, default centre).
delta: { x?: number; y?: number }Promise<CartesianZoomChangeEventDetail | null>Slide the zoomed windows by data units (`{ x?, y? }`); a no-op at the full extent.
Promise<CartesianZoomChangeEventDetail | null>Back to the full extent.
Promise<CartesianZoomState | null>The current zoom state (`null` = full extent).
request?: CartesianZoomExtentRequestPromise<CartesianZoomExtentDetail | null>The full extent (and key) of the primary — or the named — master axes (`null` before the first layout).