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

Examples

Basic Usage

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

Sparkline with Color

{% sparkline
    data="demo_daily_orders"
    y="total_sales"
    x="date"
    color="blue"
/%}

Sparkline with Type

{% sparkline
    data="demo_daily_orders"
    y="total_sales"
    x="date"
    type="area"
/%}

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 displayAllowed values:
  • line
  • area
  • bar
color
string
Color of the sparkline (CSS color)
y_fmt
string
Format for y-axis tooltip (e.g., “num”, “usd”, “pct”). See Value Formatting for available formats.
x_fmt
string
Format for x-axis tooltip (e.g., “shortdate”, “longdate”). See Value Formatting for available formats.
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. Note: When used with tables, limit will disable subtotals to prevent incomplete subtotal rows.
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
options group
Use date_range to filter data for specific time periods. Accepts predefined ranges (e.g., “last 12 months”), dynamic ranges (e.g., “Last 90 days”), custom date ranges (e.g., “2020-01-01 to 2023-03-01”), or partial ranges (e.g., “from 2020-01-01”, “until 2023-03-01”)Example:
date_range={
  range = "last 7 days"
  date = "string"
}
Attributes:
  • range: string - Time period to filter. Use presets like ‘last 7 days’, dynamic patterns like ‘Last 90 days’, custom ranges like ‘2020-01-01 to 2023-03-01’, or partial ranges like ‘from 2020-01-01’.
    • Allowed values:
      • last 7 days
      • last 30 days
      • last 3 months
      • last 6 months
      • last 12 months
      • week to date
      • month to date
      • quarter to date
      • year to date
      • previous week
      • previous month
      • previous quarter
      • previous year
      • all time
  • date: string - Date column to filter on. Required when the data has multiple date columns.
date_grain
string
Time grain for date truncation (default: day for date columns)Allowed values:
  • day
  • week
  • month
  • quarter
  • year
  • hour
  • day of week
  • day of month
  • day of year
  • week of year
  • month of year
  • quarter of year
width
number
Set the width of this component (in percent) relative to the page width