Navigator.
COMMUNITYSelect a range over a condensed view of the full dataset.
LIVE EXAMPLE
Overview and zoom
Appearance and style6
Title and dimensions1
Choose the visible range over a summarized dataset. 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-line-chart.js';
import { defineCustomElement as define1 } from '@syidax/advanced/components/sy-navigator.js';
define0();
define1();
const specs = [
{
"tag": "sy-line-chart",
"id": "chart-target",
"props": {
"engine": "standard",
"series": [
{
"name": "Organic",
"color": "#8263d9",
"values": [24, 29, 27, 38, 43, 40, 52, 58, 53, 68, 76, 84]
},
{
"name": "Direct",
"color": "#239c91",
"values": [15, 19, 17, 24, 22, 29, 32, 30, 39, 42, 40, 51]
},
{
"name": "Referral",
"color": "#e99954",
"values": [8, 11, 9, 15, 13, 19, 17, 23, 22, 28, 25, 33]
}
],
"xAxis": {
"kind": "category",
"categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
},
"yAxis": {
"kind": "linear",
"min": 0
},
"zoom": {
"enabled": true
},
"height": 280,
"width": 640
}
},
{
"id": "example-chart",
"tag": "sy-navigator",
"props": {
"for": "chart-target",
"sampling": "minmax",
"width": 640,
"height": 64
}
}
];
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', 'navigator example chart');
return element;
});
container.replaceChildren(...elements);
const chart = elements.at(-1);
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();
container.replaceChildren();
}
</script>Usage and data
#Provide a zoomed view alongside its full context.
Navigator's for points to a target chart in the same document. Distinguish sampled previews from raw data.
Data contract
| Property | Input format |
|---|---|
for | The target chart's ID. |
sampling | Reduce data with minmax or lttb. |
series | The series used in the preview. |
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 2 interactive feature examples and inspect their code. Select “Edit in preview” to combine more options in the settings panel above.
Range update API
Show April through September, then return to the full range.
View code
Mini chart
Compare 4 examples of Mini chart. 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.
Connect helper components to their target chart and shared data as shown in the example.
API reference
#The full public API for sy-navigator. Pass objects and arrays as JavaScript properties. Select a name to view usage code and type definitions.
Key properties
| Attribute / Property | Type / Default | Description |
|---|---|---|
stringDefault: undefined | The target chart's ID. | |
DataZoomOrientationDefault: 'horizontal' | 'horizontal' drives the x window (preview along x), 'vertical' the y window (preview along y). | |
numberDefault: 640 | Chart width in pixels. Update with ResizeObserver when the container changes. | |
numberDefault: 60 | Chart height in pixels. | |
| minRangePx | numberDefault: 8 | The narrowest window, in track pixels (default 8). |
| stepFraction | numberDefault: 0.1 | Fraction of the window one arrow key moves (default 0.1). |
| showLabels | booleanDefault: true | Show the window's min / max next to the handles while zoomed. |
booleanDefault: false | Set as an HTML attribute or JavaScript property. type: boolean. | |
number | stringDefault: undefined | The series used in the preview. | |
NavigatorSamplingDefault: 'minmax' | Reduce data with minmax or lttb. |
Other properties 2
| Attribute / Property | Type / Default | Description |
|---|---|---|
NavigatorTargetElement | nullDefault: undefined | The chart element to drive (the script-set alternative to `for`). | |
CartesianAxisIdDefault: undefined | Which axis of the target (id or slot index); default: the primary axis of the orientation. |
Methods 4
Stencil methods return Promises. Use await within an async function to read the result.
| Method / Arguments | Return type | Description |
|---|---|---|
Promise<void> | Re-read the chart's extent, data and window (also done on the chart's `rendered`). | |
| window: CartesianZoomWindow | readonly [number, number] | null | Promise<CartesianZoomWindow | null> | Set the window from script (`null` = the full extent) through the inner slider. |
Promise<CartesianZoomWindow | null> | An asynchronous method. Check the argument and return types below. | |
Promise<ZoomExtent | null> | An asynchronous method. Check the argument and return types below. |
No matching APIs.
Range changes are emitted through the internal Data Zoom's rangeChange event.