Histogram.
COMMUNITYSummarize continuous measurements as interval frequencies.
LIVE EXAMPLE
Frequency distribution
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
<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
| Property | Input format |
|---|---|
values | Raw numeric samples, not pre-aggregated bin counts. |
bins | The number of bins or the binning method. |
measure | The 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.
Feature examples
#Try 22 interactive feature examples and inspect their code. Select “Edit in preview” to combine more options in the settings panel above.
Percentage distribution
Show frequency as a share of the total sample.
View code
Cumulative distribution
Read the cumulative frequency as the bin range increases.
View code
Inspect values with the pointer
Point to data to view the value at that location.
View code
Crosshair tracking
Move the pointer to read horizontal and vertical coordinates alongside values.
View code
Drag to zoom and pan
Drag to zoom and hold Shift to pan. Use Ctrl + wheel to zoom in or out.
View code
Replay animation
Redraw the same example to inspect its initial display animation.
View code
Animation
Compare 1 examples of Animation. Buttons and options update both the live result and source code.
View code
Axis
Compare 7 examples of Axis. Buttons and options update both the live result and source code.
View code
Binning
Compare 4 examples of Binning. Buttons and options update both the live result and source code.
View code
Crosshair
Compare 5 examples of Crosshair. Buttons and options update both the live result and source code.
View code
Engine Compare
Compare 3 examples of Engine Compare. Buttons and options update both the live result and source code.
View code
Large datasets
Compare 1 examples of Large datasets. Buttons and options update both the live result and source code.
View code
Render
Compare 4 examples of Render. Buttons and options update both the live result and source code.
View code
Size
Compare 1 examples of Size. Buttons and options update both the live result and source code.
View code
Tooltip
Compare 12 examples of Tooltip. Buttons and options update both the live result and source code.
View code
Data input
Compare 1 examples of Data input. Buttons and options update both the live result and source code.
View code
Zoom and pan
Compare 6 examples of Zoom and pan. Buttons and options update both the live result and source code.
View code
Context menu
Compare 1 examples of Context menu. Buttons and options update both the live result and source code.
View code
Data context menu
Compare 1 examples of Data context menu. Buttons and options update both the live result and source code.
View code
Read coordinates and data
Compare 1 examples of Read coordinates and data. Buttons and options update both the live result and source code.
View code
Overview
Compare 3 examples of Overview. Buttons and options update both the live result and source code.
View code
Streaming · Add and update live dataPRO
Compare 4 examples of Add and update live data. Buttons and options update both the live result and source code.
View code
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.
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 / Property | Type / Default | Description |
|---|---|---|
HistogramValuesDefault: new Float32Array(0) | Raw numeric samples, not pre-aggregated bin counts. | |
numberDefault: 640 | Chart width in pixels. Update with ResizeObserver when the container changes. | |
numberDefault: 360 | Chart height in pixels. | |
| brandLogo | stringDefault: undefined | The 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. | |
| edgeColor | stringDefault: 'rgba(255,255,255,0.85)' | 1px separator between gapless bars. |
| valueAxisLabel | stringDefault: undefined | Set as an HTML attribute or JavaScript property. type: string. |
HistogramNormalizeDefault: 'count' | The vertical axis represents count, percent, or density. | |
booleanDefault: false | Set as an HTML attribute or JavaScript property. type: boolean. | |
| barGap | numberDefault: 0 | Set as an HTML attribute or JavaScript property. type: number. |
| xAxis | CartesianAxisInput | ReadonlyArray<CartesianAxisInput>Default: undefined | Allowed values: auto, off. Default: undefined. |
| yAxis | CartesianAxisInput | ReadonlyArray<CartesianAxisInput>Default: undefined | Allowed values: auto, off. Default: undefined. |
| gridLines | CartesianGridLinesInputDefault: undefined | Allowed values: auto, off. Default: undefined. |
CartesianCrosshairInputDefault: undefined | Crosshair that follows the cursor across the plot. | |
CartesianZoomInputDefault: undefined | Settings for zooming and the visible range. | |
| chartTitle | stringDefault: undefined | The title inside the chart. Explain the data's unit and meaning alongside it. |
| chartSubtitle | stringDefault: undefined | The subtitle inside the chart. |
| tooltipEnabled | booleanDefault: true | Set as an HTML attribute or JavaScript property. type: boolean. |
CartesianTooltipInputDefault: undefined | Tooltip settings for pointer-driven values, position, and content. | |
| animated | booleanDefault: false | Whether to animate initial display and data changes. |
| animationDuration | numberDefault: 600 | Animation duration in milliseconds. |
| animationEasing | HistogramEasingDefault: 'ease-out' | Allowed values: linear, ease-out, ease-in, ease-in-out. Default: 'ease-out'. |
| animationType | HistogramAnimationTypeDefault: undefined | Allowed values: initial, update. Default: undefined. |
Other properties 13
| Attribute / Property | Type / Default | Description |
|---|---|---|
| binWidth | numberDefault: undefined | Explicit bin width — wins over `bins`. |
| domainMin | numberDefault: undefined | Domain overrides (observations outside clamp into the edge bins). |
| domainMax | numberDefault: undefined | Set 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). | |
| activeColor | stringDefault: '#1d4ed8' | Fill for the hovered bin. |
| tooltipFormat | (detail: HistogramPointEventDetail) => stringDefault: undefined | Pass as a JavaScript property. type: (detail: HistogramPointEventDetail) => string. |
| enableMouseTracking | booleanDefault: true | Set as an HTML attribute or JavaScript property. type: boolean. |
| streamSource | HistogramStreamSourceDefault: undefined | A stream source for live data. Check the contract for the specific type. |
| streamWindow | numberDefault: undefined | The streaming data range to keep visible. |
| streamMax | numberDefault: undefined | The 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. | |
| proThreshold | numberDefault: 50_000 | Set as an HTML attribute or JavaScript property. type: number. |
HistogramUnavailableBehaviourDefault: 'fallback' | Allowed values: fallback, error. Default: 'fallback'. |
Events 15
| Events | Detail type | Description |
|---|---|---|
HistogramRenderResult & { tier: HistogramEngineTier } | Emits rendering results in detail when chart drawing completes. | |
HistogramPointEventDetail | A point selection event. Read the selected data and index from CustomEvent.detail. | |
HistogramPointEventDetail | null | CustomEvent.detail type: HistogramPointEventDetail | null. Event names are case-sensitive. | |
CartesianCrosshairEventDetail | null | CustomEvent.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. | |
void | CustomEvent.detail type: void. Event names are case-sensitive. | |
void | CustomEvent.detail type: void. Event names are case-sensitive. | |
void | CustomEvent.detail type: void. Event names are case-sensitive. | |
CartesianTooltipEventDetail | Whether to display the built-in tooltip. | |
void | CustomEvent.detail type: void. Event names are case-sensitive. | |
CartesianTooltipActionEventDetail | CustomEvent.detail type: CartesianTooltipActionEventDetail. Event names are case-sensitive. | |
CartesianSeriesOutsideClickEventDetail | CustomEvent.detail type: CartesianSeriesOutsideClickEventDetail. Event names are case-sensitive. | |
CartesianZoomChangeEventDetail | Fired 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 / Arguments | Return type | Description |
|---|---|---|
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: HistogramValues | Promise<void> | An asynchronous method. Check the argument and return types below. |
| value: number | Promise<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: number | Promise<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: number | Promise<HistogramPointEventDetail | null> | An asynchronous method. Check the argument and return types below. |
| binIndex: number | Promise<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: CartesianZoomRequest | Promise<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?: number | Promise<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?: CartesianZoomExtentRequest | Promise<CartesianZoomExtentDetail | null> | The full extent (and key) of the primary — or the named — master axes (`null` before the first layout). |
No matching APIs.