Dumbbell.
COMMUNITYConnect two measurements to show their difference.
LIVE EXAMPLE
Before and after
Appearance and style5
Axes and grid lines17
Legend and interaction14
Title and dimensions3
Connect two measurements for each item to show their difference. 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-dumbbell-chart.js';
define0();
const specs = [
{
"id": "example-chart",
"tag": "sy-dumbbell-chart",
"props": {
"engine": "standard",
"data": [
{
"category": "Team A",
"values": [35, 65]
},
{
"category": "Team B",
"values": [50, 75]
},
{
"category": "Team C",
"values": [42, 82]
}
],
"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', 'dumbbell 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
#Compare two reference points per category, such as before and after or target and actual.
Explain the meaning and unit of both endpoints. The connecting length represents their difference.
Data contract
| Property | Input format |
|---|---|
data | An array of { category, values: [low, high] }. |
color | Set endpoint colors as [first, second]. |
groups | Names for the two endpoints. |
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 23 interactive feature examples and inspect their code. Select “Edit in preview” to combine more options in the settings panel above.
Names for two reference values
Identify the endpoints as target and actual.
View code
Arrange for difference comparison
Compare by adjusting item order and connector thickness.
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
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
Color
Compare 3 examples of Color. Buttons and options update both the live result and source code.
View code
Crosshair
Compare 4 examples of Crosshair. Buttons and options update both the live result and source code.
View code
Legend
Compare 4 examples of Legend. Buttons and options update both the live result and source code.
View code
Markers
Compare 2 examples of Markers. Buttons and options update both the live result and source code.
View code
Null Values
Compare 1 examples of Null Values. 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
Data input
Compare 1 examples of Data input. Buttons and options update both the live result and source code.
View code
Size
Compare 2 examples of Size. Buttons and options update both the live result and source code.
View code
Sorting
Compare 2 examples of Sorting. Buttons and options update both the live result and source code.
View code
Appearance and style
Compare 1 examples of Appearance and style. 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 2 examples of Data input. 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
Runtime API
Compare 1 examples of Runtime API. Buttons and options update both the live result and source code.
View code
Overview
Compare 1 examples of Overview. Buttons and options update both the live result and source code.
View code
Streaming · Add and update live dataPRO
Compare 1 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-dumbbell-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 |
|---|---|---|
ReadonlyArray<DumbbellDatum>Default: [] | An array of { category, values: [low, high] }. | |
ReadonlyArray<string>Default: undefined | Names for the two endpoints. | |
| lowName | stringDefault: undefined | Compatibility alias for `groups[0]`. |
| highName | stringDefault: undefined | Compatibility alias for `groups[1]`. |
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. |
string | ReadonlyArray<string>Default: '' | Set endpoint colors as [first, second]. | |
| lineWidth | numberDefault: 3 | Connector width in CSS px. |
| markerSize | numberDefault: 6 | Marker radius in CSS px. |
| sortDescending | booleanDefault: false | Set as an HTML attribute or JavaScript property. type: boolean. |
| valueAxisLabel | stringDefault: undefined | Set as an HTML attribute or JavaScript property. type: string. |
| xAxis | CartesianAxisInput | ReadonlyArray<CartesianAxisInput>Default: undefined | Allowed values: auto, off. Default: undefined. |
| yAxis | CartesianAxisInputDefault: undefined | Allowed values: auto, off. Default: undefined. |
| gridLines | CartesianGridLinesInputDefault: undefined | Allowed values: auto, off. Default: undefined. |
| xLabelMode | 'auto' | 'all' | 'thin' | 'rotate' | 'none'Default: undefined | How crowded category-axis labels are decluttered. Default 'auto' thins labels horizontally. |
| xLabelRotation | numberDefault: undefined | Explicit category-label rotation in degrees (respected as a floor). |
CartesianCrosshairInputDefault: undefined | Crosshair that follows the cursor across the plot. `true`/`'auto'` enables a snapping line; pass an object to set mode/snap/color/dash. | |
| 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. |
booleanDefault: true | Whether to show a legend for series or items. | |
| legendPosition | DumbbellChartLegendPositionDefault: 'top' | Where the legend is positioned. |
| 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 | DumbbellChartEasingDefault: 'ease-out' | Allowed values: linear, ease-out, ease-in, ease-in-out. Default: 'ease-out'. |
| animationType | DumbbellChartAnimationTypeDefault: undefined | Allowed values: initial, update. Default: undefined. |
Other properties 12
| Attribute / Property | Type / Default | Description |
|---|---|---|
ReadonlyArray<string>Default: undefined | Optional category-label override. When set, replaces the per-datum `category` labels. | |
| lineColor | stringDefault: '#cbd5e1' | Connector (bar) stroke colour — its own faint default, independent of the `color` pair. |
DumbbellMarkerSymbol | string | ReadonlyArray<string>Default: 'circle' | Marker glyph. Polymorphic (like `color`): a single symbol applies to BOTH ends; an array or comma-string is read as `[lowMarker, highMarker]` (a single token leaves the low end on `'circle'` and applies the token to the high end, mirroring the pair rule). Resolved once via `resolvePair`. Per-datum `DumbbellDatum.lowMarker`/`highMarker` override this for individual dumbbells. | |
| xLabelMaxCount | numberDefault: undefined | Hard cap on the number of category labels shown. |
| tooltipFormat | (detail: DumbbellChartPointerEventDetail) => stringDefault: undefined | Pass as a JavaScript property. type: (detail: DumbbellChartPointerEventDetail) => string. |
| enableMouseTracking | booleanDefault: true | Set as an HTML attribute or JavaScript property. type: boolean. |
| streamSource | DumbbellChartStreamSourceDefault: 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. |
DumbbellChartEngineModeDefault: '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. |
DumbbellChartUnavailableBehaviourDefault: 'fallback' | Allowed values: fallback, error, throw. Default: 'fallback'. |
Events 16
| Events | Detail type | Description |
|---|---|---|
DumbbellChartRenderResult & { tier: DumbbellChartEngineTier } | Emits rendering results in detail when chart drawing completes. | |
DumbbellChartPointerEventDetail | A point selection event. Read the selected data and index from CustomEvent.detail. | |
DumbbellChartPointerEventDetail | null | CustomEvent.detail type: DumbbellChartPointerEventDetail | null. Event names are case-sensitive. | |
CartesianCrosshairEventDetail | null | CustomEvent.detail type: CartesianCrosshairEventDetail | null. Event names are case-sensitive. | |
ChartPointContextMenuEventDetail<DumbbellChartPointerEventDetail> | CustomEvent.detail type: ChartPointContextMenuEventDetail<DumbbellChartPointerEventDetail>. 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. | |
DumbbellChartLegendItemEventDetail | CustomEvent.detail type: DumbbellChartLegendItemEventDetail. Event names are case-sensitive. | |
DumbbellChartSeriesToggledEventDetail | CustomEvent.detail type: DumbbellChartSeriesToggledEventDetail. Event names are case-sensitive. |
Methods 18
Stencil methods return Promises. Use await within an async function to read the result.
| Method / Arguments | Return type | Description |
|---|---|---|
Promise<DumbbellChartRenderResult> | An asynchronous method. Check the argument and return types below. | |
Promise<DumbbellChartEngineTier> | An asynchronous method. Check the argument and return types below. | |
| data: ReadonlyArray<DumbbellDatum> | Promise<void> | An asynchronous method. Check the argument and return types below. |
| datum: DumbbellDatum | Promise<void> | An asynchronous method. Check the argument and return types below. |
| data: ReadonlyArray<DumbbellPairDatum> | 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. |
| data: ReadonlyArray<DumbbellPairDatum> | Promise<void> | An asynchronous method. Check the argument and return types below. |
Promise<DumbbellChartStreamSource | undefined> | An asynchronous method. Check the argument and return types below. | |
| idOrIndex: string | number, opts?: { redraw?: boolean } | Promise<boolean> | An asynchronous method. Check the argument and return types below. |
| idOrIndex: string | number, opts?: { redraw?: boolean } | Promise<boolean> | An asynchronous method. Check the argument and return types below. |
| options: { duration?: number; easing?: DumbbellChartEasing; enabled?: boolean; type?: DumbbellChartAnimationType } | 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<DumbbellChartPointerEventDetail | null> | An asynchronous method. Check the argument and return types below. |
| index: 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. | |
Promise<ChartEngineStatus> | 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. |
No matching APIs.