Navigator.

COMMUNITY

Select a range over a condensed view of the full dataset.

Live preview2 feature examples

LIVE EXAMPLE

Overview and zoom

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 style6
Title and dimensions1

Choose the visible range over a summarized dataset. 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-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

PropertyInput format
forThe target chart's ID.
samplingReduce data with minmax or lttb.
seriesThe 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.

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 / PropertyType / DefaultDescription
stringDefault: undefinedThe target chart's ID.
DataZoomOrientationDefault: 'horizontal''horizontal' drives the x window (preview along x), 'vertical' the y window (preview along y).
numberDefault: 640Chart width in pixels. Update with ResizeObserver when the container changes.
numberDefault: 60Chart height in pixels.
minRangePxnumberDefault: 8The narrowest window, in track pixels (default 8).
stepFractionnumberDefault: 0.1Fraction of the window one arrow key moves (default 0.1).
showLabelsbooleanDefault: trueShow the window's min / max next to the handles while zoomed.
booleanDefault: falseSet as an HTML attribute or JavaScript property. type: boolean.
number | stringDefault: undefinedThe series used in the preview.
NavigatorSamplingDefault: 'minmax'Reduce data with minmax or lttb.
Other properties 2
Attribute / PropertyType / DefaultDescription
NavigatorTargetElement | nullDefault: undefinedThe chart element to drive (the script-set alternative to `for`).
CartesianAxisIdDefault: undefinedWhich 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 / ArgumentsReturn typeDescription
Promise<void>Re-read the chart's extent, data and window (also done on the chart's `rendered`).
window: CartesianZoomWindow | readonly [number, number] | nullPromise<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.

Range changes are emitted through the internal Data Zoom's rangeChange event.