Skip to content
OpenChart

Publish-ready charts, maps and tables from JSON.

OpenChart draws the headline, source line, annotations, legend and a responsive layout for you, in your house style and with animation. It runs in React, Vue, Svelte or plain JavaScript.

OpenChart draws the headline, source line, annotations and responsive layout for you, in React, Vue, Svelte or plain JavaScript.

Show the same data in four forms

  • Line
  • Small multiples
  • Stacked area
  • Data table
Focus
  • All
  • Coal
  • Gas
  • Nuclear
  • Wind
  • Solar
  • Hydro
201620172018201920202021202220230%10%20%30%40%50%Share of six-source mixDown 15 ptsin seven yearsGasNuclearWindSolarCoalCoal's share of US electricity halved from 31.2% in 2016 to16.2% in 2023Share of US electricity from six main sources, 2016–2023 (%)201620172018201920202021202220230%10%20%30%40%50%Share of six-source mixDown 15 ptsin seven yearsGasNuclearWindSolarCoalCoal's share of US electricity halved from 31.2% in 2016 to16.2% in 2023Share of US electricity from six main sources, 2016–2023 (%)
View the spec
Spec: Line · Coal
{"mark": {"type": "line","strokeWidth": 2},"data": [ … 48 rows ],"chrome": {"title": "Coal's share of US electricity halved from 31.2% in 2016 to 16.2% in 2023","subtitle": "Share of US electricity from six main sources, 2016–2023 (%)"},"encoding": {"x": {"field": "year","type": "temporal","axis": { "format": "%Y" }},"y": {"field": "share","type": "quantitative","scale": {"domain": [0, 50]},"axis": { "title": "Share of six-source mix", "format": ".0f", "labelSuffix": "%", "grid": true }},"color": {"field": "source","type": "nominal","scale": {"domain": ["Gas", "Nuclear", "Coal", "Wind", "Solar", "Hydro"]},"highlight": ["Coal"]}},"endpointLabels": {"content": "label"},"annotations": [{"type": "text","x": "2023","y": 16.2,"text": "Down **15 pts**\nin seven years","connector": true,"offset": { "dx": -76, "dy": -54 }}]}
US electricity generation by fuel, 2016–2023. Switch views or highlight a fuel, and open the spec below to see the JSON. Source: Our World in Data (owid/electricity-mix).
npm install @opendata-ai/openchart-react

bun add @opendata-ai/openchart-react

pnpm add @opendata-ai/openchart-react

Drag a callout to reposition it

Drag the callout on this chart to a new spot. The spec line next to the chart shows the offset the drag writes.

20202022202402468Inflation (%)Peak of 8.5%in summer 2022Fed's 2% targetUS inflation is most ofthe way back downConsumer prices, change from a year earlier,quarterly, 2019 to 2024 (%)20202022202402468Inflation (%)Peak of 8.5%in summer 2022Fed's 2% targetUS inflation is most ofthe way back downConsumer prices, change from a year earlier,quarterly, 2019 to 2024 (%)
20192020202120222023202402468Inflation (%)Peak of 8.5%in summer 2022Fed's 2% targetUS inflation is most of the way back downConsumer prices, change from a year earlier, quarterly, 2019 to 2024 (%)20192020202120222023202402468Inflation (%)Peak of 8.5%in summer 2022Fed's 2% targetUS inflation is most of the way back downConsumer prices, change from a year earlier, quarterly, 2019 to 2024 (%)
20202022202402468Inflation (%)Peak of 8.5%in summer 2022Fed's 2% targetUS inflation is most of the way backdownConsumer prices, change from a year earlier, quarterly, 2019 to 2024 (%)20202022202402468Inflation (%)Peak of 8.5%in summer 2022Fed's 2% targetUS inflation is most of the way backdownConsumer prices, change from a year earlier, quarterly, 2019 to 2024 (%)
20192020202120222023202402468Inflation (%)Peak of 8.5%in summer 2022Fed's 2% targetUS inflation is most of the way back downConsumer prices, change from a year earlier, quarterly, 2019 to 2024 (%)20192020202120222023202402468Inflation (%)Peak of 8.5%in summer 2022Fed's 2% targetUS inflation is most of the way back downConsumer prices, change from a year earlier, quarterly, 2019 to 2024 (%)

What the spec says

"annotations": [{"type": "text","text": "Peak of 8.5%\nin summer 2022","x": "2022-07-01","y": 8.5,…"offset": { "dx": 112, "dy": 8 }},…]

Drag the callout, or tab to the chart and move it with the arrow keys. Only the callout moves; the rest of the chart stays as written.

The live chart needs JavaScript, so this is a still.

Source: US Bureau of Labor Statistics, CPI-U (via FRED CPIAUCSL).

Update the chart as the reader scrolls

Each paragraph changes the chart as it scrolls into view. One shades 2022, one adds the other indexes, one labels the Nasdaq's 2022 loss and one highlights the index that recovered most. The library animates each change.

20222024−40−20+0+20+40+60Total return since Jan 2022 (%)2022Nasdaq, end of 2022: −33%S&P 500NASDAQDow JonesRussell 2000Four US stock indexes fellin 2022 and were allhigher by late 2025Cumulative total return since January 2022,quarterly, %20222024−40−20+0+20+40+60Total return since Jan 2022 (%)2022Nasdaq, end of 2022: −33%S&P 500NASDAQDow JonesRussell 2000Four US stock indexes fellin 2022 and were allhigher by late 2025Cumulative total return since January 2022,quarterly, %
2022202320242025−40−20+0+20+40+60Total return since Jan 2022 (%)2022Nasdaq, end of 2022: −33%S&P 500+46Dow Jones+43Russell 2000+22NASDAQ+65Four US stock indexes fell in 2022 and were all higherby late 2025Cumulative total return since January 2022, quarterly, %2022202320242025−40−20+0+20+40+60Total return since Jan 2022 (%)2022Nasdaq, end of 2022: −33%S&P 500+46Dow Jones+43Russell 2000+22NASDAQ+65Four US stock indexes fell in 2022 and were all higherby late 2025Cumulative total return since January 2022, quarterly, %
  1. Four indexes follow different parts of the US stock market: the 500 largest companies, the technology-heavy Nasdaq, the 30 stocks of the Dow Jones and the 2,000 smaller companies of the Russell 2000. The chart starts with the S&P 500, measured from January 2022 with dividends reinvested.

  2. Over 2022 the S&P 500 lost 18% of its value. In 2023 it gained 26%, enough to finish the year above where it started.

    In the spec, this step adds a shaded range for 2022.

  3. The other three fell in 2022 too, by different amounts. The Dow Jones lost 7% over the year, the Russell 2000 lost 21%.

    In the spec, this step adds the NASDAQ, Dow Jones and Russell 2000 lines.

  4. The Nasdaq fell furthest, losing a third of its value in 2022. Even after a strong 2023 it finished that year below where it started.

    In the spec, this step adds a callout, “Nasdaq, end of 2022: −33%”.

  5. It also climbed furthest. By October 2025 the Nasdaq was up 65% on January 2022, against 46% for the S&P 500, 43% for the Dow and 22% for the Russell 2000.

    In the spec, this step highlights NASDAQ and dims the rest.

Returns are rebased to 1 January 2022 and include reinvested dividends. Source: S&P Dow Jones Indices, Nasdaq, FTSE Russell.

Animate the chart when the data changes

The first chart plays GDP per person against life expectancy from 1960 to 2022 in 16 seconds. Pause it or drag to any year. In the second, Next month adds a bar and the other bars animate to their new widths.

$100$10,000GDP per capita (current US$)1020304050607080Life expectancy (years)Asia & PacificAfricaAmericasEuropeChina and India gothealthier long beforethey got richGDP per capita and life expectancy, every otheryear from 1960 to 2022. Circle size = population.$100$10,000GDP per capita (current US$)1020304050607080Life expectancy (years)Asia & PacificAfricaAmericasEuropeChina and India gothealthier long beforethey got richGDP per capita and life expectancy, every otheryear from 1960 to 2022. Circle size = population.
$100$10,000GDP per capita (current US$)1020304050607080Life expectancy (years)Asia & PacificAfricaAmericasEuropeChina and India got healthier longbefore they got richGDP per capita and life expectancy, every other year from 1960 to 2022.Circle size = population.$100$10,000GDP per capita (current US$)1020304050607080Life expectancy (years)Asia & PacificAfricaAmericasEuropeChina and India got healthier longbefore they got richGDP per capita and life expectancy, every other year from 1960 to 2022.Circle size = population.
$10$100$1,000$10,000$100,000GDP per capita (current US$)1020304050607080Life expectancy (years)Asia & PacificAfricaAmericasEuropeChina and India got healthier long before they got richGDP per capita and life expectancy, every other year from 1960 to 2022. Circle size = population.$10$100$1,000$10,000$100,000GDP per capita (current US$)1020304050607080Life expectancy (years)Asia & PacificAfricaAmericasEuropeChina and India got healthier long before they got richGDP per capita and life expectancy, every other year from 1960 to 2022. Circle size = population.

The live chart needs JavaScript, so this is a still.

Source: World Bank, World Development Indicators.

Add a month to see the update animation

Animation

Showing January to June

JanFebMarAprMayJun050100150200250300350400Jobs added (thousands)353275303175272206US employers added jobs in every month of 2024Change in nonfarm payrolls, thousands, January to JuneJanFebMarAprMayJun050100150200250300350400Jobs added (thousands)353275303175272206US employers added jobs in every month of 2024Change in nonfarm payrolls, thousands, January to June

The library follows the reader's reduced-motion setting. With it on, these controls still change the chart, and nothing animates.

View the spec
{
  "mark": "bar",
  "data": [ … 6 rows ],
  "encoding": { … },
  "chrome": { … },
  "animation": "fluid"
}
Source: Bureau of Labor Statistics.

Use a built-in theme or define your own

This chart runs through the four built-in themes and dark mode. For your own house style, write a theme with your fonts and colors, or change a few values in a built-in one, and apply it to one chart or to every chart on the page.

Essay

Serif type on a warm background, with generous spacing around the chart.

What changed in the theme
  1. fonts.family "Inter Variable"becomes "Source Serif 4"
  2. colors.background "transparent"becomes "#faf8f5"
  3. colors.text "#09090b"becomes "#1c1917"
  4. colors.axis "#71717a"becomes "#78716c"
  5. fonts.sizes.title 26becomes 28
2018202020222024−5+0+5Real GDP growth (%)United States+2.8Euro Area+0.8China+5.0WORLD ECONOMYThe euro area grew under 1% in2023 and 2024, the US near 3%Annual real GDP growth, 2018-2024

The text above the plot is part of the chart, so each theme sets it in its own type. Source: IMF World Economic Outlook, World Bank.

Resize the chart from phone to full width

Drag the frame's right edge to change the chart's width. As it narrows, the axis shows fewer year labels. At phone width one callout stays on the line and the other becomes a numbered note under the chart.

20192020202120222023202402468Year-over-year change (%)Peak: 8.5% in mid-2022Low: 0.3% in spring 2020Fed 2% targetInflation ran above 4% for two years before it easedUS consumer prices, change from a year earlier, quarterly; shaded above 4%20192020202120222023202402468Year-over-year change (%)Peak: 8.5% in mid-2022Low: 0.3% in spring 2020Fed 2% targetInflation ran above 4% for two years before it easedUS consumer prices, change from a year earlier, quarterly; shaded above 4%

The live chart needs JavaScript, so this is a still.

Source: US Bureau of Labor Statistics, CPI-U (via FRED CPIAUCSL).

Export the chart and its screen-reader text

The spec that draws this chart also exports it as SVG, PNG, CSV or an animated GIF, and generates the alt text and data table a screen reader reads.

Wind and solar farms produced 15.9% of US generation from the six main sources in 2023, almost level with coal at 16.2%, according to Our World in Data. In 2016 coal's share was more than four times theirs.

2016202020221015202530Share of generation (%)Coal rose in 2021as gas prices climbedCoal16.2Wind and solar15.9Wind and solar nearlycaught coal in US powerCoal and wind plus solar, share of generation fromthe six main sources (%)2016202020221015202530Share of generation (%)Coal rose in 2021as gas prices climbedCoal16.2Wind and solar15.9Wind and solar nearlycaught coal in US powerCoal and wind plus solar, share of generation fromthe six main sources (%)
20162018202020221015202530Share of generation (%)Coal rose in 2021as gas prices climbedCoal16.2Wind and solar15.9Wind and solar nearly caught coal in USpowerCoal and wind plus solar, share of generation from the six main sources (%)20162018202020221015202530Share of generation (%)Coal rose in 2021as gas prices climbedCoal16.2Wind and solar15.9Wind and solar nearly caught coal in USpowerCoal and wind plus solar, share of generation from the six main sources (%)

In the page source this chart is static SVG, so it shows and prints without JavaScript. Source: Our World in Data (owid/electricity-mix).

Coal's decline was steady rather than sudden. Its share fell in every year but 2021, when high gas prices briefly brought coal plants back, while wind and solar added more than a percentage point a year on average.

Browse the chart types by purpose

The charts are grouped by what they show, such as a comparison or change over time. Pick a purpose to filter them, or click a chart to open its docs page. Below the list are full-size maps and a sankey diagram.

  • ComparisonColumn
  • Grouped columns
  • Bar list
  • Dumbbell
  • Change over timeLine
  • Stacked area
  • Area
  • Part to wholeDonut
  • Waffle
  • Parliament
  • DistributionHistogram
  • Beeswarm
  • Density
  • CorrelationScatter
  • Trend line
  • Heatmap
  • Flow and networksSankey
  • Network
  • MapsChoropleth
  • Symbol map
  • TablesData table
  • Sparkline column
  • CompositionBars and a rule
  • Dual axis

Use a coding agent to write specs

In this scripted session a reporter asks an agent for a chart. The validator rejects one field in the agent's spec and lists the data's columns, and the agent fixes the field. Every validator message shown is the library's real output.

JanFebMarAprMayJunJulAugSepOctNovDec0100200300400Jobs added (thousands)Hurricanes and strikesheld October to 12,00035327530317527220611414225412227256Hiring slowed after June2024 and stalled inOctoberJanFebMarAprMayJunJulAugSepOctNovDec0100200300400Jobs added (thousands)Hurricanes and strikesheld October to 12,00035327530317527220611414225412227256Hiring slowed after June2024 and stalled inOctober
JanFebMarAprMayJunJulAugSepOctNovDec050100150200250300350400Jobs added (thousands)Hurricanes and strikesheld October to 12,00035327530317527220611414225412227256Hiring slowed after June 2024 and stalled inOctoberJobs added to US nonfarm payrolls each month, thousandsJanFebMarAprMayJunJulAugSepOctNovDec050100150200250300350400Jobs added (thousands)Hurricanes and strikesheld October to 12,00035327530317527220611414225412227256Hiring slowed after June 2024 and stalled inOctoberJobs added to US nonfarm payrolls each month, thousands
The chart the corrected spec renders. Source: Bureau of Labor Statistics.
  1. Reporter

    Filing the jobs story at 4. I need a column chart of 2024 monthly payroll gains from the BLS numbers in payrolls-2024.json, with October flagged.

  2. fetch

    https://openchart.steamfield.io/llms.txt130 lines

    Show the first lines

    # OpenChart

    > Charts, tables and maps from a JSON spec.

    … 128 more lines

  3. write

    payrolls-2024.chart.json

    Show the spec
    {
      "mark": "bar",
      "data": [ … 12 rows ],
      "encoding": {
        "x": { "field": "month", "type": "ordinal" },
        "y": {
          "field": "payrolls",
          "type": "quantitative",
          "axis": { "title": "Jobs added (thousands)" }
        }
      },
      "annotations": [
        {
          "type": "text",
          "x": "Oct",
          "y": 12,
          "text": "Hurricanes and strikes\nheld October to 12,000",
          "anchor": "top",
          "offset": { "dy": -235 },
          "connector": true
        }
      ],
      "chrome": {
        "title": "Hiring slowed after June 2024 and stalled in October",
        "subtitle": "Jobs added to US nonfarm payrolls each month, thousands"
      }
    }
  4. validateSpecrejected

    payrolls-2024.chart.json1 error

    Spec error: encoding.y.field "payrolls" does not exist in data. Available columns: month, jobs

  5. edit

    payrolls-2024.chart.json

    "field": "payrolls","field": "jobs",

  6. validateSpec

    payrolls-2024.chart.json

    valid, 0 errors

  7. render

    <Chart spec={spec} />

llms.txt

Every docs page as Markdown, listed by section with its URL.

/llms.txt
JSON Schema

The whole spec grammar, for editor completion and structured output.

@opendata-ai/openchart-core/schema
Claude Code skill

Teaches Claude the spec grammar, the encoding rules and chart design conventions.

/plugin marketplace add tryopendata/skills
/plugin install openchart@openchart

Install it for React, Vue, Svelte or plain JavaScript

Install the package for your framework and pass it a spec. The code below draws the chart next to it. Every example in the docs shows this code for all four frameworks.

npm install @opendata-ai/openchart-react
SolarChart.tsx
import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const spec: ChartSpec = {
  "mark": "bar",
  "data": [/* 5 rows, as in the Spec tab; Copy includes them */],
  "encoding": {
    "x": {
      "field": "year",
      "type": "ordinal"
    },
    "y": {
      "field": "capacity",
      "type": "quantitative",
      "axis": {
        "title": "Gigawatts added"
      }
    }
  },
  "chrome": {
    "title": "Solar additions more than tripled from 2019 to 2023",
    "subtitle": "New solar generating capacity worldwide, gigawatts per year"
  }
};

export function Example() {
  return <Chart spec={spec} />;
}
npm install @opendata-ai/openchart-vue
SolarChart.vue
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const spec: ChartSpec = {
  "mark": "bar",
  "data": [/* 5 rows, as in the Spec tab; Copy includes them */],
  "encoding": {
    "x": {
      "field": "year",
      "type": "ordinal"
    },
    "y": {
      "field": "capacity",
      "type": "quantitative",
      "axis": {
        "title": "Gigawatts added"
      }
    }
  },
  "chrome": {
    "title": "Solar additions more than tripled from 2019 to 2023",
    "subtitle": "New solar generating capacity worldwide, gigawatts per year"
  }
};
</script>

<template>
  <Chart :spec="spec" />
</template>
npm install @opendata-ai/openchart-svelte
SolarChart.svelte
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const spec: ChartSpec = {
  "mark": "bar",
  "data": [/* 5 rows, as in the Spec tab; Copy includes them */],
  "encoding": {
    "x": {
      "field": "year",
      "type": "ordinal"
    },
    "y": {
      "field": "capacity",
      "type": "quantitative",
      "axis": {
        "title": "Gigawatts added"
      }
    }
  },
  "chrome": {
    "title": "Solar additions more than tripled from 2019 to 2023",
    "subtitle": "New solar generating capacity worldwide, gigawatts per year"
  }
};
</script>

<Chart {spec} />
npm install @opendata-ai/openchart-vanilla
solar-chart.ts
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const spec: ChartSpec = {
  "mark": "bar",
  "data": [/* 5 rows, as in the Spec tab; Copy includes them */],
  "encoding": {
    "x": {
      "field": "year",
      "type": "ordinal"
    },
    "y": {
      "field": "capacity",
      "type": "quantitative",
      "axis": {
        "title": "Gigawatts added"
      }
    }
  },
  "chrome": {
    "title": "Solar additions more than tripled from 2019 to 2023",
    "subtitle": "New solar generating capacity worldwide, gigawatts per year"
  }
};

const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
20192020202120222023050100150200250300350Gigawatts added98127167222346Solar additions more thantripled from 2019 to 2023New solar generating capacity worldwide, gigawatts per year20192020202120222023050100150200250300350Gigawatts added98127167222346Solar additions more thantripled from 2019 to 2023New solar generating capacity worldwide, gigawatts per year
What each tab renders. Source: International Energy Agency.
OpenChart's bundle and license, each linked to the file that backs it
TopicWhat you getBacked by
BundleESM-only packages built on d3 modules. The 3D graph renderer and the GIF encoder are optional peer dependencies, installed only if you use them, and the GIF encoder loads only when a GIF is exported. Each wrapper takes its framework as a peer.packages/vanilla/package.jsonGIF export
LicenseApache-2.0, for every package.LICENSE