Documentation
Every page here is also served as Markdown, and llms.txt lists them all.
Guides
Get started
- Introduction: What OpenChart makes, shown as published graphics, and how these docs are organized.
- Getting started: Build a line chart, then add chrome, annotations, a theme and a data table.
- Frameworks: Install and use OpenChart in React, Vue, Svelte or plain JavaScript: the spec as state, updates, dark mode and themes.
- Static rendering: Render charts to SVG at build time or on the server with renderStaticSVG, for CMS pages, reports and readers without JavaScript.
- Bundle size: Import one OpenChart visualization and ship only that one: what each import costs, which imports pull in everything, and how to check your own bundle.
Working with agents
- Generating specs: Have a language model write specs: the published JSON Schema, tool use, strict modes and the validate-and-repair loop.
- Agent patterns: Spec patterns by storytelling intent, each with its data shape, a complete spec and annotations.
Recipes
- Dashboards: Small charts in product UI: tile sizing, sparkline KPI cards, trimmed chrome, bar lists and tables in a grid.
- Ranking and change: Slope, bump and range charts for who moved and by how much, as copyable recipes.
Upgrading
- Migrating to v9: Upgrade from 8.9 to 9: annotation defaults, theme composition, removed APIs and spec migration.
- Migrating to v8: Upgrade from v7 to v8: spec and import changes, and the renderer move.
Visualizations
Comparison
- Bar: Compare one value across named categories with horizontal bars, then sort, group, stack, label and highlight them.
- Column: Compare one value across ordered categories such as months or years with vertical columns, then annotate, color by sign and label them.
- Grouped and stacked bars: Split each bar or column into series, placed side by side to compare series or stacked end to end to read totals and parts.
- Lollipop: Compare values across categories with a dot on a thin stem, then plot negatives or show two values per category.
- Bar list: Show a ranked list of labelled values as compact rows with inline bars, grouped, limited and sized to fit a card or a dense layout.
- Range (dumbbell): Show the span between two values per category as a dumbbell, an arrow or a floating bar, for change between two periods or a low to high range.
- Population pyramid: Draw two groups back to back with mirrored bars, such as men and women by age, then play the pyramid through the years.
Change over time
- Line: Trace one or more series across a continuous axis, then annotate, label the line ends, focus a series, change the curve, format dates and switch to a log scale.
- Area: Fill the space under a line to show how a quantity builds over time, then add reference lines and compare overlapping series from a shared zero baseline.
- Stacked area: Show how a total divides into parts over time with stacked areas, then normalize each period to 100% or center the stack as a streamgraph.
- Slope and bump: Compare two moments with a slope chart or follow rank across many periods with a bump chart. Both are line charts with a few extra spec fields.
- Race: Play a ranking over time as bars, lines or a table, and let readers pause on any period.
- Playback controls: Time a chart that plays through periods, choose when it starts, and drive it from code with play, pause, seek and period events.
- Sparkline: Shrink a line or area to a word-sized trend with display "sparkline", which strips the title, axes, legend and watermark so it fits beside a number.
- Calendar: Lay a daily value out as a grid of weeks and weekdays, one colored cell per day, to read seasonality and streaks across a year or several.
Part to whole
- Pie and donut: Show a handful of shares of one whole with a pie or donut, then add a center label, group small slices, label with leader lines or sweep a half circle.
- Stacked 100%: Compare how several wholes divide into parts by scaling every bar or column to the same length with stack "normalize", for categories or periods.
- Waffle: Show shares of a whole as a grid of unit squares the reader can count, then highlight one category, resize the grid and bucket small categories into Other.
- Parliament: Draw legislative seats as dots in a hemicycle grouped by party, then add a multi-party chamber, hide the majority line or move it to a custom threshold.
Distribution
- Histogram: Bin one numeric field and count each bin to show where values cluster, then change the bin count, overlap groups and compare them as shares.
- Density: Smooth one numeric field into a density curve to compare the shape of groups, then change the bandwidth or switch to a cumulative curve.
- Beeswarm: Draw every observation as a dot, dodged so none overlap, then split into lanes by group, turn the swarm vertical and size dots by a second field.
- Tick strip: Draw one short tick per observation along a shared axis to show the spread of values in each group, then color the strips and add a reference line.
- Error bars: Draw an interval between two supplied bounds, vertical or horizontal, with optional end caps, and layer a point to mark an estimate inside it.
Correlation
- Scatter: Plot two numeric fields against each other to find correlation, clusters and outliers, then add color, direct labels, a reference line and a log axis.
- Bubble: Add a third number to a scatter as dot size, then color the bubbles by group and annotate the ones that matter with callouts and a reference line.
- Bubble playback: Play a bubble chart year by year, Gapminder style, with fixed axes, named countries, trails and a large period label behind the bubbles.
- Heatmap: Color a grid of two categories by a number to read patterns across rows and columns, then change the color scheme, pin the color domain and order the rows.
- Trendlines: A scatter fits one least-squares line through its points by default. Turn it off, restyle it, draw it over a dense cloud and see how it treats color groups.
Flow and networks
Maps
- Choropleth: Color regions on a map by a value, from US states to world countries, with classed scales, projections and no-data fills.
- Symbol map: Place sized and colored circles on a map by longitude and latitude, alone on a basemap or over a choropleth.
- Tile map: Give every US state one equal tile in a grid that keeps the country's rough shape, colored by a number or a category.
- Geographic labels: Name the regions and points on a map from data, and anchor authored callouts to features that hold as readers zoom.
- Time-lapse map: Play a choropleth, tile map or symbol layer through periods, with one color scale and legend held for the whole run.
Tables
- Data table: Show rows and columns as an interactive table with formats, sorting, search, paging, row density and a total row, from a declarative spec.
- Column types: Turn table columns into heatmaps, inline bars, sparklines, delta chips, images and category chips with one config field per column.
- Row inspection: Read across one row at a time, with the rowHover option on horizontal bar charts and search, sort, totals and row clicks on tables.
Composition
- Layers: Draw several marks on one plot with a layer array, such as bars with a reference rule, labelled points, or two series on independent axes.
- Facets and small multiples: Repeat one chart as a grid of panels, one per category, with shared or independent scales and wrapped, row or column layouts.
- Dashboard tiles: Compact chart forms for dense layouts, from sparklines and short charts to metric rows, bar lists and condensed tables, as single specs.
Building blocks
The spec
- Anatomy of a spec: One published chart taken apart: data, mark, encoding, chrome and annotations, and what each block adds.
- Encoding channels: Map fields to x, y, color and size, and see the same data read differently as the channels change.
- Field types and scales: Nominal, ordinal, quantitative and temporal fields, and the scale settings for domain, zero, log and color ramps.
- Axes: Tick formats, tick counts, gridlines, axis titles and long labels, set on the encoding channel.
- Transforms: Filter, aggregate, bin, fold, calculate and window data inside the spec, so published numbers trace back to source rows.
Framing
- Title, subtitle and source: The text around a chart: a headline that states the finding, a subtitle with measure and unit, the source and byline.
- Annotations: Text callouts with connectors, reference lines and shaded ranges, placed in data coordinates to point at the story.
- Labels and legends: Value labels, their density and format, and when a legend earns its place over labelling marks directly.
- Endpoint labels: Name each line at its end with its series and last value, so readers never match colors to a legend.
Style
- Theming and tokens: ThemeConfig colors, fonts, spacing and rules for every chart, and the CSS tokens a page can set instead.
- Presets: Four house styles, essay, wire, broadsheet and terminal, applied to the same chart with one theme field.
- Dark mode: How charts switch to dark: the darkMode setting, light and dark color pairs, and preset dark palettes.
- Color palettes: Categorical, sequential and diverging color, highlighting one series, and colors that survive print and color blindness.
Behavior
- Motion: Entrance and data-update transitions, the fluid and subtle presets, turning motion off, and what reduced motion does.
- Responsive: How a chart re-lays out from phone to desktop: the compact, medium and full breakpoints and the responsive settings.
- Interaction and events: Tooltips, crosshairs, legend toggles and selection, and the events a chart emits as a reader uses it.
- Edit mode: Let a reader drag annotations and edit text in place, and apply each edit transaction to the spec.
- Scrollytelling: Step a chart through states as the reader scrolls with createChartStory, each step a spec change.
- You draw it: Ask readers to draw their guess for the hidden part of a line, then reveal the real data.
Output
- Accessibility: What every chart does for screen readers and keyboards, the options you add, and the WCAG 2.1 mapping.
- Export: Download a chart as SVG, PNG or CSV in the browser, and where static rendering takes over.
- Canvas mode: Draw thousands of points on a canvas layer while axes and text stay SVG, and when the library switches by itself.
Reference
Spec
- Spec reference: The VizSpec union, the spec builder functions, and a one-line index of every reference page.
- ChartSpec: Every top-level ChartSpec field and the mark properties, plus the A11yConfig and FrameConfig objects.
- LayerSpec: LayerSpec fields for overlaying several marks on shared scales, and what each layer inherits.
- Encoding: Encoding channels, field types, aggregates, axis and scale settings, and faceting into small multiples.
- Marks: The channels each mark type takes, complete spec examples for common charts, and canvas mark mode.
- Chrome, labels and legends: Title, subtitle, source, byline and footer fields, plus value labels, endpoint labels and the legend.
- Transforms: The filter, bin, calculate, timeUnit, aggregate, joinaggregate, fold, window and density transforms.
- Annotations: Text, range and reference line annotations, with their position, connector and style fields.
- Animation: Animation presets, entrance and update phase settings, and data-update transitions.
- Theme: ThemeConfig fields for colors, fonts, spacing and chrome, and the DarkMode setting.
- TableSpec: TableSpec and ColumnConfig fields, the column visual types, and a complete data table example.
- GraphSpec: GraphSpec fields for network charts, plus the Graph component, its props and its interaction model.
- SankeySpec: SankeySpec fields for flow diagrams: encoding, node and link settings, and an example.
- TileMapSpec: TileMapSpec fields for US state tile grids: encoding, behavior and an example.
- GeoMapSpec: GeoMapSpec fields for choropleth and symbol maps: geography, encoding, point layers, focus and zoom.
- BarListSpec: BarListSpec fields for ranked bar lists: encoding, groups, value domains and reference lines.
- Authoring and reader APIs: Library interfaces for authoring and reader apps: numeric observations, interaction contracts and callout limits.
API
- Vanilla API: The create* mount functions, MountOptions, the ChartInstance methods, the chart and table lifecycle, and the render-state attributes.
- React: The React components, their props and handles, the hooks, and how the components behave under server rendering.
- Vue: The Vue 3 components, their props, events and exposed methods, the composables, and how the components behave under server rendering.
- Svelte: The Svelte 5 components, their callback props and exported methods, the composables, and how the components behave under server rendering.
- Events: Chart and table event handlers with their payloads and framework spellings, interaction modes, edit persistence and common patterns.
- Export API: Export charts as SVG, PNG, JPG, WebP, CSV or an animated GIF, from a chart instance, a standalone function or a framework component.
- Table state: Controlled and uncontrolled tables: sort, search and page state, and the table state hooks.
Tokens
- Theming tokens: ThemeConfig fields, named presets and the CSS custom properties a page can set to restyle charts and tables without changing a spec.
- Design system: The default palette, type scale, spacing, mark defaults, interaction language, motion timings and presets.
JSON Schema and llms.txt
- JSON Schema and llms.txt: The published JSON Schema, runtime validation with validateSpec, the llms.txt and Markdown exports, and the OpenChart skill for coding agents.