Title, axis title, zero baseline.
WiseMetering · Reference
Chart generator
An HTTP service that turns Google Charts ChartWrapper JSON into PNG or SVG images. It renders ColumnChart, BarChart, PieChart and BubbleChart the way Google Charts does, without a browser and without network access.
Questions, API keys or problems with a chart: charts@wisemetering.com.
Vertical bars and lines, on one or two value axes, optionally stacked.
Horizontal bars: categories top to bottom, values along the bottom.
Pie or donut, with percentages in the slices and a legend beside, below or around it.
Bubbles placed by x and y, colored by group and sized by a value.
Request
POST / with Content-Type: application/json:
{
"args": {
"chartType": "ColumnChart",
"dataTable": [["Month", "kWh"], ["Jan", 1250], ["Feb", 1130]],
"options": {"width": 800, "height": 350, "colors": ["#688715"]}
},
"format": "png",
"forceUncutLine": false
}| Field | Description |
|---|---|
args.chartType | ColumnChart, BarChart, PieChart or BubbleChart. |
args.dataTable | Rows of data; the first row is the header. See each chart. |
args.options | Google Charts options; the supported ones are listed in Options for every chart and in each chart's section. Others are ignored. |
format | png (a data:image/png;base64,… string) or svg (markup). Default svg. |
forceUncutLine | true keeps the names of a pie's labeled legend on one line; otherwise long names wrap. |
When API keys are required, send one as Authorization: Bearer <key>. GET /up and GET /health answer {"status":"ok"} (and GET /ping, ping, as the Node service did).
Responses
| Status | When | Body |
|---|---|---|
| 200 | The chart was rendered | The PNG data URI or the SVG |
| 400 | The chart couldn't be rendered | {"error": "<message>"}, see Errors |
| 401 | API keys are required (AUTH=required) and the request has no valid Authorization: Bearer <key> | {"error": "unauthorized", "message": "missing or invalid API key", "hint": "…"}, with WWW-Authenticate: Bearer |
| 404 | Unknown path | {"error": "not_found", "message": "no such endpoint", "hint": "…"} (a page for browsers) |
| 405 | Known path, wrong method | {"error": "method_not_allowed", "message": "…"} |
Errors
Messages of 400 responses:
| Message | Cause |
|---|---|
request body too large | The body is over 10 MB. |
invalid JSON body: <details> | The body isn't valid JSON. |
[InputError] unsupported format | format is neither png nor svg. |
[InputError] chartOptions should be an object containing Google ChartWrapper options | args is missing or isn't an object. |
[RenderingError] The chart type is not defined. | args.chartType is missing. |
[RenderingError] unsupported chartType <type> | The chart type isn't one of ColumnChart, BarChart, PieChart, BubbleChart. |
[RenderingError] The data table is not defined. | args.dataTable is missing or isn't an array. |
[RenderingError] Table has no columns. | The header row is missing or isn't an array. |
[RenderingError] Data column(s) for axis #0 cannot be of type string | The header has only the label column, no series. |
[RenderingError] Every row given must be either null or an array. | A data row isn't an array. |
[RenderingError] Data table has no rows with numeric x and y | BubbleChart without any row with numeric x and y. |
[RenderingError] internal error while rendering the chart | A bug in the renderer. It is logged as ERROR with the request; the service keeps running. |
Options for every chart
Options may be null; numbers may be strings ("50") and sizes percentages ("80%"). Colors are #rrggbb, #rgb, transparent or basic names.
| Option | Type | Default | Description |
|---|---|---|---|
width | number | 600 | Image width in px, capped at 4096. |
height | number | 400 | Image height in px, capped at 4096. |
backgroundColor | color or {fill} | #ffffff | Background; "transparent" keeps the PNG transparent. |
backgroundColor.fill | color | Same as a color given directly. | |
colors | array of colors | Google's palette | Colors of the series (pie: slices; bubble: groups), cycled when there are more series than colors. |
fontSize | number | derived from the size | Base font size. By default 12 + (width + height − 790) / 315, rounded up from .6, as Google does. |
chartArea.left | px or % | centered | Left edge of the plot area. |
chartArea.top | px or % | centered | Top edge of the plot area. |
chartArea.width | px or % | 61.8% (wider on wide charts) | Plot area width. |
chartArea.height | px or % | 61.8% | Plot area height. |
title | string | Chart title, bold, above the plot area. | |
titleTextStyle | text style | bold, black | Style of the title. |
legend | string or object | {position: "right"} | A position string, or an object with position and textStyle. |
legend.position | string | right | bottom, top, right or none (pie charts also labeled). |
legend.textStyle | text style | #222222 | Style of the legend entries. |
Text styles
Every textStyle and titleTextStyle accepts:
| Option | Type | Default | Description |
|---|---|---|---|
fontSize | number | chart font size | Font size in px (at most 200). |
color | color | depends on the text | Text color. |
bold | boolean | false (titles: true) | Bold text. "true"/"false" strings are accepted. |
italic | boolean | false | Italic text. |
Text is always drawn in DejaVu Sans.
Chart
ColumnChart
Vertical bars and lines, on one or two value axes, optionally stacked.
Data
- First row: header. First column: category labels (strings); each following column is a series.
- A
{"role": "style"}header after a series colors each bar:"#hex"or"color: #hex"(empty = series color). - A
{"role": "annotation"}header after a series adds text above each bar. nullleaves a gap: no bar, or a break in a line. Numbers may be strings.
Options
Besides the options for every chart:
| Option | Type | Default | Description |
|---|---|---|---|
vAxis.minValue | number | Extends the axis to include this value. | |
vAxis.maxValue | number | Extends the axis to include this value ("automatic" is ignored). | |
vAxis.baseline | number | Value that must be on the axis; 0 makes bars start at zero. | |
vAxis.viewWindow.min | number | Fixed axis start (with viewWindow.max). | |
vAxis.viewWindow.max | number | Fixed axis end (with viewWindow.min). | |
vAxis.format | string | #,##0 (en) | Number format of the tick labels, e.g. #,##0.##. |
vAxis.gridlines.color | color | #cccccc | Major gridlines; transparent hides them. |
vAxis.minorGridlines.color | color | 60% towards the background | Minor gridlines, one between majors. |
vAxis.textStyle | text style | #444444 | Style of the tick labels. |
vAxis.title | string | Title of the left axis, rotated. | |
vAxis.titleTextStyle | text style | #222222 | Style of the axis titles. |
vAxis.textPosition | string | out | none hides the tick labels. |
vAxis.baselineColor | color | #333333 | Line at zero; transparent hides it. |
vAxes.N | object | Overrides vAxis for axis N (0 = left, 1 = right): any of the vAxis keys above. | |
vAxes.N.title | string | Title of axis N. | |
hAxis.textStyle | text style | #222222 | Style of the category labels. |
hAxis.textColor | color | Color of the category labels (overrides textStyle.color). | |
hAxis.textPosition | string | out | none hides the category labels. |
hAxis.slantedText | boolean | false | Rotates the category labels; crowded ones are thinned out. |
hAxis.slantedTextAngle | number | 30 | Rotation in degrees (up to 90). |
series.N.type | string | bars | bars or line (area and steppedArea are drawn as lines). |
series.N.targetAxisIndex | number | 0 | 0 = left axis, 1 = right axis. |
series.N.color | color | colors[N] | Color of series N. |
series.N.lineWidth | number | 2 | Line width in px; 0 hides the line. |
series.N.lineDashStyle | array of numbers | Dash pattern, e.g. [6, 4]. | |
series.N.visibleInLegend | boolean | true | Lists the series in the legend. |
lineWidth | number | 2 | Line width of every line series. |
isStacked | boolean | false | Stacks the bars of each axis; lines are not stacked. |
bar.groupWidth | px or % | 61.8% | Width of a category's bars. |
annotations.textStyle | text style | bar color, darkened | Style of annotation texts. |
annotations.stem.length | number | 12 | Length of the line between a bar and its annotation. |
Examples
Several series side by side, legend at the bottom, vAxis.format.
isStacked, legend on top.
series.N.type, targetAxisIndex, lineDashStyle, labels at 90°.
style and annotation roles, hidden value axis.
Chart
BarChart
Horizontal bars: categories top to bottom, values along the bottom.
Data
- Same as ColumnChart: labels, then series, with optional style and annotation role columns.
- Negative values extend left of the baseline.
Options
Besides the options for every chart:
| Option | Type | Default | Description |
|---|---|---|---|
hAxis.minValue | number | Extends the axis to include this value. | |
hAxis.maxValue | number | Extends the axis to include this value ("automatic" is ignored). | |
hAxis.baseline | number | Value that must be on the axis; 0 makes bars start at zero. | |
hAxis.viewWindow.min | number | Fixed axis start (with viewWindow.max). | |
hAxis.viewWindow.max | number | Fixed axis end (with viewWindow.min). | |
hAxis.format | string | #,##0 (en) | Number format of the tick labels, e.g. #,##0.##. |
hAxis.gridlines.color | color | #cccccc | Major gridlines; transparent hides them. |
hAxis.minorGridlines.color | color | 60% towards the background | Minor gridlines, one between majors. |
hAxis.textStyle | text style | #444444 | Style of the tick labels. |
hAxis.textColor | color | Color of the value labels; transparent hides them. | |
hAxis.textPosition | string | out | none hides the value labels. |
hAxis.baselineColor | color | #333333 | Line at zero. |
vAxis.textPosition | string | out | Category labels: out (left of the bars), in (inside the plot area) or none. |
vAxis.textStyle | text style | #222222 | Style of the category labels. |
vAxis.textColor | color | Color of the category labels. | |
bar.groupWidth | px or % | 61.8% | Height of a category's bars. |
annotations.textStyle | text style | bar color, darkened | Style of annotation texts, drawn after the bar (or the baseline, for negative values) with a 12px stem. |
Examples
Labels left of the bars, value axis at the bottom.
Negative values, viewWindow, labels inside, colors per bar, annotations.
Chart
PieChart
Pie or donut, with percentages in the slices and a legend beside, below or around it.
Data
- Rows of
[label, value]. Negative values count as zero. - With legend
labeled, names that don't fit beside the pie wrap onto several lines unless the request has"forceUncutLine": true.
Options
Besides the options for every chart:
| Option | Type | Default | Description |
|---|---|---|---|
pieHole | number | 0 | Hole size from 0 (pie) to 0.95 (thin donut). |
pieSliceText | string | percentage | percentage or none. Percentages that don't fit in their slice are left out. |
pieSliceTextStyle | text style | #ffffff | Style of the percentages. |
sliceVisibilityThreshold | number | 1/720 | Slices below this fraction of the total merge into one slice; 0 keeps all. |
pieResidueSliceLabel | string | Other | Label of the merged slice. |
pieResidueSliceColor | color | #cccccc | Color of the merged slice. |
legend.position | string | right | right, labeled (name and percentage beside each slice, with a leader line), bottom, top or none. |
Examples
Percentages inside, legend on the right, title.
pieHole, legend labeled, small slices merged.
pieHole 0.5, legend bottom.
Chart
BubbleChart
Bubbles placed by x and y, colored by group and sized by a value.
Data
- Rows of
[id, x, y, group, size]; group and size are optional. idis drawn on the bubble. Rows without numeric x and y are skipped.- Each distinct group gets the next color and a legend entry.
- The radius goes from 5 to 30 px, with the bubble area linear in size.
Options
Besides the options for every chart:
| Option | Type | Default | Description |
|---|---|---|---|
hAxis.minValue | number | Extends the axis to include this value. | |
hAxis.maxValue | number | Extends the axis to include this value ("automatic" is ignored). | |
hAxis.baseline | number | Value that must be on the axis; 0 makes bars start at zero. | |
hAxis.viewWindow.min | number | Fixed axis start (with viewWindow.max). | |
hAxis.viewWindow.max | number | Fixed axis end (with viewWindow.min). | |
hAxis.format | string | #,##0 (en) | Number format of the tick labels, e.g. #,##0.##. |
hAxis.gridlines.color | color | #cccccc | Major gridlines; transparent hides them. |
hAxis.minorGridlines.color | color | 60% towards the background | Minor gridlines, one between majors. |
hAxis.textStyle | text style | #444444 | Style of the tick labels. |
hAxis.title | string | Title below the horizontal axis. | |
hAxis.titleTextStyle | text style | #222222 | Style of the horizontal axis title. |
vAxis.minValue | number | Extends the axis to include this value. | |
vAxis.maxValue | number | Extends the axis to include this value ("automatic" is ignored). | |
vAxis.baseline | number | Value that must be on the axis; 0 makes bars start at zero. | |
vAxis.viewWindow.min | number | Fixed axis start (with viewWindow.max). | |
vAxis.viewWindow.max | number | Fixed axis end (with viewWindow.min). | |
vAxis.format | string | #,##0 (en) | Number format of the tick labels, e.g. #,##0.##. |
vAxis.gridlines.color | color | #cccccc | Major gridlines; transparent hides them. |
vAxis.minorGridlines.color | color | 60% towards the background | Minor gridlines, one between majors. |
vAxis.textStyle | text style | #444444 | Style of the tick labels. |
vAxis.title | string | Title of the vertical axis, rotated. | |
vAxis.titleTextStyle | text style | #222222 | Style of the vertical axis title. |
bubble.textStyle | text style | black, chart font size | Style of the bubble labels. |
Examples
Groups, sizes, axis titles, legend at the bottom.
Try it
Playground
Edit a request and render it with this service. It is sent to POST / as is.

