Line chart
A line chart plots numeric series against an ordered category — usually time. Each selected Y-axis column becomes its own line.
Category (X-axis)
The xAxisField column supplies the horizontal axis. Typical choices: month, week, date, or a step in a funnel that has a natural order.
Sort the query in that order (ORDER BY month). The chart does not re-sort for you.
You can format the axis (for example as a date) independently of the values.
Values (Y-axis)
yAxisFields is the list of numeric columns to plot. One column is a single line. Several columns are several lines that share the same X-axis.
Each series can have its own format (currency on revenue, number on order count).
Chart options
- Show legend — default on. Turn off for a single series with an obvious title.
- Smooth lines — interpolates between points. Leave off when the values are discrete months or steps.
Example query
SELECT
date_trunc('month', created_at) AS month,
SUM(amount) AS revenue,
COUNT(*) AS orders
FROM orders
WHERE account_id = :customer_id
GROUP BY 1
ORDER BY 1
Map Category (X-axis) to month and Values (Y-axis) to revenue and orders.
Related
- Stacked line chart when series should stack to a total
- Combo chart when one series should be bars
- Bar chart for unordered categories