Skip to content
In this guide

Guide · Doing

Chart a query result

5 min read

Checked on 0.6.1

A grid of about 120 rows tells you each day's count per channel. It does not show you whether web orders dip at weekends while the other three channels hold steady. Open a chart when the question is about shape: a trend over days, which of 40 stores carries the revenue, how order totals spread. Stay in the grid when you need exact values or the row behind one.

Draw the chart

  1. Run an aggregate in a SQL tab. Orders per day for the last 30 days, split by channel:

    SQL
    SELECT date_trunc('day', placed_at) AS day,
           channel,
           count(*) AS orders
    FROM   commerce.orders
    WHERE  placed_at >= now() - interval '30 days'
    GROUP  BY 1, 2
    ORDER  BY 1;

    The result pane shows Result, Chart and Plan. Chart carries a small sparkline of what it would draw. When the result has nothing to chart, the button is dimmed and its tooltip says Nothing to chart.

  2. Click Chart. Seqora draws a line per channel: day on the X axis, orders up the side, one coloured series for each of the four channels and a legend above the plot.

  3. Hover the plot. A dashed line snaps to the nearest day, and a card lists that date and each channel's count. Axis labels are compact (12k, 1.5M). The card shows the full value.

The Chart view of orders per day over 30 days, four channel lines, the legend above, and the hover card on one day listing each channel's orders.

The x, y and split chips read day, orders and channel. Line is pressed.

  1. Change the chart with the chips in the header. x picks the axis column, y picks the measure, split picks the column whose values become series, or None. The type buttons switch between Line, Area, Bar, Scatter, Number and Histogram. With a split, Area and Bar stack the channels.

  2. Click a channel in the legend to hide it. The axis rescales to what is left. Click it again to bring it back.

  3. Copy the chart with Copy image (a PNG at twice the size on screen) or Copy SVG. The copy carries a title, orders by day here, the visible legend entries, and a footer with the connection name and the time you copied it. The hover line and card are left out.

Run the query again and the chart keeps your choices, as long as the result has the same column names. Change the columns and Seqora picks again. The choices last until you quit Seqora. A tab that was on Chart stays on Chart when you run it again.

How Seqora picks what to draw

Seqora reads the column types and a sample of up to 200 cells per column. Each column becomes one of four things:

Column Counts as Example
date, timestamp, timestamptz time day
integer, numeric, float number orders, revenue_cents
text, boolean category channel, store
time, interval, jsonb, anything else not charted

A text column where every sampled cell is an ISO date counts as time, so to_char(placed_at, 'YYYY-MM-DD') charts as dates. A number column counts only when 90% of its sampled cells parse as numbers.

Then it picks the first rule that fits:

  • One row, no time column: Number, each measure as a large figure.
  • A time column: Line over time. A category column with 12 or fewer distinct values becomes the split.
  • A category column: Bar, one bar per value, in the order the query returned them.
  • Two number columns: Line when the first one ascends, Scatter when it doesn't.
  • One number column, many rows: Histogram of its values.

A number column named id or ending in _id, such as store_id, is not picked as the measure. It counts rows and measures nothing.

Revenue by store shows the bar rule:

SQL
SELECT s.name AS store,
       sum(o.total_cents) AS revenue_cents
FROM   commerce.orders o
JOIN   commerce.stores s ON s.id = o.store_id
GROUP  BY s.name
ORDER  BY revenue_cents DESC;

commerce.stores has 40 rows under 24 names, so the chart draws 24 bars. A bar chart draws at most 30. Past that, Seqora keeps the 30 categories with the largest totals and the header says how many it kept out of how many there were.

A bar chart of revenue_cents by store name, 24 bars from largest to smallest.

A type button that doesn't fit the columns stays dimmed, and its tooltip says why: Histogram: A histogram needs at least two rows to show a spread., Number: Big numbers show a single row or a time series. Number on a time series shows the latest value with a sparkline under it.

When there is nothing to chart

A result with no number column, such as SELECT email, country FROM crm.customers, has nothing to measure. Chart stays dimmed. If the tab was already on Chart when you ran it, the view says Nothing to chart and Charts need a number column, with a time or text column to plot it against.

The Chart view after a query with only text columns, an empty state reading Nothing to chart.

Caveats

  • The chart reads at most 10,000 rows. Past that it draws the first 10,000 and the header says 10,000 of N rows. The result itself keeps 10,000 rows by default (see the row cap), so aggregate in SQL rather than charting raw rows.
  • A filter in Result narrows the chart too. The header then reads N of M rows.
  • Rows that share an X value are added together, and a Σ mark appears with Rows with the same day are summed. Group in the query if you meant something other than a sum.
  • A split draws at most eight series. The values with the smallest totals fold into one series called other. y draws at most six measures, and All numbers picks them all.
  • A NULL measure leaves a gap in a line or area, so a missing day reads as missing. A NULL time or number on the X axis drops that row. A NULL category becomes a bar labelled NULL.
  • Times are plotted as the database printed them, in the session time zone. A daylight saving change inside the range can shift a point by an hour.
  • Charts work on SQL results on every engine Seqora connects to. A table tab has no Chart. Run a SELECT instead, or watch the table to see its rows change.

Last checked against Seqora 0.6.1, PostgreSQL 17 on .

Bugs and small complaints both go to this address. I read every email myself.