Image & Canvas
canvasChartBar
$canvasChartBar
Draws a bar chart with automatic scaling and configurable bar spacing
Syntax
$canvasChartBar[x;y;width;height;data;colors;labels?;maxValue?;barSpacing?;container?]
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| x | integer | check_circle Required | — | Top-left X of chart area |
| y | integer | check_circle Required | — | Top-left Y of chart area |
| width | integer | check_circle Required | — | Chart area width |
| height | integer | check_circle Required | — | Chart area height |
| data | string | check_circle Required | — | Semicolon-separated numeric values (e.g. "120;85;200;60;150") |
| colors | string | check_circle Required | — | Semicolon-separated hex colors. One per bar; uses 12-color fallback. |
| labels | string | Optional | — | Semicolon-separated labels (accepted but not rendered at runtime) |
| maxValue | number | Optional | — | Overrides the auto-calculated maximum value for scaling |
| barSpacing | integer | Optional |
4
|
Gap between bars in pixels |
| container | string | Optional | — | Container name |
Return Value
canvas
Modifies the canvas in-place. Bars grow upward from the bottom of the chart area.
Bar width is calculated automatically by dividing the chart area width by the number of data values, minus barSpacing. Without a maxValue override, the tallest bar is scaled to fill the full chart height. Labels are parsed but not rendered — use separate $canvasDrawText calls below each bar if you need labels. Use $canvasChartLine for datasets better suited to trends over discrete categories.
Examples
Monthly members chart
$canvasChartBar[20;30;380;300;120;85;200;60;150;E53935;1E88E5;43A047;FB8C00;8E24AA;;;5]
Fixed-scale bar chart
$canvasChartBar[50;50;300;200;30;60;90;FFD700;8E24AA;00ACC1;;100;8]