Skip to content

Chart

Render query results as line, bar, pie, scatter, and histogram PNG charts with JFreeChart

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/chart/index.md to help me query Chart with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Turn SQL rows into a bar chart

The connector returns a PNG image built from the sample sales rows.

Example output · captured
Connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT png
FROM chart.main.chart_bar(
  (SELECT * FROM (VALUES
    ('Q1', 30), ('Q2', 45), ('Q3', 38), ('Q4', 60)
  ) AS sales(quarter, revenue)),
  category := 'quarter', value := 'revenue'
);
Bar chart of sample quarterly revenue: Q1 30, Q2 45, Q3 38, Q4 60.
Rendered by the Chart connector from the sample rows above.

Quick start

Choose where to run Chart, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

ATTACH 'chart' AS chart (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-chart:0.5.0'
);

3. Run a query

query.sql
SELECT png
FROM chart.main.chart_bar(
  (SELECT * FROM (VALUES
    ('Q1', 30), ('Q2', 45), ('Q3', 38), ('Q4', 60)
  ) AS sales(quarter, revenue)),
  category := 'quarter', value := 'revenue'
);
More example queries →
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

ATTACH 'chart' AS chart (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-chart:0.5.0'
);

Overview

Render charts (line/bar/pie/scatter/histogram) from a query result into PNG image BLOBs via JFreeChart

Catalog

Everything chart exposes once attached — read straight from the worker's released build.

chart 1 schema
main 1 table · 5 functions

Chart-rendering functions that turn a query result into a PNG image BLOB (line, bar, pie, scatter, histogram).

Schema examples (5)
Examples (5)

Render a line chart from inline points.

SELECT octet_length(png)
FROM chart.main.chart_line((SELECT * FROM (VALUES (1, 10), (2, 25), (3, 18)) AS t(x, y)), x := 'x', y := 'y');

Render a bar chart of category counts.

SELECT octet_length(png)
FROM chart.main.chart_bar((SELECT * FROM (VALUES ('A', 30), ('B', 45)) AS t(category, value)), category := 'category', value := 'value');

Render a pie chart of two slices.

SELECT octet_length(png)
FROM chart.main.chart_pie((SELECT * FROM (VALUES ('X', 65), ('Y', 35)) AS t(label, value)), label := 'label', value := 'value');

Render a scatter plot of numeric x/y points.

SELECT octet_length(png)
FROM chart.main.chart_scatter((SELECT * FROM (VALUES (1.0, 2.1), (2.0, 3.9)) AS t(x, y)), x := 'x', y := 'y');
1 more example

Render a 5-bin histogram of a numeric column.

SELECT octet_length(png)
FROM chart.main.chart_histogram((SELECT * FROM (VALUES (1.0), (1.5), (2.0)) AS t(value)), value := 'value', bins := 5);
Tables
chart_types 3 examples4 cols

One row per chart function this worker exposes, with its category, a one-line summary, and the column arguments it takes.

Columns
chart_typenot null VARCHAR
The chart function's SQL name, e.g. chart_line.
categorynot null VARCHAR
The chart's category in the schema's category registry.
summarynot null VARCHAR
One-line description of what the chart visualizes.
column_argumentsnot null VARCHAR
The named column arguments that select the data to plot, in call order.
ConstraintsPRIMARY KEY (chart_type)
Examples (3)

List every chart type this worker offers with its category and the column arguments it takes.

SELECT chart_type, category, column_arguments
FROM chart.main.chart_types()
ORDER BY chart_type;

Find the chart types that compare a measure across discrete categories.

SELECT chart_type, summary
FROM chart.main.chart_types()
WHERE category = 'categorical-comparisons'
ORDER BY chart_type;
SELECT chart_type, category
FROM chart.main.chart_types()
ORDER BY chart_type;
Link
Table in-out functions
chart_bar (input TABLE, category := VARCHAR, value := VARCHAR, series := VARCHAR, title := VARCHAR, width := BIGINT, height := BIGINT) 2 examples

Render a bar chart from an input relation to a PNG image BLOB (JFreeChart). With a series column, bars are grouped per series value.

Positional arguments
input TABLE
The input relation to plot. Its rows supply the bars; name the columns to use with the `category`, `value`, and optional `series` arguments.
Named arguments
category := VARCHAR
Name of the column holding the discrete category for each bar (the x-axis groups). · default "category"
value := VARCHAR
Name of the column giving each bar's height (the measure being compared across categories). · default "value"
series := VARCHAR
Optional name of a grouping column; bars are grouped with one colored bar per distinct value within each category. Empty (the default) draws a single bar per category.
title := VARCHAR
Optional chart title drawn above the plot. Defaults to empty (no title).
width := BIGINT
Width of the rendered PNG image in pixels (default 800). Larger values produce a higher-resolution chart. · default 800
height := BIGINT
Height of the rendered PNG image in pixels (default 600). Larger values produce a higher-resolution chart. · default 600
Returns columns
png BLOB
The rendered chart as a PNG image (raw bytes), ready to write to a .png file with DuckDB's COPY, embed in HTML, or hand to an image viewer.
Examples (2)

Render one bar per category and report the PNG byte size.

SELECT octet_length(png) AS bytes
FROM chart.main.chart_bar((SELECT * FROM (VALUES ('A', 30), ('B', 45), ('C', 12)) AS t(category, value)), category := 'category', value := 'value', title := 'Counts');

Render grouped bars (one group per product series) of units by quarter.

SELECT octet_length(png) AS bytes
FROM chart.main.chart_bar((SELECT * FROM (VALUES ('Q1', 30, 'Widget'), ('Q2', 42, 'Widget'), ('Q1', 18, 'Gadget'), ('Q2', 25, 'Gadget')) AS t(quarter, units, product)), category := 'quarter', value := 'units', series := 'product', title := 'Units per quarter by product');
Link
chart_histogram (input TABLE, value := VARCHAR, bins := BIGINT, title := VARCHAR, width := BIGINT, height := BIGINT) 2 examples

Render a histogram of a numeric column to a PNG image BLOB (JFreeChart), binning the values into bins equal-width buckets.

Positional arguments
input TABLE
The input relation to plot. Its rows supply the samples; name the column to bin with the `value` argument.
Named arguments
value := VARCHAR
Name of the column whose value distribution is binned and counted. · default "value"
bins := BIGINT
Number of equal-width buckets to divide the observed value range into (default 20). Values of 0 or less fall back to 20. · default 20
title := VARCHAR
Optional chart title drawn above the plot. Defaults to empty (no title).
width := BIGINT
Width of the rendered PNG image in pixels (default 800). Larger values produce a higher-resolution chart. · default 800
height := BIGINT
Height of the rendered PNG image in pixels (default 600). Larger values produce a higher-resolution chart. · default 600
Returns columns
png BLOB
The rendered chart as a PNG image (raw bytes), ready to write to a .png file with DuckDB's COPY, embed in HTML, or hand to an image viewer.
Examples (2)

Bin five values into 5 equal-width buckets and report the PNG byte size.

SELECT octet_length(png) AS bytes
FROM chart.main.chart_histogram((SELECT * FROM (VALUES (1.0), (1.5), (2.0), (2.0), (3.5)) AS t(value)), value := 'value', bins := 5, title := 'Distribution');

Render a 30-bucket histogram of request latency as a 900x500 PNG.

SELECT octet_length(png) AS bytes
FROM chart.main.chart_histogram((SELECT * FROM (VALUES (12.0), (15.0), (15.0), (22.0), (30.0), (45.0), (9.0)) AS t(latency_ms)), value := 'latency_ms', bins := 30, title := 'Latency distribution', width := 900, height := 500);
Link
chart_line (input TABLE, x := VARCHAR, y := VARCHAR, series := VARCHAR, title := VARCHAR, width := BIGINT, height := BIGINT) 2 examples

Render a line chart from an input relation to a PNG image BLOB (JFreeChart). With a series column, one line per series value.

Positional arguments
input TABLE
The input relation to plot. Its rows supply the data points; name the columns to use with the `x`, `y`, and optional `series` arguments.
Named arguments
x := VARCHAR
Name of the column to use for the x axis. An ordered or time-like column yields a continuous axis; a label column yields a category axis. · default "x"
y := VARCHAR
Name of the column whose measure is plotted on the y axis for each x position. · default "y"
series := VARCHAR
Optional name of a grouping column; one line is drawn per distinct value in this column. Empty (the default) draws a single line.
title := VARCHAR
Optional chart title drawn above the plot. Defaults to empty (no title).
width := BIGINT
Width of the rendered PNG image in pixels (default 800). Larger values produce a higher-resolution chart. · default 800
height := BIGINT
Height of the rendered PNG image in pixels (default 600). Larger values produce a higher-resolution chart. · default 600
Returns columns
png BLOB
The rendered chart as a PNG image (raw bytes), ready to write to a .png file with DuckDB's COPY, embed in HTML, or hand to an image viewer.
Examples (2)

Render a single line over numeric x/y points and report the PNG byte size.

SELECT octet_length(png) AS bytes
FROM chart.main.chart_line((SELECT * FROM (VALUES (1, 10), (2, 25), (3, 18), (4, 30)) AS t(x, y)), x := 'x', y := 'y', title := 'Trend');

Render one line per region (series) of revenue over months and report its PNG byte size.

SELECT octet_length(png) AS bytes
FROM chart.main.chart_line((SELECT * FROM (VALUES ('Jan', 100, 'East'), ('Feb', 140, 'East'), ('Jan', 80, 'West'), ('Feb', 95, 'West')) AS t(month, revenue, region)), x := 'month', y := 'revenue', series := 'region', title := 'Revenue by region');
Link
chart_pie (input TABLE, label := VARCHAR, value := VARCHAR, title := VARCHAR, width := BIGINT, height := BIGINT) 2 examples

Render a pie chart from an input relation to a PNG image BLOB (JFreeChart). One slice per distinct label; duplicate labels are summed.

Positional arguments
input TABLE
The input relation to plot. Its rows supply the pie slices; name the columns to use with the `label` and `value` arguments.
Named arguments
label := VARCHAR
Name of the column holding each slice's label. Rows that share a label are summed into a single slice. · default "label"
value := VARCHAR
Name of the column giving each slice's size (summed per distinct label). · default "value"
title := VARCHAR
Optional chart title drawn above the plot. Defaults to empty (no title).
width := BIGINT
Width of the rendered PNG image in pixels (default 800). Larger values produce a higher-resolution chart. · default 800
height := BIGINT
Height of the rendered PNG image in pixels (default 600). Larger values produce a higher-resolution chart. · default 600
Returns columns
png BLOB
The rendered chart as a PNG image (raw bytes), ready to write to a .png file with DuckDB's COPY, embed in HTML, or hand to an image viewer.
Examples (2)

Render a pie with one slice per label and report the PNG byte size.

SELECT octet_length(png) AS bytes
FROM chart.main.chart_pie((SELECT * FROM (VALUES ('Chrome', 65), ('Safari', 19), ('Firefox', 16)) AS t(label, value)), label := 'label', value := 'value', title := 'Browser share');

Render spend per category as a 700x700 pie (duplicate categories are summed).

SELECT octet_length(png) AS bytes
FROM chart.main.chart_pie((SELECT * FROM (VALUES ('Rent', 1200), ('Food', 450), ('Rent', 100), ('Travel', 300)) AS t(category, amount)), label := 'category', value := 'amount', title := 'Spend by category', width := 700, height := 700);
Link
chart_scatter (input TABLE, x := VARCHAR, y := VARCHAR, series := VARCHAR, title := VARCHAR, width := BIGINT, height := BIGINT) 2 examples

Render a scatter plot from an input relation to a PNG image BLOB (JFreeChart). With a series column, one point series per series value.

Positional arguments
input TABLE
The input relation to plot. Its rows supply the points; name the columns to use with the `x`, `y`, and optional `series` arguments.
Named arguments
x := VARCHAR
Name of the column to use for the x coordinate of each point. · default "x"
y := VARCHAR
Name of the column to use for the y coordinate of each point. · default "y"
series := VARCHAR
Optional name of a grouping column; one colored point series is drawn per distinct value. Empty (the default) draws all points in a single series.
title := VARCHAR
Optional chart title drawn above the plot. Defaults to empty (no title).
width := BIGINT
Width of the rendered PNG image in pixels (default 800). Larger values produce a higher-resolution chart. · default 800
height := BIGINT
Height of the rendered PNG image in pixels (default 600). Larger values produce a higher-resolution chart. · default 600
Returns columns
png BLOB
The rendered chart as a PNG image (raw bytes), ready to write to a .png file with DuckDB's COPY, embed in HTML, or hand to an image viewer.
Examples (2)

Render a scatter plot of numeric x/y points and report the PNG byte size.

SELECT octet_length(png) AS bytes
FROM chart.main.chart_scatter((SELECT * FROM (VALUES (1.0, 2.1), (2.0, 3.9), (3.0, 6.2)) AS t(x, y)), x := 'x', y := 'y', title := 'x vs y');

Render one colored point series per cohort of height against weight.

SELECT octet_length(png) AS bytes
FROM chart.main.chart_scatter((SELECT * FROM (VALUES (170.0, 65.0, 'A'), (180.0, 80.0, 'A'), (160.0, 55.0, 'B'), (175.0, 72.0, 'B')) AS t(height_cm, weight_kg, cohort)), x := 'height_cm', y := 'weight_kg', series := 'cohort', title := 'Height vs weight by cohort');
Link

Try these queries

Render a line chart from inline points.

SELECT octet_length(png)
FROM chart.main.chart_line((SELECT * FROM (VALUES (1, 10), (2, 25), (3, 18)) AS t(x, y)), x := 'x', y := 'y')

Uses chart_line

Render a bar chart of category counts.

SELECT octet_length(png)
FROM chart.main.chart_bar((SELECT * FROM (VALUES ('A', 30), ('B', 45)) AS t(category, value)), category := 'category', value := 'value')

Uses chart_bar

Render a pie chart of two slices.

SELECT octet_length(png)
FROM chart.main.chart_pie((SELECT * FROM (VALUES ('X', 65), ('Y', 35)) AS t(label, value)), label := 'label', value := 'value')

Uses chart_pie

Render a scatter plot of numeric x/y points.

SELECT octet_length(png)
FROM chart.main.chart_scatter((SELECT * FROM (VALUES (1.0, 2.1), (2.0, 3.9)) AS t(x, y)), x := 'x', y := 'y')

Uses chart_scatter

Render a 5-bin histogram of a numeric column.

SELECT octet_length(png)
FROM chart.main.chart_histogram((SELECT * FROM (VALUES (1.0), (1.5), (2.0)) AS t(value)), value := 'value', bins := 5)

Uses chart_histogram

List every chart type this worker offers with its category and the column arguments it takes.

SELECT chart_type, category, column_arguments
FROM chart.main.chart_types()
ORDER BY chart_type

12 more examples in the Catalog, each listed under the table or function it uses.

Chart is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.