Charts
Draw bar, line, area, pie, donut, scatter and histogram charts on the server, as SVG, PNG files or data URIs. Typical uses: add a chart to a report or a mail.
chart svgchart svgchart pngchart pngchart to_base64chart to_base64

chart svg <json_chart>


Description

    Draw a chart as SVG text, 640 x 400 by default. The description of the JSON is at the top of the page

Parameters

    json_chart:   The chart: a JSON object (see the top of the page) - String - required
admin
chart svg "{\"type\": \"bar\", \"title\": \"Sales\", \"categories\": [\"Jan\", \"Feb\", \"Mar\"], \"series\": [{\"name\": \"North\", \"values\": [120, 98.5, 140]}, {\"name\": \"South\", \"values\": [80, 110, 95]}], \"y_label\": \"k EUR\"}" "{\"width\": 320, \"height\": 200}"
mentdb
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="320" height="200" viewBox="0 0 320 200" role="img" font-family="Helvetica, Arial, sans-serif" aria-label="Sales"><title>Sales</title><rect x="0" y="0" width="320" height="200" fill="#ffffff"/><text x="160" y="27.6" font-size="16.8" text-anchor="middle" font-weight="bold" fill="#222222">Sales</text><rect x="108.94" y="39.3" width="9.38" height="9.38" fill="#0072b2"/><text x="123.29" y="47.86" font-size="11.04" fill="#222222">North</text><rect x="166.79" y="39.3" width="9.38" height="9.38" fill="#e69f00"/><text x="181.14" y="47.86" font-size="11.04" fill="#222222">South</text><line x1="52.94" y1="171.92" x2="309.2" y2="171.92" stroke="#e6e6e6" stroke-width="1"/><text x="46.94" y="175.7" font-size="10.8" text-anchor="end" fill="#555555">0</text><line x1="52.94" y1="62.54" x2="309.2" y2="62.54" stroke="#e6e6e6" stroke-width="1"/><text x="46.94" y="66.32" font-size="10.8" text-anchor="end" fill="#555555">200</text><text x="22.8" y="117.23" font-size="12" text-anchor="middle" transform="rotate(-90 22.8 117.23)" fill="#222222">k EUR</text><text x="95.65" y="185.42" font-size="10.8" text-anchor="middle" fill="#555555">Jan</text><text x="181.07" y="185.42" font-size="10.8" text-anchor="middle" fill="#555555">Feb</text><text x="266.49" y="185.42" font-size="10.8" text-anchor="middle" fill="#555555">Mar</text><line x1="52.94" y1="171.92" x2="309.2" y2="171.92" stroke="#888888" stroke-width="1"/><rect x="61.99" y="106.29" width="33.17" height="65.63" fill="#0072b2"/><rect x="147.4" y="118.05" width="33.17" height="53.87" fill="#0072b2"/><rect x="232.82" y="95.36" width="33.17" height="76.56" fill="#0072b2"/><rect x="96.15" y="128.17" width="33.17" height="43.75" fill="#e69f00"/><rect x="181.57" y="111.76" width="33.17" height="60.16" fill="#e69f00"/><rect x="266.99" y="119.97" width="33.17" height="51.95" fill="#e69f00"/></svg>
Complete: the start of a line chart with dates and a missing value
admin
if (equal (file exist "tmp/tuto_report") "0") {file mkdir "tmp/tuto_report";}; -> "[res]" (string left (chart svg "{\"type\": \"line\", \"title\": \"Orders per day\", \"series\": [{\"name\": \"Web\", \"x\": [\"2026-11-02\", \"2026-11-03\", \"2026-11-04\", \"2026-11-05\", \"2026-11-06\"], \"y\": [42, 51, null, 47, 60]}, {\"name\": \"Shop\", \"x\": [\"2026-11-02\", \"2026-11-03\", \"2026-11-04\", \"2026-11-05\", \"2026-11-06\"], \"y\": [30, 28, 35, 33, 31]}]}") 160); file delete "tmp/tuto_report"; [res]
mentdb
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="640" height="400" viewBox="0 0 640 400" role="img" font-family="Helvetica, Arial, sans-serif" aria-
Complete: a pie chart: its size
admin
if (equal (file exist "tmp/tuto_report") "0") {file mkdir "tmp/tuto_report";}; -> "[res]" (string length (chart svg "{\"type\": \"pie\", \"title\": \"Payment methods\", \"categories\": [\"Card\", \"Transfer\", \"Cash\"], \"values\": [62, 30, 8]}")); file delete "tmp/tuto_report"; [res]
mentdb
1594

chart svg <json_chart> <json_params>


Description

    Draw a chart as SVG text with parameters: width (640, 100 to 4000), height (400, 80 to 4000), theme (light or dark), colors (a JSON array of colours replacing the palette), background (a colour or transparent), font_family (letters, digits, spaces, commas, - and _: Helvetica, Arial, sans-serif by default; the SVG viewer chooses the font, the PNG uses the sans serif font of Java), font_size (12, 6 to 48), scale (1, 0.5 to 4: PNG pixels per unit, 2 gives a sharp image in Word or a PDF; 16 million pixels at most). scale has no effect on SVG

Parameters

    json_chart:   The chart: a JSON object (see the top of the page) - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_report") "0") {file mkdir "tmp/tuto_report";}; -> "[res]" (string left (chart svg "{\"type\": \"bar\", \"title\": \"Sales by shop\", \"categories\": [\"Jan\", \"Feb\", \"Mar\"], \"series\": [{\"name\": \"North\", \"values\": [120, 98.5, 140]}, {\"name\": \"South\", \"values\": [80, 110, 95]}], \"y_label\": \"k EUR\"}" "{\"theme\": \"dark\", \"colors\": [\"#56B4E9\", \"#E69F00\"], \"width\": 480, \"height\": 300}") 330); file delete "tmp/tuto_report"; [res]
mentdb
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="480" height="300" viewBox="0 0 480 300" role="img" font-family="Helvetica, Arial, sans-serif" aria-label="Sales by shop"><title>Sales by shop</title><rect x="0" y="0" width="480" height="300" fill="#1e1e1e"/><text x="240" y="27.6" font-size="16.8" text-anchor="middle"
A wrong colour
admin
chart svg "{\"type\": \"bar\", \"title\": \"Sales by shop\", \"categories\": [\"Jan\", \"Feb\", \"Mar\"], \"series\": [{\"name\": \"North\", \"values\": [120, 98.5, 140]}, {\"name\": \"South\", \"values\": [80, 110, 95]}], \"y_label\": \"k EUR\"}" "{\"colors\": [\"red\"]}"
mentdb
ERROR: Sorry, an error appears (the colour 0 of 'colors' must be a colour such as #0072B2).
Used in use cases (1 recipe)

    System administrator & DevOps › Read the disk space of a node exporter and draw the free space of each disk
Often used with

    prometheus parse  ·  string left  ·  string length

chart png <json_chart> <out_path>


Description

    Write a chart in a file: PNG, or SVG when the name ends with .svg. Returns {path, format, width, height, bytes} (width and height in pixels of the file)

Parameters

    json_chart:   The chart: a JSON object (see the top of the page) - String - required
    out_path:   The file to write, .png or .svg (the folders are created; an existing file is replaced; same rights as file load) - String - required
admin
if (equal (file exist "tmp/tuto_report") "0") {file mkdir "tmp/tuto_report";}; chart png "{\"type\": \"bar\", \"title\": \"Sales by shop\", \"categories\": [\"Jan\", \"Feb\", \"Mar\"], \"series\": [{\"name\": \"North\", \"values\": [120, 98.5, 140]}, {\"name\": \"South\", \"values\": [80, 110, 95]}], \"y_label\": \"k EUR\"}" "tmp/tuto_report/sales.png"; -> "[res]" (image info "tmp/tuto_report/sales.png"); file delete "tmp/tuto_report"; [res]
mentdb
{"file": "tmp/tuto_report/sales.png", "width": 640, "height": 400, "format": "png", "bytes": 12103, "megapixels": 0.26, "color_model": "rgb", "has_alpha": true, "bits_per_pixel": 32}
Complete: a histogram of raw values
admin
if (equal (file exist "tmp/tuto_report") "0") {file mkdir "tmp/tuto_report";}; -> "[res]" (chart png "{\"type\": \"histogram\", \"title\": \"Delivery time\", \"x_label\": \"days\", \"values\": [1, 2, 2, 3, 3, 3, 3, 4, 4, 5, 7, 9]}" "tmp/tuto_report/delivery.png"); file delete "tmp/tuto_report"; [res]
mentdb
{"path": "tmp/tuto_report/delivery.png", "format": "png", "width": 640, "height": 400, "bytes": 8298}
Complete: the same chart as an SVG file
admin
if (equal (file exist "tmp/tuto_report") "0") {file mkdir "tmp/tuto_report";}; -> "[res]" (chart png "{\"type\": \"pie\", \"title\": \"Payment methods\", \"categories\": [\"Card\", \"Transfer\", \"Cash\"], \"values\": [62, 30, 8]}" "tmp/tuto_report/share.svg"); file delete "tmp/tuto_report"; [res]
mentdb
{"path": "tmp/tuto_report/share.svg", "format": "svg", "width": 640, "height": 400, "bytes": 1594}

chart png <json_chart> <out_path> <json_params>


Description

    Write a chart in a file with parameters: width (640, 100 to 4000), height (400, 80 to 4000), theme (light or dark), colors (a JSON array of colours replacing the palette), background (a colour or transparent), font_family (letters, digits, spaces, commas, - and _: Helvetica, Arial, sans-serif by default; the SVG viewer chooses the font, the PNG uses the sans serif font of Java), font_size (12, 6 to 48), scale (1, 0.5 to 4: PNG pixels per unit, 2 gives a sharp image in Word or a PDF; 16 million pixels at most)

Parameters

    json_chart:   The chart: a JSON object (see the top of the page) - String - required
    out_path:   The file to write, .png or .svg (the folders are created; an existing file is replaced; same rights as file load) - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_report") "0") {file mkdir "tmp/tuto_report";}; -> "[res]" (chart png "{\"type\": \"bar\", \"title\": \"Sales by shop\", \"categories\": [\"Jan\", \"Feb\", \"Mar\"], \"series\": [{\"name\": \"North\", \"values\": [120, 98.5, 140]}, {\"name\": \"South\", \"values\": [80, 110, 95]}], \"y_label\": \"k EUR\"}" "tmp/tuto_report/sales.png" "{\"width\": 480, \"height\": 300, \"scale\": 2}"); file delete "tmp/tuto_report"; [res]
mentdb
{"path": "tmp/tuto_report/sales.png", "format": "png", "width": 960, "height": 600, "bytes": 21863}
Complete: a chart in a Word report with docx fill (the template has {{%chart}})
admin
if (equal (file exist "tmp/tuto_report") "0") {file mkdir "tmp/tuto_report";}; docx create "tmp/tuto_report/tpl.docx" "[{\"type\": \"heading\", \"level\": 1, \"text\": \"Monthly report\"}, {\"type\": \"paragraph\", \"text\": \"{{%chart}}\"}, {\"type\": \"paragraph\", \"text\": \"Source: shop database.\"}]"; chart png "{\"type\": \"bar\", \"title\": \"Sales by shop\", \"categories\": [\"Jan\", \"Feb\", \"Mar\"], \"series\": [{\"name\": \"North\", \"values\": [120, 98.5, 140]}, {\"name\": \"South\", \"values\": [80, 110, 95]}], \"y_label\": \"k EUR\"}" "tmp/tuto_report/chart.png" "{\"width\": 480, \"height\": 300, \"scale\": 2}"; -> "[res]" (docx fill "tmp/tuto_report/tpl.docx" "tmp/tuto_report/report.docx" "{\"chart\": {\"path\": \"tmp/tuto_report/chart.png\", \"width\": 480}}"); file delete "tmp/tuto_report"; [res]
mentdb
{"out_path": "tmp/tuto_report/report.docx", "replaced": 1, "unresolved": []}
Complete: a dark donut on a transparent background
admin
if (equal (file exist "tmp/tuto_report") "0") {file mkdir "tmp/tuto_report";}; -> "[res]" (chart png "{\"type\": \"donut\", \"categories\": [\"Rent\", \"Food\", \"Travel\"], \"values\": [1200, 450, 300], \"center_text\": \"1950\", \"pie_labels\": \"value\"}" "tmp/tuto_report/budget.png" "{\"theme\": \"dark\", \"background\": \"transparent\", \"width\": 360, \"height\": 240}"); file delete "tmp/tuto_report"; [res]
mentdb
{"path": "tmp/tuto_report/budget.png", "format": "png", "width": 360, "height": 240, "bytes": 10691}
Used in use cases (1 recipe)

    XML, HTML & Word integrator › Put a chart drawn on the server into a Word report
Often used with

    docx create  ·  docx fill  ·  docx to_text  ·  file delete  ·  file exist  ·  file mkdir  ·  string char

chart to_base64 <json_chart>


Description

    A chart as a PNG data URI (data:image/png;base64,...), for an img tag, an e-mail or pdf image add

Parameters

    json_chart:   The chart: a JSON object (see the top of the page) - String - required
admin
if (equal (file exist "tmp/tuto_report") "0") {file mkdir "tmp/tuto_report";}; -> "[res]" (string left (chart to_base64 "{\"type\": \"bar\", \"title\": \"Sales by shop\", \"categories\": [\"Jan\", \"Feb\", \"Mar\"], \"series\": [{\"name\": \"North\", \"values\": [120, 98.5, 140]}, {\"name\": \"South\", \"values\": [80, 110, 95]}], \"y_label\": \"k EUR\"}") 40); file delete "tmp/tuto_report"; [res]
mentdb
data:image/png;base64,iVBORw0KGgoAAAANSU
Complete: a chart in a PDF: pdf image add takes the data URI
admin
if (equal (file exist "tmp/tuto_report") "0") {file mkdir "tmp/tuto_report";}; -> "[uri]" (chart to_base64 "{\"type\": \"line\", \"title\": \"Orders per day\", \"series\": [{\"name\": \"Web\", \"x\": [\"2026-11-02\", \"2026-11-03\", \"2026-11-04\", \"2026-11-05\", \"2026-11-06\"], \"y\": [42, 51, null, 47, 60]}, {\"name\": \"Shop\", \"x\": [\"2026-11-02\", \"2026-11-03\", \"2026-11-04\", \"2026-11-05\", \"2026-11-06\"], \"y\": [30, 28, 35, 33, 31]}]}" "{\"width\": 500, \"height\": 300, \"scale\": 2}"); pdf create "tuto_chart"; pdf page add "tuto_chart" "A4" "portrait"; pdf text add "tuto_chart" 1 40 40 "Weekly orders" "font=HELVETICA_BOLD;size=16"; pdf image add "tuto_chart" 1 [uri] 40 70 500 0; pdf save "tuto_chart" "tmp/tuto_report/orders.pdf"; pdf close "tuto_chart"; -> "[res]" (concat "pages: " (pdf page_count_file "tmp/tuto_report/orders.pdf")); file delete "tmp/tuto_report"; [res]
mentdb
pages: 1

chart to_base64 <json_chart> <json_params>


Description

    A chart as a data URI with parameters: format (png or svg: data:image/svg+xml;base64,...) and width (640, 100 to 4000), height (400, 80 to 4000), theme (light or dark), colors (a JSON array of colours replacing the palette), background (a colour or transparent), font_family (letters, digits, spaces, commas, - and _: Helvetica, Arial, sans-serif by default; the SVG viewer chooses the font, the PNG uses the sans serif font of Java), font_size (12, 6 to 48), scale (1, 0.5 to 4: PNG pixels per unit, 2 gives a sharp image in Word or a PDF; 16 million pixels at most)

Parameters

    json_chart:   The chart: a JSON object (see the top of the page) - String - required
    json_params:   The parameters - String - required
admin
chart to_base64 "{\"type\": \"bar\", \"categories\": [\"A\", \"B\"], \"values\": [3, 5]}" "{\"format\": \"svg\", \"width\": 120, \"height\": 80, \"font_size\": 8}"
mentdb
data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgd2lkdGg9IjEyMCIgaGVpZ2h0PSI4MCIgdmlld0JveD0iMCAwIDEyMCA4MCIgcm9sZT0iaW1nIiBmb250LWZhbWlseT0iSGVsdmV0aWNhLCBBcmlhbCwgc2Fucy1zZXJpZiI+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEyMCIgaGVpZ2h0PSI4MCIgZmlsbD0iI2ZmZmZmZiIvPjxsaW5lIHgxPSIxOC4wMyIgeTE9IjYwLjQ4IiB4Mj0iMTEyIiB5Mj0iNjAuNDgiIHN0cm9rZT0iI2U2ZTZlNiIgc3Ryb2tlLXdpZHRoPSIxIi8+PHRleHQgeD0iMTIuMDMiIHk9IjYzIiBmb250LXNpemU9IjcuMiIgdGV4dC1hbmNob3I9ImVuZCIgZmlsbD0iIzU1NTU1NSI+MDwvdGV4dD48bGluZSB4MT0iMTguMDMiIHkxPSIxMS42IiB4Mj0iMTEyIiB5Mj0iMTEuNiIgc3Ryb2tlPSIjZTZlNmU2IiBzdHJva2Utd2lkdGg9IjEiLz48dGV4dCB4PSIxMi4wMyIgeT0iMTQuMTIiIGZvbnQtc2l6ZT0iNy4yIiB0ZXh0LWFuY2hvcj0iZW5kIiBmaWxsPSIjNTU1NTU1Ij41PC90ZXh0Pjx0ZXh0IHg9IjQxLjUyIiB5PSI2OS40OCIgZm9udC1zaXplPSI3LjIiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGZpbGw9IiM1NTU1NTUiPkE8L3RleHQ+PHRleHQgeD0iODguNTEiIHk9IjY5LjQ4IiBmb250LXNpemU9IjcuMiIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0iIzU1NTU1NSI+QjwvdGV4dD48bGluZSB4MT0iMTguMDMiIHkxPSI2MC40OCIgeDI9IjExMiIgeTI9IjYwLjQ4IiBzdHJva2U9IiM4ODg4ODgiIHN0cm9rZS13aWR0aD0iMSIvPjxyZWN0IHg9IjIzLjIzIiB5PSIzMS4xNSIgd2lkdGg9IjM2LjU5IiBoZWlnaHQ9IjI5LjMzIiBmaWxsPSIjMDA3MmIyIi8+PHJlY3QgeD0iNzAuMjEiIHk9IjExLjYiIHdpZHRoPSIzNi41OSIgaGVpZ2h0PSI0OC44OCIgZmlsbD0iIzAwNzJiMiIvPjwvc3ZnPg==
Complete: a small PNG: the start of the data URI
admin
if (equal (file exist "tmp/tuto_report") "0") {file mkdir "tmp/tuto_report";}; -> "[res]" (string left (chart to_base64 "{\"type\": \"histogram\", \"title\": \"Delivery time\", \"x_label\": \"days\", \"values\": [1, 2, 2, 3, 3, 3, 3, 4, 4, 5, 7, 9]}" "{\"width\": 200, \"height\": 120, \"font_size\": 8}") 30); file delete "tmp/tuto_report"; [res]
mentdb
data:image/png;base64,iVBORw0K
Used in use cases (1 recipe)

    PDF & document automation specialist › Build a one-page PDF of weekly KPIs with a line chart
Often used with

    file delete  ·  file exist  ·  file mkdir  ·  pdf close  ·  pdf create  ·  pdf extract_text  ·  pdf image add  ·  pdf page add