SQLDesk

Visualizations

A visualization belongs to a query and draws its rows. One query can have many, and they all show the same data — so fixing the SQL fixes every one of them.

Choosing one

You want to showUse
Rows, as rowsTable — with per-column formatting, colouring and data bars
Something over timeLine, area, or a stat with a sparkline
Categories comparedBar or column; horizontal bars when the labels are long
The headline, in wordsSummary — a sentence with the result’s values in it, for the top of a page
One number that mattersCounter, or Gauge when there is a target or a healthy range
Parts of a wholePie for a handful of slices; a stacked bar for more
Progress toward a targetProgress bar, bullet bar, or Gauge
Status across many thingsStatus grid — one tile per row, coloured by a column
Two numbers relatedScatter, or a bubble chart with a third for size
Where something isMap (markers), or Choropleth for regions
Flow between stagesSankey, or Funnel for a conversion sequence
DistributionHistogram or box plot

A summary: the result, in a sentence

A Summary is words with the query’s values in them — the paragraph somebody would write at the top of a report, except that it is true every time the query refreshes. It spans the dashboard and sizes itself to its text, so it sits naturally as the first thing on a page.

This quarter so far: {{ revenue | currency }} from {{ orders }} orders,
{{ average_order | currency }} an order. That is {{ share_of_target | number | suffix(%) }} of target.

Whatever is between {{ and }} is a value from the result:

WriteFor
{{ revenue }}The first row’s value
{{ sum(revenue) }}Over every row: sum, avg, min, max, count — and {{ count() }} for the number of rows
{{ revenue where region = "West" }}One row, found by another column
{{ change | percent | arrow }}Formatted, left to right: currency (or currency(€)), percent (of one: 0.124 is 12.4%), number, integer, round(2), date, datetime, upper, lower, arrow for ▲ or ▼ by its sign, and prefix(…) / suffix(…) to keep a unit inside the value’s colour — {{ share | number | suffix(%) }}, or suffix(" days") quoted to keep the space

In the editor, the buttons under the text insert a column where the cursor is. A column the result does not have is not left blank: the summary says so in its place — “revnue isn’t in this result — did you mean revenue?” — and so does the editor, as you type. Values are always shown as text, so nothing in a query’s result can put anything but words on the page.

Colours are rules, one per line: a column, a test (above, below, between, is…) and what a value that passes looks like — good, bad, watch or neutral, with an arrow, a check or a warning mark if wanted. The first rule that holds wins, so “below 0 is bad” then “otherwise good” reads the way you would say it. A rule on revenue also colours sum(revenue).

The same text can be laid out three ways: as a sentence (line breaks kept), bullets (one per line), or a status line (lines joined by a dot). A summary reads one query; for a sentence about two, write one query that returns both. An agent can write one too: save_visualization with kind: "summary".

A sankey: flows between stages

One row per path through the stages: columns stage1, stage2 … as many as the funnel has, and value, how many took that path. A blank stage means the path stopped there; it is drawn flowing into Exit.

This is the drill-down: click a bar, land on the query, dashboard or system that explains it. It is configured per visualization, and the important part is that the link is built from the row — so one setting makes every point link somewhere different.

On a chart

Open the visualization editor and go to General. Tick Enable click events — until you do, the two settings under it stay greyed out and clicking a point does nothing:

Enable click events
Makes the points clickable. Nothing below works without it.
Open in new tab
Usually what you want from a dashboard somebody is watching.
URL template
A URL with placeholders filled in from the point that was clicked, for example /dashboards/12?p_region={{ @@x }}. The braces are part of it.

The placeholders are:

Values go in raw, not formatted: a tooltip may read 1.2k, but the URL gets 1200, because the other end has to be able to look it up. A placeholder that matches nothing is replaced with an empty string rather than left in the URL.

A worked example. A column chart of revenue by region, where clicking a column opens a dashboard filtered to that region:

Enable click events:  yes
Open in new tab:      yes
URL template:         /dashboards/7-regional-detail?p_region={{ @@x }}

Because {{ @@x }} is filled in per point, the North column links to North's dashboard and the South column to South's. There is no per-point configuration.

Charts have no link text setting — the whole point is clickable, and there is no label to write. Per-cell link text is a table thing, below.

On a table

A table column can be a link instead of text. In the visualization editor choose the column, set its Display as to Link, and fill in:

Note the difference from a chart: a table's placeholders are column names, with no @@ in front of them. That prefix belongs to charts, where there are no column names to use. {{ @ }} is the one shorthand here — the value of the column being displayed.

Any column of the row can be used, not only the one being displayed. A common shape is to select an id you never show, and use it to build links in the column you do.

If the link does not appear

Formatting numbers

Every numeric column and most chart values take a format string. It is applied in the browser, so it changes what is shown and never what was fetched.

Format1234567.891 becomes
0,01,234,568
0,0.001,234,567.89
0.0a1.2m
$0,0.00$1,234,567.89
0.00%applied to 0.1234 gives 12.34%
0[.]00decimals only when there are any

Thousands and decimal separators follow the organization's setting, so the same format string reads correctly for everyone.

Colouring by the value itself

A series colour says which measure a bar is. It cannot say whether the number is any good, and on a chart of variances that is the only thing anybody wants from it.

Bars on a chart

In the visualization editor, Colors → Color bars by value. Set a breakpoint and a colour for bars below it; optionally a second colour for the rest. The common setting is a breakpoint of 0 with one colour below it — negatives in red, everything else as it was.

A bar exactly at the breakpoint counts as above it, so a breakpoint of zero colours negatives and leaves a zero bar alone: it has no height to colour, and reading it as a shortfall would be wrong.

Bars only. A threshold on a line would colour its markers and leave the line itself one colour, which says less than the goal lines under Lines & Zoom — use those instead.

Telling two lines apart

Under Series, a line or area series has a Line setting: solid, dashed, dotted, fine dots, long dash or dash-dot. Use it when two series are the same measure at different times — this week against the same hour last week. Giving the comparison its own colour says it is a different thing; giving it its own pattern says it is the same thing, earlier, which is usually what the reader needs. The picker draws each pattern rather than naming it.

Bars inside table cells

On a number column, Data bar behind the number draws each value as a bar across its cell, scaled against the largest magnitude in the column. Two colours sit below it: the bar's colour, and the colour it takes below zero.

Which way a bar points depends on the column, not on a setting:

The column holdsThe bars
Only values at or above zeroGrow from the left edge, using the full width
Only values at or below zeroGrow from the right edge — the mirror of it
Values on both sidesZero sits in the middle, with a line drawn on it, and the sign is the direction

A shared zero is only worth the width it costs when there is something on both sides of it, which is why an all-positive column still gets the whole cell.

Four more settings decide how it looks:

SettingWhat it does
BarSolid paints the colour as chosen and restates the number over the bar in whichever of black or white can be read on it. Tinted is the older, paler wash — readable behind text, but a weak mark on its own.
Column widthA floor for the column, because a table sizes a column to its widest number and a bar in that much space says nothing.
Show the number on the barTurn it off to read the column as shapes. The number stays in the page for anyone using a screen reader.
Fill (under Colour the → Cell background)The same choice for a coloured cell: tinted keeps the text dark, solid paints the cell and flips the text to suit.

What the tooltip shows

Hover over a chart and the tooltip lists every series at that point, with the one under the cursor in bold and highlighted on the plot:

Stacked panels: several plots, one clock

Spend reads around 1,400, a percent change around 20 and a rate around 5. There is no single y axis on which all three can be read — put them together and two of them are flat lines along the bottom. A second y axis handles two scales; a third needs a second plot.

Under Y Axis → Panels, choose up to four. Each series then picks its panel on the Series tab. The panels share one x axis, one legend and one cursor: hovering a moment in the top panel marks the same moment in the others, which is the whole reason to stack them rather than put three charts side by side.

Use it when the series are different measures against the same clock. For the same measure broken down different ways — revenue by region, by channel, by product — the categories differ, so stacking is wrong and buttons on a dashboard widget are right.

Panels are for upright charts. A pie has no grid to divide, a heatmap builds its own, a box plot is a distribution per category, and a sideways bar chart already runs its categories down the axis the panels would cut — each of those draws as one plot whatever is set.

A chart too short to divide still draws every panel it was told to, rather than quietly collapsing to one. A taller widget is the fix, and a chart that ignored the setting would never tell you that.

When several rows share an x

A query keyed on more columns than the chart plots returns several rows per point. Keyed on region, channel and product but plotting region alone, every region arrives several times, and something has to happen to the repeats.

Something always did: they were added up, silently. That is right for money and wrong for a rate — the average of four conversion rates is a conversion rate, their sum is nothing at all.

Under General → When rows share an x:

SettingUse it for
Add them upTotals, revenue, counts of things. The default, and what every chart saved before this did.
Average themRates and ratios, where a total means nothing.
Keep the lowest / highestThe worst or best case at each point.
Count the rowsHow many rows share this x, ignoring the measure.

Two details worth knowing. An average divides by the rows that carried a number, not by the rows — counting the empty ones would read every missing reading as a zero. And a point with no readings at all is drawn as a gap rather than a zero, because zero is a claim about the measure. Counting rows is the exception: an order with no total is still an order.

Offered on column, line and area charts. A scatter or bubble chart is a point cloud and keeps every row, so collapsing it would be the bug rather than the feature.

Dates and times

Times are stored as the warehouse returned them and displayed in the organization's configured format. If a chart's x axis looks wrong by exactly some number of hours, the column is almost certainly a timestamp without a time zone — the fix belongs in the SQL, where the intent is known.