VISUALIZE picks the metrics to chart, the chart type and how many data
points to draw. Without it, the chart follows the shape of the result.
VISUALIZE [<metric> [TYPE <chart>], …] [MAX <n>]
VISUALIZE TYPE <chart> [MAX <n>]
Chart types
Each chart draws a set number of dimensions and metrics. A time series
counts as a dimension. When the TYPE you pick can't draw the result, the
chart shows as a table and the warning W_CHART_CANNOT_DRAW says what the
chart needs.
Stacked charts, donut, treemap, sunburst and waterfall add values
up, so they need metrics that add up, such as revenue or room nights. A
rate such as occupancy, ADR or cancellation rate doesn't add up across
groups, so these charts show it as a table.
Tables and lists
| Type | Draws | Needs |
|---|---|---|
table | every row and column of the result | anything |
list | the groups ranked by one metric, with a bar for each | 1 dimension and 1 metric |
list_with_dimension_values | the groups ranked by one metric, with the change for each | 1 dimension and 1 metric |
The change in list_with_dimension_values comes from COMPARE TO with
WITH PERCENT_CHANGE. Room types ranked by revenue, against the period
before:
FROM rooms
SHOW room_revenue
DURING last_90_days
GROUP BY room_type
COMPARE TO previous_period
WITH PERCENT_CHANGE
ORDER BY room_revenue DESC
VISUALIZE TYPE list_with_dimension_valuesSingle metric
| Type | Draws | Needs |
|---|---|---|
single_metric | one number, with the change when the query compares | no dimensions |
FROM payments
SHOW net_payments
DURING month_to_date
VISUALIZE TYPE single_metricLine and area
| Type | Draws | Needs |
|---|---|---|
line | a line for each metric, dashed for the compared period | up to 2 dimensions |
stacked_area | areas stacked to a total over time | 1 or 2 dimensions, with TIMESERIES day, week, month, quarter or year, and metrics that add up |
Revenue each day, against the month before:
FROM rooms
SHOW room_revenue
DURING last_month
TIMESERIES day
COMPARE TO previous_period
VISUALIZE TYPE lineNights sold each month, stacked by channel:
FROM rooms
SHOW room_nights_sold
DURING this_year
GROUP BY channel
TIMESERIES month
VISUALIZE TYPE stacked_areaBar charts
| Type | Draws | Needs |
|---|---|---|
bar | a bar for each group or period | up to 2 dimensions |
grouped_bar | bars side by side for each group of the second dimension, or for the compared period | 1 or 2 dimensions |
horizontal_bar | bars in rows, with the name above each bar | up to 2 dimensions |
horizontal_grouped_bar | grouped bars in rows | 1 or 2 dimensions |
stacked_bar | bars stacked by the second dimension | up to 2 dimensions, and metrics that add up |
stacked_horizontal_bar | stacked bars in rows | 1 or 2 dimensions, and metrics that add up |
single_stacked_bar | the parts of one total in a single bar | 1 dimension and 1 metric that adds up |
Nights sold each quarter, a bar for each channel:
FROM rooms
SHOW room_nights_sold
DURING this_year
GROUP BY channel
TIMESERIES quarter
VISUALIZE TYPE grouped_barNights sold each month, stacked by channel:
FROM rooms
SHOW room_nights_sold
DURING this_year
GROUP BY channel
TIMESERIES month
VISUALIZE TYPE stacked_barEach channel's part of this year's revenue:
FROM rooms
SHOW room_revenue
DURING this_year
GROUP BY channel
ORDER BY room_revenue DESC
VISUALIZE TYPE single_stacked_barPart-to-whole
| Type | Draws | Needs |
|---|---|---|
donut | each group's share of the total | exactly 1 dimension and 1 metric that adds up |
treemap | tiles sized by value, in one or two levels | 1 or 2 dimensions and 1 metric that adds up |
sunburst | the groups in an inner ring and their parts in an outer ring | exactly 2 dimensions and 1 metric that adds up |
With more than 8 groups, the groups after the first 7 join one slice named Other. A sunburst also joins slices too thin to read into Other.
FROM revenue
SHOW net_revenue, vat_amount
DURING last_month
GROUP BY revenue_category
VISUALIZE net_revenue TYPE donutRevenue by channel, and by room type inside each channel:
FROM rooms
SHOW room_revenue
DURING this_year
GROUP BY channel, room_type
VISUALIZE TYPE sunburstThe same query with TYPE treemap draws the two levels as tiles.
Heatmaps
| Type | Draws | Needs |
|---|---|---|
heatmap | a grid of the two dimensions, each cell coloured by value | exactly 2 dimensions and 1 metric |
calendar_heatmap | each day in a calendar, coloured by value | TIMESERIES day, no other dimension, and 1 metric |
Occupancy for each weekday in each month:
FROM rooms
SHOW occupancy
DURING this_year
GROUP BY day_of_week
TIMESERIES month
VISUALIZE TYPE heatmapOccupancy day by day:
FROM rooms
SHOW occupancy
DURING this_year
TIMESERIES day
VISUALIZE TYPE calendar_heatmapA calendar too narrow for the whole range shows the last weeks that fit.
Distribution and relationship
| Type | Draws | Needs |
|---|---|---|
scatter_plot | a dot for each group, the first metric across and the second up | 1 dimension and exactly 2 metrics |
bubble_chart | a scatter plot with each dot sized by a third metric | 1 dimension and exactly 3 metrics |
histogram | touching bars that show how often each value occurs | 1 dimension and 1 metric |
Rate against occupancy for each room type, sized by revenue:
FROM rooms
SHOW adr, occupancy, room_revenue
DURING this_year
GROUP BY room_type
VISUALIZE TYPE bubble_chartDrop room_revenue and use TYPE scatter_plot for dots of one size.
Bookings for each length of stay:
FROM bookings
SHOW bookings
DURING this_year
GROUP BY length_of_stay
ORDER BY length_of_stay
VISUALIZE TYPE histogramRadial
| Type | Draws | Needs |
|---|---|---|
radar | the first 3 groups as shapes, with each metric on its own axis, scaled to its largest value | 1 dimension and 2 or more metrics |
FROM rooms
SHOW adr, occupancy, revpar
DURING this_year
GROUP BY room_type
ORDER BY revpar DESC
VISUALIZE TYPE radarFunnel and running total
| Type | Draws | Needs |
|---|---|---|
funnel | each metric as a step, with the share of the step before it | no dimensions and 2 or more metrics |
waterfall | how each row adds to or takes from a running total, then the total | 1 dimension and 1 metric that adds up |
Bookings through to stays and check-ins:
FROM bookings
SHOW bookings, stays, checked_in_stays
ON booking_date
DURING this_year
VISUALIZE TYPE funnelHow each month builds the year's room revenue:
FROM rooms
SHOW room_revenue
DURING this_year
TIMESERIES month
VISUALIZE TYPE waterfallBar and line in one chart
Give a metric its own TYPE to draw it differently. A TYPE applies to
the metric it follows and to the metrics before it that have none. A metric
after the last TYPE takes that TYPE. Only bar and line mix: the
chart shows as combo, with a second axis on the right when the metrics
have different units. It draws one dimension at most.
FROM rooms
SHOW room_revenue, occupancy
DURING this_year
TIMESERIES month
VISUALIZE room_revenue TYPE bar, occupancy TYPE lineAny other mix stops the query:
FROM rooms
SHOW room_revenue, occupancy
DURING this_year
TIMESERIES month
VISUALIZE room_revenue TYPE bar, occupancy TYPE donutDraw fewer points with MAX
MAX draws the first rows of the result after ORDER BY. The table under
the chart keeps every row. The 8 room types with the most revenue:
FROM rooms
SHOW room_revenue
DURING last_90_days
GROUP BY room_type
COMPARE TO previous_period
ORDER BY room_revenue DESC
VISUALIZE TYPE horizontal_bar MAX 8MAX takes a whole number of 1 or more:
FROM rooms
SHOW room_revenue
DURING last_90_days
GROUP BY room_type
VISUALIZE TYPE list MAX 0The chart without VISUALIZE
| The query has | Chart |
|---|---|
TIMESERIES by day, week, month, quarter or year | line |
TIMESERIES by weekday, week number or month of year | bar |
one metric and no GROUP BY | single_metric |
one GROUP BY dimension | bar |
| anything else | table |
Pick the metrics
VISUALIZE charts the metrics it names, which must be in SHOW. Without
names, it charts the metrics in SHOW, up to the number the chart draws. A
query that names metrics in VISUALIZE can leave out SHOW.
Most charts draw only the metrics that share the first metric's unit, so
occupancy (a percent) and ADR (money) draw as one line. table, radar,
scatter_plot, bubble_chart and funnel draw every unit. To chart two
units, give one metric TYPE bar and the other TYPE line.
Nights sold and nights available as lines, without SHOW:
FROM rooms
DURING this_quarter
TIMESERIES week
VISUALIZE room_nights_sold, room_nights_available TYPE lineA metric VISUALIZE names must be one the query shows:
FROM rooms
SHOW occupancy
DURING last_month
VISUALIZE adr