Chart to SVG/PNG
ai_chartRender bar, line, area, pie, or scatter charts offline to SVG or PNG from simple row data or a full Vega-Lite/Vega spec with inline data.
Instructions
Render a chart to an SVG or PNG file, offline. Either give a simple description ({ type: bar|line|area|pie|scatter, data: rows, x, y, color?, title? }; y may be a list of fields for multi-series line/bar charts), or a full Vega-Lite (or Vega) spec in "spec" with the rows inline in data.values. Field types are inferred (numbers = quantitative, ISO dates = temporal, other = categories). Loading data or images from URLs or files is refused. Up to 50,000 rows. PNG is rasterised from the SVG at "scale" (default 2×).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | No | Field for the x axis (the category / slice label for pie). | |
| y | No | Numeric field for the y axis (slice size for pie). A list of fields draws one series per field. | |
| data | No | Rows for the simple chart, e.g. [{"month":"Jan","sales":12}]. | |
| spec | No | A full Vega-Lite spec (or Vega, if its $schema says so). Data must be inline (data.values). Use this or "type". | |
| type | No | Simple chart type. Use with data, x and y. | |
| color | No | Optional field that splits the data into coloured series. | |
| scale | No | PNG only: pixel density multiplier (2 = twice the SVG size, sharp on high-DPI screens). Default 2. | |
| title | No | ||
| width | No | Plot width in px (default 600; pie 360). | |
| format | No | Output format: svg (default) or png. | svg |
| height | No | Plot height in px (default 360). | |
| output | No | Where to write the result: a file path, or a folder ending in "/". Default: the server output folder (a temp folder unless --out-dir is set). | |
| background | No | Background colour. Default white; "transparent" for none. | #ffffff |
| returnBase64 | No | Also return the output as base64 in the result (only for small files). Default false. |