Skip to content

Chart

The Chart widget turns an SQL query into a line, bar or pie chart: revenue per month, orders per customer, shares per status. Viewers see legend and tooltips and, if configured, choose the time range themselves.

Chart widget Umsatz je Kunde (revenue per customer) as a bar chart with the series netto and brutto per customer and a legend at the bottom
Bar chart with two value columns and legend.

Setting up

Configure chart leads through the setup in steps; each step has Next, Apply saves as soon as type, query and mapping are complete.

  1. Type: Line, Bar or Pie chart. Switching resets the mapping.
  2. Data: the SQL query. For line and bar it returns one category column and one or more value columns (SELECT monat, umsatz, kosten FROM …), for the pie exactly one label and one value (SELECT status, anzahl FROM …). Test runs the query and shows the columns and the first rows; without a successful test with at least one row there is no going further.
  3. Mapping: for line and bar X axis (category) and under Y axis (values) one or more columns as chips, one series per column with the column name in the legend. For the pie Label and Value.
  4. Display: Chart title, Show legend (on), Smoothed lines, Stacked (line and bar), Horizontal (bar only), X axis label, Y axis label, Y axis unit such as € or h, which is appended to the axis values. A preview shows the result immediately.
  5. Time range: appears only if the query contains @periodStart and @periodEnd. Here the offered periods and the Default time range are defined.
Dialog Configure chart in the step Data with the note on category and value columns, the tip on @periodStart and @periodEnd, the SQL query Umsatz je Kunde and the button Test
Step “Data”: note, time range tip, query and Test.
Dialog Configure chart in the step Mapping with X axis (category) kunde and the selected Y axis values netto and brutto
Step “Mapping”: one category, several values.

The robot icon in the dialog opens the SQL assistant, which proposes a query from a description.

What the query must return

  • The order of the rows is the order on the axis: for time series ORDER BY monat.
  • Value columns must be numbers; text is drawn as 0.
  • With more than ten categories the labels are slanted. LIMIT helps for top lists.
  • Time ranges: WHERE datum >= date(@periodStart) AND datum < date(@periodEnd), details under SQL in widgets.

On the dashboard

Legend at the bottom, tooltip on hover, the pie as a ring. With a configured time range, the time range button is at the top; the browser remembers the choice per viewer. If the query returns no rows, the widget reads No data available. The chart loads when the dashboard opens, on Refresh dashboard and via the refresh icon in the header.

Example

Revenue per customer as bars, net and gross side by side:

sql SELECT COALESCE(c.document_name, '-') AS kunde, SUM(i.app_net_total) AS netto, SUM(i.app_gross_total) AS brutto FROM app_invoices i LEFT JOIN app_contacts c ON c.id = i.app_recipient GROUP BY 1 ORDER BY 3 DESC

Type Bar, X axis kunde, Y axis netto and brutto, Y axis unit €.

Frequently asked questions

“Next” is grayed out in the step Data.

Test first. The mapping needs the columns from the test run, and the query must return at least one row.

Can colors be chosen?

Not in the dialog; the series get the colors of the color scheme in order. A connected AI assistant can set the widget setting colorPalette.

The pie chart shows only one area.

The query returns only one row, or all values except one are 0. The pie needs one row per share.

Months appear in the wrong order.

The axis follows the row order. Sort by a date column, not by the month name, and build the label only afterwards.

Next step

Heatmap: values as colored cells across hours, days, months or two categories.