Documentation

Start here for agents

A verified entry point, observable API facts and a short workflow for building a correct VisDelta story.

Copy this complete example into index.html and serve it over HTTP.

<!doctype html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/visdelta@0.4.2/dist/visdelta.css">
<div id="chart" style="width:100%;max-width:640px;height:400px"></div>
<script type="module">
  import { bar, transition, visualizationWarnings }
    from 'https://cdn.jsdelivr.net/npm/visdelta@0.4.2/+esm';
  const rows = [
    { product: 'Hardware', revenue: 12, profit: 5 },
    { product: 'Software', revenue: 18, profit: 11 },
    { product: 'Services', revenue: 9, profit: 7 },
  ];
  const from = bar(rows).x('product').y('revenue').key('product');
  const to = from.y('profit');
  console.log(await visualizationWarnings(to));
  const change = await transition(from, to, {
    target: '#chart', width: 'auto', height: 400,
  });
  // A complete, synchronous endpoint. play() returns a controller, not a Promise.
  change.progress(1);
</script>

For a scrolling story, copy the single-file template and follow its scroll and iframe contract. It contains inline fictional data, real chart states and controls. Serve the file over HTTP; no bundler or data service is required.

Before drawing

  1. Supply tidy rows and check the fields and types you will bind.
  2. Choose stable source-record identity separately from mark identity. A line with several series commonly uses .key(['date', 'series']).
  3. Decide whether dates are local calendar dates or absolute instants. ISO date-only strings are parsed by JavaScript as UTC instants; the current temporal axis uses local time. Neither “always local midnight” nor “always UTC” is a safe universal conversion rule.
  4. Declare position domains when a story requires fixed comparison scales. Leave them inferred when the axis should fit visible data. Read the chart-specific domain rules.

Query what exists today

import { delta, visualizationWarnings } from 'visdelta';

const declared = state.toSpec();        // declaration, not final pixel geometry
const visibleRows = state.rows();       // transformed inline rows
const changes = delta(from, to).stateChanges;
const warnings = await visualizationWarnings(state);

These are useful for inline data. Warning inspection can also receive named rows, but does not fetch remote sources. Rendering can load a declared URL; await controller creation before using the resolved endpoint declarations.

const change = await transition(from, to, { target: '#chart' });
console.log(change.from, change.to, change.delta.stateChanges);
console.log(change.stageCount(), change.stageOperations());
console.log(await change.inspect());
change.progress(1);

inspect() reports compiled SVG tracks, phase boundaries and property endpoint values. Custom tween internals, immediate writes, node lifecycle changes and External page markup is outside its coverage. It does not return a list of marks or prove that a line is visible. state.resolve(), inspect(t), global strict/debug configuration and bindScroll() are not implemented APIs.

Verify behavior, then appearance

  • Check the exact start/end states against independent static charts at the same size, margins and theme. An SVG node alone is insufficient: check actual bar dimensions and line drawing state.
  • Check forward/reverse playback and seeking. To sample a phase, use its compiled interval from inspect(), rather than equating semantic changes with rendered phases. Unit's opt-in directionalEase() has its documented directional exception.
  • Check narrow and desktop layouts, resize, theme refresh and reduced motion.
  • Check that filtering keeps colors and legend categories stable where the chart contract requires it, and that empty selections can be restored.
  • Use screenshots for the final visual review, after the numerical assertions.

The repository runs the distribution and template browser checks with npm run browser:check. The single-file templates are copied unchanged into the built documentation site and tested through their real controls.

Avoid plausible but unsupported fixes

Do not invent scale.nice, axis.endpointTicks, utc, domain: 'filtered', story.ready or a play() completion Promise. Check the automatic behavior table before adding an option. Do not assume every combination of data, grain and scale edits has a planned route; the chart contracts define the supported subsets and fallback boundaries.

Persistent-view tool loop

  1. Read the current snapshot() and available data fields. Reuse current context instead of repeating observations. Pin documentation to the installed package version and matching repository revision; copied snippets can drift. The checked-in examples may include unreleased changes.
  2. Consult the JSON guide for a complete declaration. A docs lookup does not finish a requested mutation. parseSpec checks structure; chart-owned runtime validation checks the destination with resolved data.
  3. Apply one complete destination through update, or replace across types. Query view.capabilities() before fluent edit; it requires a fresh base revision and request ID. Do not infer capabilities from inherited builder method names.
  4. Await the result. Only status: 'applied' confirms playback completion; superseded and destroyed do not. Check the current revision before reporting a receipt; other requests may have advanced accepted intent. Wait for the application's latest pending work before inspectMarks() when needed.

On rejection, retain the previous chart and use the specific error to correct the declaration. Do not retry identical invalid arguments. A snapshot describes accepted intent; a later route failure can leave an older chart visible. Capture only for visual inspection, not automatically after each tool call. App-specific source restrictions, model quotas, voice, transport and conversation history belong to the application. Core accepts inline rows, named bindings and URLs.

Read visdelta/docs/index.json and its listed documents from the installed package for version-matched authoring context. Before cross-type replacement, diffViewStates(before, candidate).hasDelta('highlight', 'remove') can detect lost attention; delta itself is same-type only. An applied receipt does not prove intent preservation. Removing a scope, selecting no marks and selecting all marks remain distinct; follow the clearing example.

On this page