Presets
Four house styles, essay, wire, broadsheet and terminal, applied to the same chart with one theme field.
A preset is a finished ThemeConfig that ships with the library. The four charts on this page share one spec and differ only in the preset passed to theme. This one is essay.
{
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"data": [
{
"date": "2021-01-01",
"rate": 1.4
},
{
"date": "2021-04-01",
"rate": 4.2
},
{
"date": "2021-07-01",
"rate": 5.4
},
{
"date": "2021-10-01",
"rate": 6.2
},
{
"date": "2022-01-01",
"rate": 7.5
},
{
"date": "2022-04-01",
"rate": 8.3
},
// … 10 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"background": {
"light": "#faf8f5",
"dark": "#1a1816"
},
"text": {
"light": "#1c1917",
"dark": "#e7e5e4"
},
"gridline": {
"light": "rgba(0,0,0,0.08)",
"dark": "rgba(255,255,255,0.06)"
},
"axis": {
"light": "#78716c",
"dark": "#a8a29e"
}
},
"fonts": {
"family": "\"Source Serif 4\", \"Source Serif Pro\", Georgia, \"Times New Roman\", serif",
"sizes": {
"title": 28,
"subtitle": 15,
"body": 14,
"small": 12
},
"weights": {
"normal": 400,
"medium": 500,
"semibold": 600,
"bold": 700
}
},
"spacing": {
"padding": 24,
"chromeGap": 6,
"chromeToChart": 12,
"chartToFooter": 12
},
"chrome": {
"title": {
"fontWeight": 600,
"lineHeight": 1.2
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.5
}
},
"borderRadius": 0
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"background": {
"light": "#faf8f5",
"dark": "#1a1816"
},
"text": {
"light": "#1c1917",
"dark": "#e7e5e4"
},
"gridline": {
"light": "rgba(0,0,0,0.08)",
"dark": "rgba(255,255,255,0.06)"
},
"axis": {
"light": "#78716c",
"dark": "#a8a29e"
}
},
"fonts": {
"family": "\"Source Serif 4\", \"Source Serif Pro\", Georgia, \"Times New Roman\", serif",
"sizes": {
"title": 28,
"subtitle": 15,
"body": 14,
"small": 12
},
"weights": {
"normal": 400,
"medium": 500,
"semibold": 600,
"bold": 700
}
},
"spacing": {
"padding": 24,
"chromeGap": 6,
"chromeToChart": 12,
"chartToFooter": 12
},
"chrome": {
"title": {
"fontWeight": 600,
"lineHeight": 1.2
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.5
}
},
"borderRadius": 0
}
};
export function Example() {
return <Chart spec={spec} />;
}
<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 data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"background": {
"light": "#faf8f5",
"dark": "#1a1816"
},
"text": {
"light": "#1c1917",
"dark": "#e7e5e4"
},
"gridline": {
"light": "rgba(0,0,0,0.08)",
"dark": "rgba(255,255,255,0.06)"
},
"axis": {
"light": "#78716c",
"dark": "#a8a29e"
}
},
"fonts": {
"family": "\"Source Serif 4\", \"Source Serif Pro\", Georgia, \"Times New Roman\", serif",
"sizes": {
"title": 28,
"subtitle": 15,
"body": 14,
"small": 12
},
"weights": {
"normal": 400,
"medium": 500,
"semibold": 600,
"bold": 700
}
},
"spacing": {
"padding": 24,
"chromeGap": 6,
"chromeToChart": 12,
"chartToFooter": 12
},
"chrome": {
"title": {
"fontWeight": 600,
"lineHeight": 1.2
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.5
}
},
"borderRadius": 0
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<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 data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"background": {
"light": "#faf8f5",
"dark": "#1a1816"
},
"text": {
"light": "#1c1917",
"dark": "#e7e5e4"
},
"gridline": {
"light": "rgba(0,0,0,0.08)",
"dark": "rgba(255,255,255,0.06)"
},
"axis": {
"light": "#78716c",
"dark": "#a8a29e"
}
},
"fonts": {
"family": "\"Source Serif 4\", \"Source Serif Pro\", Georgia, \"Times New Roman\", serif",
"sizes": {
"title": 28,
"subtitle": 15,
"body": 14,
"small": 12
},
"weights": {
"normal": 400,
"medium": 500,
"semibold": 600,
"bold": 700
}
},
"spacing": {
"padding": 24,
"chromeGap": 6,
"chromeToChart": 12,
"chartToFooter": 12
},
"chrome": {
"title": {
"fontWeight": 600,
"lineHeight": 1.2
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.5
}
},
"borderRadius": 0
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"background": {
"light": "#faf8f5",
"dark": "#1a1816"
},
"text": {
"light": "#1c1917",
"dark": "#e7e5e4"
},
"gridline": {
"light": "rgba(0,0,0,0.08)",
"dark": "rgba(255,255,255,0.06)"
},
"axis": {
"light": "#78716c",
"dark": "#a8a29e"
}
},
"fonts": {
"family": "\"Source Serif 4\", \"Source Serif Pro\", Georgia, \"Times New Roman\", serif",
"sizes": {
"title": 28,
"subtitle": 15,
"body": 14,
"small": 12
},
"weights": {
"normal": 400,
"medium": 500,
"semibold": 600,
"bold": 700
}
},
"spacing": {
"padding": 24,
"chromeGap": 6,
"chromeToChart": 12,
"chartToFooter": 12
},
"chrome": {
"title": {
"fontWeight": 600,
"lineHeight": 1.2
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.5
}
},
"borderRadius": 0
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Essay sets Source Serif 4 for all text, a warm off-white background, a 28px title and 24px of padding.
Using a preset
Import the preset from the core package and pass it as the theme:
import { essay } from "@opendata-ai/openchart-core";
const spec = { ...inflationSpec, theme: essay };The code tab under each chart shows the preset written out as the object it is, because the demo prints the spec with every value in place. In your own code, the import is all you need. To change part of a preset, merge your fields over it with mergeThemeConfig(essay, { fonts: { sizes: { title: 24 } } }).
Presets name fonts but do not load them. A page that uses essay needs Source Serif 4, and wire needs JetBrains Mono; this page loads both.
Wire
{
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"data": [
{
"date": "2021-01-01",
"rate": 1.4
},
{
"date": "2021-04-01",
"rate": 4.2
},
{
"date": "2021-07-01",
"rate": 5.4
},
{
"date": "2021-10-01",
"rate": 6.2
},
{
"date": "2022-01-01",
"rate": 7.5
},
{
"date": "2022-04-01",
"rate": 8.3
},
// … 10 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"background": {
"light": "#ffffff",
"dark": "#0a0a0a"
},
"text": {
"light": "#171717",
"dark": "#ededed"
},
"gridline": {
"light": "rgba(0,0,0,0.06)",
"dark": "rgba(255,255,255,0.06)"
},
"axis": {
"light": "#737373",
"dark": "#a3a3a3"
}
},
"fonts": {
"family": "\"JetBrains Mono\", \"Fira Code\", \"Cascadia Code\", monospace",
"sizes": {
"title": 16,
"subtitle": 12,
"body": 11,
"small": 10,
"axisTick": 12
},
"weights": {
"normal": 400,
"medium": 500,
"semibold": 600,
"bold": 700
}
},
"spacing": {
"padding": 12,
"chromeGap": 2,
"chromeToChart": 4,
"chartToFooter": 4
},
"chrome": {
"title": {
"fontWeight": 600,
"lineHeight": 1.25
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.3
}
},
"borderRadius": 2
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"background": {
"light": "#ffffff",
"dark": "#0a0a0a"
},
"text": {
"light": "#171717",
"dark": "#ededed"
},
"gridline": {
"light": "rgba(0,0,0,0.06)",
"dark": "rgba(255,255,255,0.06)"
},
"axis": {
"light": "#737373",
"dark": "#a3a3a3"
}
},
"fonts": {
"family": "\"JetBrains Mono\", \"Fira Code\", \"Cascadia Code\", monospace",
"sizes": {
"title": 16,
"subtitle": 12,
"body": 11,
"small": 10,
"axisTick": 12
},
"weights": {
"normal": 400,
"medium": 500,
"semibold": 600,
"bold": 700
}
},
"spacing": {
"padding": 12,
"chromeGap": 2,
"chromeToChart": 4,
"chartToFooter": 4
},
"chrome": {
"title": {
"fontWeight": 600,
"lineHeight": 1.25
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.3
}
},
"borderRadius": 2
}
};
export function Example() {
return <Chart spec={spec} />;
}
<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 data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"background": {
"light": "#ffffff",
"dark": "#0a0a0a"
},
"text": {
"light": "#171717",
"dark": "#ededed"
},
"gridline": {
"light": "rgba(0,0,0,0.06)",
"dark": "rgba(255,255,255,0.06)"
},
"axis": {
"light": "#737373",
"dark": "#a3a3a3"
}
},
"fonts": {
"family": "\"JetBrains Mono\", \"Fira Code\", \"Cascadia Code\", monospace",
"sizes": {
"title": 16,
"subtitle": 12,
"body": 11,
"small": 10,
"axisTick": 12
},
"weights": {
"normal": 400,
"medium": 500,
"semibold": 600,
"bold": 700
}
},
"spacing": {
"padding": 12,
"chromeGap": 2,
"chromeToChart": 4,
"chartToFooter": 4
},
"chrome": {
"title": {
"fontWeight": 600,
"lineHeight": 1.25
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.3
}
},
"borderRadius": 2
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<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 data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"background": {
"light": "#ffffff",
"dark": "#0a0a0a"
},
"text": {
"light": "#171717",
"dark": "#ededed"
},
"gridline": {
"light": "rgba(0,0,0,0.06)",
"dark": "rgba(255,255,255,0.06)"
},
"axis": {
"light": "#737373",
"dark": "#a3a3a3"
}
},
"fonts": {
"family": "\"JetBrains Mono\", \"Fira Code\", \"Cascadia Code\", monospace",
"sizes": {
"title": 16,
"subtitle": 12,
"body": 11,
"small": 10,
"axisTick": 12
},
"weights": {
"normal": 400,
"medium": 500,
"semibold": 600,
"bold": 700
}
},
"spacing": {
"padding": 12,
"chromeGap": 2,
"chromeToChart": 4,
"chartToFooter": 4
},
"chrome": {
"title": {
"fontWeight": 600,
"lineHeight": 1.25
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.3
}
},
"borderRadius": 2
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"background": {
"light": "#ffffff",
"dark": "#0a0a0a"
},
"text": {
"light": "#171717",
"dark": "#ededed"
},
"gridline": {
"light": "rgba(0,0,0,0.06)",
"dark": "rgba(255,255,255,0.06)"
},
"axis": {
"light": "#737373",
"dark": "#a3a3a3"
}
},
"fonts": {
"family": "\"JetBrains Mono\", \"Fira Code\", \"Cascadia Code\", monospace",
"sizes": {
"title": 16,
"subtitle": 12,
"body": 11,
"small": 10,
"axisTick": 12
},
"weights": {
"normal": 400,
"medium": 500,
"semibold": 600,
"bold": 700
}
},
"spacing": {
"padding": 12,
"chromeGap": 2,
"chromeToChart": 4,
"chartToFooter": 4
},
"chrome": {
"title": {
"fontWeight": 600,
"lineHeight": 1.25
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.3
}
},
"borderRadius": 2
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Wire sets JetBrains Mono for all text, a 16px title, 12px tick labels and tight gaps between the title, subtitle and plot. It fits dashboards and agency-style graphics where many charts share a screen.
Broadsheet
{
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"data": [
{
"date": "2021-01-01",
"rate": 1.4
},
{
"date": "2021-04-01",
"rate": 4.2
},
{
"date": "2021-07-01",
"rate": 5.4
},
{
"date": "2021-10-01",
"rate": 6.2
},
{
"date": "2022-01-01",
"rate": 7.5
},
{
"date": "2022-04-01",
"rate": 8.3
},
// … 10 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"categorical": [
{
"light": "#1d5f8a",
"dark": "#5e9fd6"
},
{
"light": "#e3120b",
"dark": "#f4655a"
},
{
"light": "#7fb0d3",
"dark": "#93c2e2"
},
{
"light": "#e0a63b",
"dark": "#e0b267"
},
{
"light": "#3a8a6e",
"dark": "#4fb093"
},
{
"light": "#8c8680",
"dark": "#9aa1a8"
}
],
"categoricalFill": [
{
"light": "#3b7097",
"dark": "#80b5e3"
},
{
"light": "#ee493a",
"dark": "#ec5b50"
},
{
"light": "#97c2e2",
"dark": "#acd3eb"
},
{
"light": "#efbb64",
"dark": "#c6ad55"
},
{
"light": "#579a81",
"dark": "#5bd2ac"
},
{
"light": "#9e9893",
"dark": "#b4b9bf"
}
],
"background": {
"light": "#fffdf9",
"dark": "#12181f"
},
"text": {
"light": "#1a1714",
"dark": "#e9ebe6"
},
"gridline": {
"light": "rgba(26,23,20,0.08)",
"dark": "rgba(233,235,230,0.07)"
},
"hairline": {
"light": "rgba(26,23,20,0.28)",
"dark": "rgba(233,235,230,0.28)"
},
"axis": {
"light": "#6b645c",
"dark": "#9aa4ad"
},
"annotationFill": {
"light": "rgba(26,23,20,0.05)",
"dark": "rgba(233,235,230,0.07)"
},
"annotationText": {
"light": "#6b645c",
"dark": "#9aa4ad"
}
},
"fonts": {
"sizes": {
"title": 24,
"subtitle": 14,
"body": 13,
"small": 11
}
},
"spacing": {
"padding": 20,
"chromeGap": 8,
"chromeToChart": 16,
"chartToFooter": 12
},
"chrome": {
"eyebrow": {
"color": {
"light": "#e3120b",
"dark": "#f4463f"
},
"fontSize": 11,
"fontWeight": 700
},
"title": {
"fontWeight": 700,
"lineHeight": 1.18
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.45
}
},
"rule": {
"color": {
"light": "#e3120b",
"dark": "#f4463f"
},
"width": 40,
"thickness": 3
},
"borderRadius": 0
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"categorical": [
{
"light": "#1d5f8a",
"dark": "#5e9fd6"
},
{
"light": "#e3120b",
"dark": "#f4655a"
},
{
"light": "#7fb0d3",
"dark": "#93c2e2"
},
{
"light": "#e0a63b",
"dark": "#e0b267"
},
{
"light": "#3a8a6e",
"dark": "#4fb093"
},
{
"light": "#8c8680",
"dark": "#9aa1a8"
}
],
"categoricalFill": [
{
"light": "#3b7097",
"dark": "#80b5e3"
},
{
"light": "#ee493a",
"dark": "#ec5b50"
},
{
"light": "#97c2e2",
"dark": "#acd3eb"
},
{
"light": "#efbb64",
"dark": "#c6ad55"
},
{
"light": "#579a81",
"dark": "#5bd2ac"
},
{
"light": "#9e9893",
"dark": "#b4b9bf"
}
],
"background": {
"light": "#fffdf9",
"dark": "#12181f"
},
"text": {
"light": "#1a1714",
"dark": "#e9ebe6"
},
"gridline": {
"light": "rgba(26,23,20,0.08)",
"dark": "rgba(233,235,230,0.07)"
},
"hairline": {
"light": "rgba(26,23,20,0.28)",
"dark": "rgba(233,235,230,0.28)"
},
"axis": {
"light": "#6b645c",
"dark": "#9aa4ad"
},
"annotationFill": {
"light": "rgba(26,23,20,0.05)",
"dark": "rgba(233,235,230,0.07)"
},
"annotationText": {
"light": "#6b645c",
"dark": "#9aa4ad"
}
},
"fonts": {
"sizes": {
"title": 24,
"subtitle": 14,
"body": 13,
"small": 11
}
},
"spacing": {
"padding": 20,
"chromeGap": 8,
"chromeToChart": 16,
"chartToFooter": 12
},
"chrome": {
"eyebrow": {
"color": {
"light": "#e3120b",
"dark": "#f4463f"
},
"fontSize": 11,
"fontWeight": 700
},
"title": {
"fontWeight": 700,
"lineHeight": 1.18
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.45
}
},
"rule": {
"color": {
"light": "#e3120b",
"dark": "#f4463f"
},
"width": 40,
"thickness": 3
},
"borderRadius": 0
}
};
export function Example() {
return <Chart spec={spec} />;
}
<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 data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"categorical": [
{
"light": "#1d5f8a",
"dark": "#5e9fd6"
},
{
"light": "#e3120b",
"dark": "#f4655a"
},
{
"light": "#7fb0d3",
"dark": "#93c2e2"
},
{
"light": "#e0a63b",
"dark": "#e0b267"
},
{
"light": "#3a8a6e",
"dark": "#4fb093"
},
{
"light": "#8c8680",
"dark": "#9aa1a8"
}
],
"categoricalFill": [
{
"light": "#3b7097",
"dark": "#80b5e3"
},
{
"light": "#ee493a",
"dark": "#ec5b50"
},
{
"light": "#97c2e2",
"dark": "#acd3eb"
},
{
"light": "#efbb64",
"dark": "#c6ad55"
},
{
"light": "#579a81",
"dark": "#5bd2ac"
},
{
"light": "#9e9893",
"dark": "#b4b9bf"
}
],
"background": {
"light": "#fffdf9",
"dark": "#12181f"
},
"text": {
"light": "#1a1714",
"dark": "#e9ebe6"
},
"gridline": {
"light": "rgba(26,23,20,0.08)",
"dark": "rgba(233,235,230,0.07)"
},
"hairline": {
"light": "rgba(26,23,20,0.28)",
"dark": "rgba(233,235,230,0.28)"
},
"axis": {
"light": "#6b645c",
"dark": "#9aa4ad"
},
"annotationFill": {
"light": "rgba(26,23,20,0.05)",
"dark": "rgba(233,235,230,0.07)"
},
"annotationText": {
"light": "#6b645c",
"dark": "#9aa4ad"
}
},
"fonts": {
"sizes": {
"title": 24,
"subtitle": 14,
"body": 13,
"small": 11
}
},
"spacing": {
"padding": 20,
"chromeGap": 8,
"chromeToChart": 16,
"chartToFooter": 12
},
"chrome": {
"eyebrow": {
"color": {
"light": "#e3120b",
"dark": "#f4463f"
},
"fontSize": 11,
"fontWeight": 700
},
"title": {
"fontWeight": 700,
"lineHeight": 1.18
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.45
}
},
"rule": {
"color": {
"light": "#e3120b",
"dark": "#f4463f"
},
"width": 40,
"thickness": 3
},
"borderRadius": 0
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<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 data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"categorical": [
{
"light": "#1d5f8a",
"dark": "#5e9fd6"
},
{
"light": "#e3120b",
"dark": "#f4655a"
},
{
"light": "#7fb0d3",
"dark": "#93c2e2"
},
{
"light": "#e0a63b",
"dark": "#e0b267"
},
{
"light": "#3a8a6e",
"dark": "#4fb093"
},
{
"light": "#8c8680",
"dark": "#9aa1a8"
}
],
"categoricalFill": [
{
"light": "#3b7097",
"dark": "#80b5e3"
},
{
"light": "#ee493a",
"dark": "#ec5b50"
},
{
"light": "#97c2e2",
"dark": "#acd3eb"
},
{
"light": "#efbb64",
"dark": "#c6ad55"
},
{
"light": "#579a81",
"dark": "#5bd2ac"
},
{
"light": "#9e9893",
"dark": "#b4b9bf"
}
],
"background": {
"light": "#fffdf9",
"dark": "#12181f"
},
"text": {
"light": "#1a1714",
"dark": "#e9ebe6"
},
"gridline": {
"light": "rgba(26,23,20,0.08)",
"dark": "rgba(233,235,230,0.07)"
},
"hairline": {
"light": "rgba(26,23,20,0.28)",
"dark": "rgba(233,235,230,0.28)"
},
"axis": {
"light": "#6b645c",
"dark": "#9aa4ad"
},
"annotationFill": {
"light": "rgba(26,23,20,0.05)",
"dark": "rgba(233,235,230,0.07)"
},
"annotationText": {
"light": "#6b645c",
"dark": "#9aa4ad"
}
},
"fonts": {
"sizes": {
"title": 24,
"subtitle": 14,
"body": 13,
"small": 11
}
},
"spacing": {
"padding": 20,
"chromeGap": 8,
"chromeToChart": 16,
"chartToFooter": 12
},
"chrome": {
"eyebrow": {
"color": {
"light": "#e3120b",
"dark": "#f4463f"
},
"fontSize": 11,
"fontWeight": 700
},
"title": {
"fontWeight": 700,
"lineHeight": 1.18
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.45
}
},
"rule": {
"color": {
"light": "#e3120b",
"dark": "#f4463f"
},
"width": 40,
"thickness": 3
},
"borderRadius": 0
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"categorical": [
{
"light": "#1d5f8a",
"dark": "#5e9fd6"
},
{
"light": "#e3120b",
"dark": "#f4655a"
},
{
"light": "#7fb0d3",
"dark": "#93c2e2"
},
{
"light": "#e0a63b",
"dark": "#e0b267"
},
{
"light": "#3a8a6e",
"dark": "#4fb093"
},
{
"light": "#8c8680",
"dark": "#9aa1a8"
}
],
"categoricalFill": [
{
"light": "#3b7097",
"dark": "#80b5e3"
},
{
"light": "#ee493a",
"dark": "#ec5b50"
},
{
"light": "#97c2e2",
"dark": "#acd3eb"
},
{
"light": "#efbb64",
"dark": "#c6ad55"
},
{
"light": "#579a81",
"dark": "#5bd2ac"
},
{
"light": "#9e9893",
"dark": "#b4b9bf"
}
],
"background": {
"light": "#fffdf9",
"dark": "#12181f"
},
"text": {
"light": "#1a1714",
"dark": "#e9ebe6"
},
"gridline": {
"light": "rgba(26,23,20,0.08)",
"dark": "rgba(233,235,230,0.07)"
},
"hairline": {
"light": "rgba(26,23,20,0.28)",
"dark": "rgba(233,235,230,0.28)"
},
"axis": {
"light": "#6b645c",
"dark": "#9aa4ad"
},
"annotationFill": {
"light": "rgba(26,23,20,0.05)",
"dark": "rgba(233,235,230,0.07)"
},
"annotationText": {
"light": "#6b645c",
"dark": "#9aa4ad"
}
},
"fonts": {
"sizes": {
"title": 24,
"subtitle": 14,
"body": 13,
"small": 11
}
},
"spacing": {
"padding": 20,
"chromeGap": 8,
"chromeToChart": 16,
"chartToFooter": 12
},
"chrome": {
"eyebrow": {
"color": {
"light": "#e3120b",
"dark": "#f4463f"
},
"fontSize": 11,
"fontWeight": 700
},
"title": {
"fontWeight": 700,
"lineHeight": 1.18
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.45
}
},
"rule": {
"color": {
"light": "#e3120b",
"dark": "#f4463f"
},
"width": 40,
"thickness": 3
},
"borderRadius": 0
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Broadsheet draws a short red bar above the title, the masthead device of a newspaper graphic, and sets a bold 24px title on warm paper. Its six-color palette is led by an ink blue and a house red. The light palette fails the library’s Machado/CIE76 checks for deuteranopia and protanopia at the default threshold of 15. The text family stays the default, Inter.
Terminal
{
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"data": [
{
"date": "2021-01-01",
"rate": 1.4
},
{
"date": "2021-04-01",
"rate": 4.2
},
{
"date": "2021-07-01",
"rate": 5.4
},
{
"date": "2021-10-01",
"rate": 6.2
},
{
"date": "2022-01-01",
"rate": 7.5
},
{
"date": "2022-04-01",
"rate": 8.3
},
// … 10 more rows; Copy includes them
],
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"categorical": [
"#22d3ee",
"#f9be78",
"#6591e1",
"#d771a4",
"#6ebf8c",
"#bca1ed"
],
"categoricalFill": [
"#72cedc",
"#f3c898",
"#7698d6",
"#d281a8",
"#82ba95",
"#c2afe7"
],
"background": {
"light": "#0b0f14",
"dark": "#0b0f14"
},
"text": {
"light": "#e6edf3",
"dark": "#e6edf3"
},
"gridline": {
"light": "rgba(230,237,243,0.06)",
"dark": "rgba(230,237,243,0.06)"
},
"hairline": {
"light": "rgba(230,237,243,0.14)",
"dark": "rgba(230,237,243,0.14)"
},
"axis": {
"light": "#8b949e",
"dark": "#8b949e"
},
"annotationFill": {
"light": "rgba(230,237,243,0.06)",
"dark": "rgba(230,237,243,0.06)"
},
"annotationText": {
"light": "#8b949e",
"dark": "#8b949e"
},
"positive": {
"light": "#4ade80",
"dark": "#4ade80"
},
"negative": {
"light": "#f87171",
"dark": "#f87171"
}
},
"fonts": {
"family": "\"Inter Variable\", Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif",
"mono": "\"JetBrains Mono\", \"Fira Code\", \"Cascadia Code\", monospace",
"sizes": {
"title": 15,
"subtitle": 12,
"body": 12,
"small": 10,
"axisTick": 12
}
},
"spacing": {
"padding": 12,
"chromeGap": 3,
"chromeToChart": 6,
"chartToFooter": 6
},
"chrome": {
"eyebrow": {
"color": {
"light": "#22d3ee",
"dark": "#22d3ee"
},
"fontSize": 10,
"fontWeight": 500
},
"title": {
"fontWeight": 600,
"lineHeight": 1.3
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.4
}
},
"borderRadius": 4,
"seriesStrategy": "accent-neutral"
}
}import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"categorical": [
"#22d3ee",
"#f9be78",
"#6591e1",
"#d771a4",
"#6ebf8c",
"#bca1ed"
],
"categoricalFill": [
"#72cedc",
"#f3c898",
"#7698d6",
"#d281a8",
"#82ba95",
"#c2afe7"
],
"background": {
"light": "#0b0f14",
"dark": "#0b0f14"
},
"text": {
"light": "#e6edf3",
"dark": "#e6edf3"
},
"gridline": {
"light": "rgba(230,237,243,0.06)",
"dark": "rgba(230,237,243,0.06)"
},
"hairline": {
"light": "rgba(230,237,243,0.14)",
"dark": "rgba(230,237,243,0.14)"
},
"axis": {
"light": "#8b949e",
"dark": "#8b949e"
},
"annotationFill": {
"light": "rgba(230,237,243,0.06)",
"dark": "rgba(230,237,243,0.06)"
},
"annotationText": {
"light": "#8b949e",
"dark": "#8b949e"
},
"positive": {
"light": "#4ade80",
"dark": "#4ade80"
},
"negative": {
"light": "#f87171",
"dark": "#f87171"
}
},
"fonts": {
"family": "\"Inter Variable\", Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif",
"mono": "\"JetBrains Mono\", \"Fira Code\", \"Cascadia Code\", monospace",
"sizes": {
"title": 15,
"subtitle": 12,
"body": 12,
"small": 10,
"axisTick": 12
}
},
"spacing": {
"padding": 12,
"chromeGap": 3,
"chromeToChart": 6,
"chartToFooter": 6
},
"chrome": {
"eyebrow": {
"color": {
"light": "#22d3ee",
"dark": "#22d3ee"
},
"fontSize": 10,
"fontWeight": 500
},
"title": {
"fontWeight": 600,
"lineHeight": 1.3
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.4
}
},
"borderRadius": 4,
"seriesStrategy": "accent-neutral"
}
};
export function Example() {
return <Chart spec={spec} />;
}
<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 data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"categorical": [
"#22d3ee",
"#f9be78",
"#6591e1",
"#d771a4",
"#6ebf8c",
"#bca1ed"
],
"categoricalFill": [
"#72cedc",
"#f3c898",
"#7698d6",
"#d281a8",
"#82ba95",
"#c2afe7"
],
"background": {
"light": "#0b0f14",
"dark": "#0b0f14"
},
"text": {
"light": "#e6edf3",
"dark": "#e6edf3"
},
"gridline": {
"light": "rgba(230,237,243,0.06)",
"dark": "rgba(230,237,243,0.06)"
},
"hairline": {
"light": "rgba(230,237,243,0.14)",
"dark": "rgba(230,237,243,0.14)"
},
"axis": {
"light": "#8b949e",
"dark": "#8b949e"
},
"annotationFill": {
"light": "rgba(230,237,243,0.06)",
"dark": "rgba(230,237,243,0.06)"
},
"annotationText": {
"light": "#8b949e",
"dark": "#8b949e"
},
"positive": {
"light": "#4ade80",
"dark": "#4ade80"
},
"negative": {
"light": "#f87171",
"dark": "#f87171"
}
},
"fonts": {
"family": "\"Inter Variable\", Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif",
"mono": "\"JetBrains Mono\", \"Fira Code\", \"Cascadia Code\", monospace",
"sizes": {
"title": 15,
"subtitle": 12,
"body": 12,
"small": 10,
"axisTick": 12
}
},
"spacing": {
"padding": 12,
"chromeGap": 3,
"chromeToChart": 6,
"chartToFooter": 6
},
"chrome": {
"eyebrow": {
"color": {
"light": "#22d3ee",
"dark": "#22d3ee"
},
"fontSize": 10,
"fontWeight": 500
},
"title": {
"fontWeight": 600,
"lineHeight": 1.3
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.4
}
},
"borderRadius": 4,
"seriesStrategy": "accent-neutral"
}
};
</script>
<template>
<Chart :spec="spec" />
</template>
<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 data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"categorical": [
"#22d3ee",
"#f9be78",
"#6591e1",
"#d771a4",
"#6ebf8c",
"#bca1ed"
],
"categoricalFill": [
"#72cedc",
"#f3c898",
"#7698d6",
"#d281a8",
"#82ba95",
"#c2afe7"
],
"background": {
"light": "#0b0f14",
"dark": "#0b0f14"
},
"text": {
"light": "#e6edf3",
"dark": "#e6edf3"
},
"gridline": {
"light": "rgba(230,237,243,0.06)",
"dark": "rgba(230,237,243,0.06)"
},
"hairline": {
"light": "rgba(230,237,243,0.14)",
"dark": "rgba(230,237,243,0.14)"
},
"axis": {
"light": "#8b949e",
"dark": "#8b949e"
},
"annotationFill": {
"light": "rgba(230,237,243,0.06)",
"dark": "rgba(230,237,243,0.06)"
},
"annotationText": {
"light": "#8b949e",
"dark": "#8b949e"
},
"positive": {
"light": "#4ade80",
"dark": "#4ade80"
},
"negative": {
"light": "#f87171",
"dark": "#f87171"
}
},
"fonts": {
"family": "\"Inter Variable\", Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif",
"mono": "\"JetBrains Mono\", \"Fira Code\", \"Cascadia Code\", monospace",
"sizes": {
"title": 15,
"subtitle": 12,
"body": 12,
"small": 10,
"axisTick": 12
}
},
"spacing": {
"padding": 12,
"chromeGap": 3,
"chromeToChart": 6,
"chartToFooter": 6
},
"chrome": {
"eyebrow": {
"color": {
"light": "#22d3ee",
"dark": "#22d3ee"
},
"fontSize": 10,
"fontWeight": 500
},
"title": {
"fontWeight": 600,
"lineHeight": 1.3
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.4
}
},
"borderRadius": 4,
"seriesStrategy": "accent-neutral"
}
};
</script>
<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 16 rows; Copy includes them */];
const spec: ChartSpec = {
data,
"mark": {
"type": "line",
"strokeWidth": 2.5
},
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "rate",
"type": "quantitative",
"axis": {
"title": "Change (%)",
"grid": true
}
}
},
"annotations": [
{
"type": "text",
"x": "2022-07-01",
"y": 8.5,
"text": "8.5% in Q3 2022",
"anchor": "right"
},
{
"type": "refline",
"y": 2,
"label": "Fed target, 2%",
"style": "dashed"
}
],
"chrome": {
"title": "US inflation peaked at 8.5% in 2022 and eased to 2.6% by the end of 2024",
"subtitle": "Consumer price index, year-over-year change, %, quarterly 2021–2024"
},
"theme": {
"colors": {
"categorical": [
"#22d3ee",
"#f9be78",
"#6591e1",
"#d771a4",
"#6ebf8c",
"#bca1ed"
],
"categoricalFill": [
"#72cedc",
"#f3c898",
"#7698d6",
"#d281a8",
"#82ba95",
"#c2afe7"
],
"background": {
"light": "#0b0f14",
"dark": "#0b0f14"
},
"text": {
"light": "#e6edf3",
"dark": "#e6edf3"
},
"gridline": {
"light": "rgba(230,237,243,0.06)",
"dark": "rgba(230,237,243,0.06)"
},
"hairline": {
"light": "rgba(230,237,243,0.14)",
"dark": "rgba(230,237,243,0.14)"
},
"axis": {
"light": "#8b949e",
"dark": "#8b949e"
},
"annotationFill": {
"light": "rgba(230,237,243,0.06)",
"dark": "rgba(230,237,243,0.06)"
},
"annotationText": {
"light": "#8b949e",
"dark": "#8b949e"
},
"positive": {
"light": "#4ade80",
"dark": "#4ade80"
},
"negative": {
"light": "#f87171",
"dark": "#f87171"
}
},
"fonts": {
"family": "\"Inter Variable\", Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif",
"mono": "\"JetBrains Mono\", \"Fira Code\", \"Cascadia Code\", monospace",
"sizes": {
"title": 15,
"subtitle": 12,
"body": 12,
"small": 10,
"axisTick": 12
}
},
"spacing": {
"padding": 12,
"chromeGap": 3,
"chromeToChart": 6,
"chartToFooter": 6
},
"chrome": {
"eyebrow": {
"color": {
"light": "#22d3ee",
"dark": "#22d3ee"
},
"fontSize": 10,
"fontWeight": 500
},
"title": {
"fontWeight": 600,
"lineHeight": 1.3
},
"subtitle": {
"fontWeight": 400,
"lineHeight": 1.4
}
},
"borderRadius": 4,
"seriesStrategy": "accent-neutral"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);
Terminal is dark in both site themes: a near-black background, light text and the library’s dark palette. It sets seriesStrategy: "accent-neutral", so a chart with two to four series shows one cyan accent and greys for the rest. Use it for product and monitoring screens that are dark already.
Fields that matter
| Field | What it does |
|---|---|
theme |
Takes a preset: essay, wire, broadsheet or terminal. Omit it, or pass {}, for the default. |
mergeThemeConfig(preset, overrides) |
Returns the preset with your fields merged over it. |
theme.rule |
The bar above the title. Set rule: null to drop broadsheet’s. |
theme.fonts.family |
Each preset’s text family. Load the font on your page, or the browser falls back down the list. |
Related
- Theming and tokens explains each
ThemeConfigfield the presets set. - Dark mode shows a preset’s dark palette.
- Line covers the chart type used here.
- Theme reference lists the presets and every field default.