Skip to main content

Line Chart

A line chart connects values in order, which makes it the natural choice for showing how a number changes over time or across an ordered sequence.

Building a line chart

Use your time or sequence column as the first column (the labels) and the metric as the value:

SELECT
DATE(created_at) AS "Day",
COUNT(*) AS "Signups"
FROM users
GROUP BY DATE(created_at)
ORDER BY DATE(created_at);

Day runs along the x-axis and Signups is drawn as the line.

Multiple lines

Add more numeric columns to plot several lines on the same axes — useful for comparing related metrics:

SELECT
DATE(created_at) AS "Day",
COUNT(*) AS "Orders",
SUM(total) AS "Revenue"
FROM orders
GROUP BY DATE(created_at)
ORDER BY DATE(created_at);

Tips

  • Always ORDER BY your time column. A line chart connects points in row order, so unsorted rows produce a tangled line.
  • Fill gaps in the date range in SQL if you need a continuous axis — missing days otherwise collapse together.
  • If one series dwarfs the others, a mixed chart lets you pair a line with bars so both remain visible.