Example

{% sparkline 
	data="demo_daily_orders"
	x="date"
	date_grain="month"
	y="total_sales"
	date_range={
		date="date"
		range="last 12 months"
	}
/%}

Attributes

data
String
required
Table or view to query
x
String
required
Column for x-axis (often date/time)
y
String
required
Column for y-axis (values to plot)
type
String
default:"line"
Type of sparkline to display
color
String
Color of the sparkline (CSS color)
y_fmt
String
Format for y-axis tooltip (e.g., “num”, “usd”, “pct”)
x_fmt
String
Format for x-axis tooltip (e.g., “shortdate”, “longdate”)
fit_to_data
Boolean
default:"false"
Whether to scale the y-axis to the data range
interactive
Boolean
default:"true"
Whether the sparkline should be interactive
filters
Array
IDs of filters to apply to the query
where
String
Custom SQL WHERE condition to apply to the query. For date filters, use date_range instead.
having
String
Custom SQL HAVING condition to apply to the query after GROUP BY
limit
Number
Maximum number of rows to return from the query
order
String
Column name(s) with optional direction (e.g. “column_name”, “column_name desc”)
qualify
String
Custom SQL QUALIFY condition to filter windowed results
date_range
Use date_range to filter data for specific time periods like last 12 months, year-to-date, etcExample:
date_range={
  range = value
  date = "string"
}
Attributes:
  • range: enum
  • date: string
date_grain
String
Time grain for date truncation (default: day for date columns)
width
Number
Set the width of this component (in percent) relative to the page width