Earlier formats

Charts

Bar, line, area, pie, donut, and scatter charts: data shapes, stacking and grouping, number formats, and currency rules.

One component, Chart, draws 6 types: bar, line, area, pie, donut, scatter. Up to 8 series, one per color in a fixed, validated palette with light and dark values. Every chart has a Table button that shows its data as a table, for screen readers and for exact numbers.

Bar, line, and areaLink to this section

labels are the x-axis. Each series has a name and one value per label in values. height is sm, md (default), or lg; xLabel and yLabel name the axes.

Bar
Deploys per month
LabelDeploys
Jan12
Feb19
Mar8
Apr22
May17
Jun25
Show JSON
{
  "version": 1,
  "root": "chart",
  "elements": {
    "chart": {
      "type": "Chart",
      "props": {
        "type": "bar",
        "title": "Deploys per month",
        "labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
        "series": [{ "name": "Deploys", "values": [12, 19, 8, 22, 17, 25] }]
      }
    }
  }
}
Line, two series
Signups and churn
  • Signups
  • Churn
LabelSignupsChurn
Jan12020
Feb18024
Mar24022
Apr31030
May29028
Jun36026
Show JSON
{
  "version": 1,
  "root": "chart",
  "elements": {
    "chart": {
      "type": "Chart",
      "props": {
        "type": "line",
        "title": "Signups and churn",
        "labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
        "series": [
          {
            "name": "Signups",
            "values": [120, 180, 240, 310, 290, 360]
          },
          { "name": "Churn", "values": [20, 24, 22, 30, 28, 26] }
        ]
      }
    }
  }
}
Area
Storage used
LabelBytes
Jan1.2B
Feb1.5B
Mar1.7B
Apr2.1B
May2.4B
Jun2.9B
Show JSON
{
  "version": 1,
  "root": "chart",
  "elements": {
    "chart": {
      "type": "Chart",
      "props": {
        "type": "area",
        "title": "Storage used",
        "format": "compact",
        "height": "sm",
        "labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
        "series": [
          {
            "name": "Bytes",
            "values": [
              1200000000,
              1450000000,
              1700000000,
              2100000000,
              2350000000,
              2900000000
            ]
          }
        ]
      }
    }
  }
}

Grouped barsLink to this section

Several bar series draw grouped bars, side by side for each label.

Grouped bars
Spend by team
  • Platform
  • Web
  • Data

Spend

Quarter

QuarterPlatformWebData
Q1$42,000$18,000$9,500
Q2$45,500$21,000$12,000
Q3$39,000$22,400$14,200
Q4$51,200$25,100$15,800
Show JSON
{
  "version": 1,
  "root": "chart",
  "elements": {
    "chart": {
      "type": "Chart",
      "props": {
        "type": "bar",
        "title": "Spend by team",
        "format": "currency",
        "currency": "USD",
        "labels": ["Q1", "Q2", "Q3", "Q4"],
        "series": [
          { "name": "Platform", "values": [42000, 45500, 39000, 51200] },
          { "name": "Web", "values": [18000, 21000, 22400, 25100] },
          { "name": "Data", "values": [9500, 12000, 14200, 15800] }
        ],
        "xLabel": "Quarter",
        "yLabel": "Spend"
      }
    }
  }
}

Stacked bars and areasLink to this section

"stacked": true stacks bar or area series. Negative values stack below zero, so gains and losses read in one bar.

Stacked bars with negatives
Net seats by source
  • New
  • Expansion
  • Churn
LabelNewExpansionChurnTotal
Jan3012-1527
Feb428-2228
Mar1820-830
Apr508-3028
May2414-1226
Jun3610-1828
Show JSON
{
  "version": 1,
  "root": "chart",
  "elements": {
    "chart": {
      "type": "Chart",
      "props": {
        "type": "bar",
        "stacked": true,
        "title": "Net seats by source",
        "labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
        "series": [
          { "name": "New", "values": [30, 42, 18, 50, 24, 36] },
          { "name": "Expansion", "values": [12, 8, 20, 8, 14, 10] },
          { "name": "Churn", "values": [-15, -22, -8, -30, -12, -18] }
        ]
      }
    }
  }
}
Stacked area
Requests by region
  • us-east
  • eu-west
  • ap-south
Labelus-easteu-westap-southTotal
Jan820K410K90K1.3M
Feb910K450K120K1.5M
Mar960K520K160K1.6M
Apr1M540K210K1.8M
May1.1M600K260K2M
Jun1.2M640K330K2.2M
Show JSON
{
  "version": 1,
  "root": "chart",
  "elements": {
    "chart": {
      "type": "Chart",
      "props": {
        "type": "area",
        "stacked": true,
        "title": "Requests by region",
        "format": "compact",
        "labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
        "series": [
          {
            "name": "us-east",
            "values": [820000, 910000, 960000, 1020000, 1100000, 1240000]
          },
          {
            "name": "eu-west",
            "values": [410000, 450000, 520000, 540000, 600000, 640000]
          },
          {
            "name": "ap-south",
            "values": [90000, 120000, 160000, 210000, 260000, 330000]
          }
        ]
      }
    }
  }
}

Gaps and negativesLink to this section

Write null for a missing value. Lines and areas break there instead of guessing.

Gaps and negatives

null leaves a gap; the line does not invent a value for March.

Margin
LabelMargin
Jan-12%
Feb-4%
Mar—
Apr6%
May11%
Jun18%
Show JSON
{
  "version": 1,
  "root": "chart",
  "elements": {
    "chart": {
      "type": "Chart",
      "props": {
        "type": "line",
        "title": "Margin",
        "format": "percent",
        "labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
        "series": [{ "name": "Margin", "values": [-12, -4, null, 6, 11, 18] }]
      }
    }
  }
}

Pie and donutLink to this section

Pie and donut take exactly one series. labels name the slices, and values must be zero or more. With more than 8 slices, the 7 largest stay and the rest fold into one "Other" slice. The legend shows each slice's value and share; a donut shows the total in the middle.

Pie
Incidents by cause
  • Config1440%
  • Deploy925.7%
  • Capacity617.1%
  • Dependency411.4%
  • Other25.7%

LabelIncidentsShare
Config1440%
Deploy925.7%
Capacity617.1%
Dependency411.4%
Other25.7%
Show JSON
{
  "version": 1,
  "root": "chart",
  "elements": {
    "chart": {
      "type": "Chart",
      "props": {
        "type": "pie",
        "title": "Incidents by cause",
        "labels": ["Config", "Deploy", "Capacity", "Dependency", "Other"],
        "series": [{ "name": "Incidents", "values": [14, 9, 6, 4, 2] }]
      }
    }
  }
}
Donut with currency
Spend by vendor
  • Neon€1,250.0053.2%
  • Vercel€980.5041.7%
  • Cloudflare€120.005.1%

LabelSpendShare
Neon€1,250.0053.2%
Vercel€980.5041.7%
Cloudflare€120.005.1%
Show JSON
{
  "version": 1,
  "root": "chart",
  "elements": {
    "chart": {
      "type": "Chart",
      "props": {
        "type": "donut",
        "title": "Spend by vendor",
        "format": "currency",
        "currency": "EUR",
        "labels": ["Neon", "Vercel", "Cloudflare"],
        "series": [{ "name": "Spend", "values": [1250, 980.5, 120] }]
      }
    }
  }
}

ScatterLink to this section

Scatter series carry points instead of values: { "x": 4, "y": 38, "label": "optional" }, up to 500 per series, and the chart has no labels. format styles y values and xFormat styles x values. Keep to 3 series or fewer so the colors stay easy to tell apart.

Scatter
Latency against payload size
  • Edge
  • Origin

p95 latency (ms)

Payload (KB)

SeriesLabelPayload (KB)p95 latency (ms)
EdgeGET /a438
Origin6120
Edge1252
Origin18140
Edge3061
Origin40182
EdgePOST /upload6490
OriginPOST /upload80260
Show JSON
{
  "version": 1,
  "root": "chart",
  "elements": {
    "chart": {
      "type": "Chart",
      "props": {
        "type": "scatter",
        "title": "Latency against payload size",
        "xLabel": "Payload (KB)",
        "yLabel": "p95 latency (ms)",
        "series": [
          {
            "name": "Edge",
            "points": [
              { "x": 4, "y": 38, "label": "GET /a" },
              { "x": 12, "y": 52 },
              { "x": 30, "y": 61 },
              { "x": 64, "y": 90, "label": "POST /upload" }
            ]
          },
          {
            "name": "Origin",
            "points": [
              { "x": 6, "y": 120 },
              { "x": 18, "y": 140 },
              { "x": 40, "y": 182 },
              { "x": 80, "y": 260, "label": "POST /upload" }
            ]
          }
        ]
      }
    }
  }
}

Number formatsLink to this section

format applies to values, axis ticks, tooltips, and the data table. The same rules format Metric, Table, and KeyValue numbers. Values read together, such as an axis or a column, share one decimal count so they line up.

formatValueShows asNotes
number1234.51,234.5Plain numbers. Up to two decimals; whole numbers show none.
compact12500001.3MShort form for big numbers. Values under 1 use the plain rules.
percent12.512.5%The value is already a percent: 12.5 shows as 12.5%, not 1,250%.
currency28.5$28.50Uses currency (default USD) and its minor unit.
currency (JPY)1200¥1,200Yen has no minor unit, so no decimals.
currency, sub-cent0.0042$0.0042Smaller than one cent keeps two significant digits, never $0.00.
currency, huge2e15USD 2.00e+15From 10¹⁵ up, numbers switch to scientific notation.
Formats side by side
percent
LabelShare
A12.5%
B40.0%
C47.5%
compact
LabelViews
A12.4K
B1.3M
C98M
currency (JPY)
LabelCost
A¥1,200
B¥45,000
C¥980
number
LabelCount
A2.50
B14.00
C7.25
Show JSON
{
  "version": 1,
  "root": "grid",
  "elements": {
    "grid": {
      "type": "Grid",
      "props": { "columns": 2 },
      "children": ["as-percent", "as-compact", "as-currency", "as-number"]
    },
    "as-percent": {
      "type": "Chart",
      "props": {
        "type": "bar",
        "title": "percent",
        "format": "percent",
        "height": "sm",
        "labels": ["A", "B", "C"],
        "series": [{ "name": "Share", "values": [12.5, 40, 47.5] }]
      }
    },
    "as-compact": {
      "type": "Chart",
      "props": {
        "type": "bar",
        "title": "compact",
        "format": "compact",
        "height": "sm",
        "labels": ["A", "B", "C"],
        "series": [{ "name": "Views", "values": [12400, 1250000, 98000000] }]
      }
    },
    "as-currency": {
      "type": "Chart",
      "props": {
        "type": "bar",
        "title": "currency (JPY)",
        "format": "currency",
        "currency": "JPY",
        "height": "sm",
        "labels": ["A", "B", "C"],
        "series": [{ "name": "Cost", "values": [1200, 45000, 980] }]
      }
    },
    "as-number": {
      "type": "Chart",
      "props": {
        "type": "bar",
        "title": "number",
        "height": "sm",
        "labels": ["A", "B", "C"],
        "series": [{ "name": "Count", "values": [2.5, 14, 7.25] }]
      }
    }
  }
}

CurrencyLink to this section

  • currency is a three-letter ISO 4217 code such as USD, EUR, or JPY. It applies only when format is currency, and defaults to USD.
  • Amounts use the currency's minor unit: two decimals for USD and EUR ($28.50), none for JPY. Whole amounts drop the decimals ($1,430) unless others on the same axis need them.
  • A code the browser does not know still renders, as CODE 1,234.
  • For a Metric, change uses changeFormat, which defaults to the value's format. A revenue metric usually sets changeFormat: "percent" so a 12.4 change reads +12.4%, not +$12.40.

Chart rulesLink to this section

Validation checks the data shape for each type. These are the real messages:

MistakeMessage
Fewer values than labelsSeries "Deploys" has 3 values but there are 4 labels. Give each series one value per label (use null for a gap).
Two series on a pieA pie chart shows one series, but there are 2. Put one value per slice in series[0].values and the slice names in labels. For several series, use a bar chart.
stacked on a line chartstacked works with bar and area charts only, not line. Remove stacked.
values on a scatter chartSeries "Runs" has values, but a scatter chart reads `points`: [{ "x": 1, "y": 2 }, …]. Move the data into points.