Chart Image API

Render bar, line, area, pie, doughnut, scatter and sparkline charts from a Chart.js-like JSON config as PNG or SVG, by a URL usable in <img> and emails.

GETPOSThttps://apibox.io.vn/v1/chart-image
Images & Codes▶ Try it online

Describe the chart in JSON and get an image: {"type":"bar","data":{"labels":[…],"datasets":[{"label":"…","data":[…]}]},"options":{"title":"…"}}. Types: bar, horizontal-bar (or Chart.js indexAxis: "y"), line, area, pie, doughnut, scatter (points {x, y}) and sparkline. Several datasets are grouped (or stacked: true), a dataset of a bar chart can be drawn as a line, gaps (null) break lines, and tension smooths them. Options: title, subtitle, legend (top, bottom, right, false), x_label / y_label, min / max, values (data labels), prefix / suffix (" ₫", "%"), locale (vi writes 1.234,5 and 12 tr / 3 tỷ on axes), theme (light / dark), font_size and colours per dataset (color, backgroundColor, an array for one colour per bar). The usual Chart.js keys (plugins.title, plugins.legend, scales.y.min, scales.x.stacked…) are understood, so most QuickChart-style configs work as they are.

Because it answers GET with the config URL-encoded in c, the URL can be put straight into <img src>, an e-mail, a Slack / Zalo message or a Markdown / PDF report. PNG (default) and JPEG are drawn by our own renderer with the Be Vietnam Pro font, so Vietnamese text looks the same everywhere; scale=2 gives a sharp image on retina screens. SVG keeps the text as vector outlines by default (exact rendering without fonts), svg_text=text writes real <text> elements instead.

Size: width × height up to 2000 px and 4 megapixels with scale, up to 20 datasets and 10,000 points. The colours follow a colour-blind-checked palette; the renderer is our own code (not QuickChart or Chart.js).

Parameters

NameInTypeRequiredDefault
cquery|bodyobjectyesChart config (JSON; URL-encoded in GET): type, data.labels, data.datasets, options. chart is an alias.
formatquery|bodystringnopngpng, svg, jpeg or json (PNG as base64 + SVG).
widthquery|bodynumberno600Width in pixels (50–2000).
heightquery|bodynumberno400Height in pixels (30–2000).
scalequery|bodynumberno1Pixel ratio of PNG / JPEG (1–4), e.g. 2 for retina screens.
themequery|bodystringnolightlight or dark (also options.theme).
localequery|bodystringnoenvi for Vietnamese number format (1.234,5; 12 tr; 3 tỷ).
backgroundquery|bodystringnoBackground colour (#fff, transparent…).
svg_textquery|bodystringnopathsSVG only: paths (text as outlines) or text (<text> elements).

Example

curl "https://apibox.io.vn/v1/chart-image?c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22T1%22%2C%22T2%22%2C%22T3%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Doanh%20thu%22%2C%22data%22%3A%5B12%2C19%2C7%5D%7D%5D%7D%7D" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o output

Response

binary image/png

Use cases

  • Charts in daily report e-mails (sales, traffic, orders)
  • Images for Slack, Zalo or Telegram bot messages
  • Charts inside generated PDFs and Markdown reports
  • Sparklines and KPI images in dashboards without a JS library

FAQ

Can I use it in an <img> tag?

Yes: GET /v1/chart-image?c=<URL-encoded JSON>&api_key=… returns the PNG directly. Keep long configs in POST.

Is it compatible with Chart.js / QuickChart configs?

The common parts are: type, data.labels, datasets (label, data, backgroundColor, borderColor, fill, tension, type), indexAxis, plugins.title / legend, scales min / max / stacked.

Does Vietnamese text render correctly?

Yes, PNG and SVG draw text from the Be Vietnam Pro outlines, so diacritics are exact without any installed font.

Related APIs

Start with 1,000 free requests every month. Get free API key →