Example

{% line_chart 
	data="demo_daily_orders" 
	x="date" 
	y="sum(total_sales)" 
	date_grain="month"
	date_range={
		date="date"
		range="last 12 months"
	}
/%}

Attributes

data
String
required
Name of the table to query
filters
Array
default:"[]"
Array of column names to use as filters
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)
x
String
required
Column name for x-axis
x_fmt
String
Format for x values and axis labels
y_fmt
String
Format for x values and axis labels
y2_fmt
String
Format for x values and axis labels
series
String
Column name for series
size
String
Column name for size
title
String
Title to display above the chart
subtitle
String
Subtitle to display below the title
info
String
Information tooltip text (can only be used with title)
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
width
Number
Set the width of this component (in percent) relative to the page width
y_axis_options
default:"{}"
Configure the y-axisExample:
y_axis_options={
  title = "string"
  ticks = true
  baseline = true
  labels = true
  gridlines = true
  min = 0
  max = 0
  fit_to_data = true
}
Attributes:
  • title: string
  • ticks: boolean
  • baseline: boolean
  • labels: boolean - Show/hide axis labels
  • gridlines: boolean - Show/hide gridlines
  • min: number - Minimum value for this axis
  • max: number - Maximum value for this axis
  • fit_to_data: boolean - Fit the axis to the data instead of including 0
y2_axis_options
default:"{}"
Configure the secondary y-axisExample:
y2_axis_options={
  title = "string"
  ticks = true
  baseline = true
  labels = true
  gridlines = true
  min = 0
  max = 0
  fit_to_data = true
}
Attributes:
  • title: string
  • ticks: boolean
  • baseline: boolean
  • labels: boolean - Show/hide axis labels
  • gridlines: boolean - Show/hide gridlines
  • min: number - Minimum value for this axis
  • max: number - Maximum value for this axis
  • fit_to_data: boolean - Fit the axis to the data instead of including 0
x_axis_options
default:"{}"
Configure the x-axisExample:
x_axis_options={
  title = "string"
  label_wrap = true
  ticks = true
  baseline = true
  labels = true
  gridlines = true
  min = 0
  max = 0
  fit_to_data = true
}
Attributes:
  • title: string
  • label_wrap: boolean
  • ticks: boolean
  • baseline: boolean
  • labels: boolean - Show/hide axis labels
  • gridlines: boolean - Show/hide gridlines
  • min: number - Minimum value for this axis
  • max: number - Maximum value for this axis
  • fit_to_data: boolean - Fit the axis to the data instead of including 0
chart_options
Example:
chart_options={
  color_palette = []
}
Attributes:
  • color_palette: array
y
String | Array
required
Column name for y-axis
fmt
String
Format for this series’ values
data_labels
default:"{}"
Label each point in the series with its valueExample:
data_labels={
  position = value
  fmt = value
  size = 0
  distance = 0
  rotate = 0
  color = "string"
  show_overlap = true
}
Attributes:
  • position: effects - Position the label relative to its data point
  • fmt: enum - Format the label value. Defaults to series or axis fmt.
  • size: number - Font size in px
  • distance: number - How far the label is from the data point
  • rotate: number - Rotate each label (degrees)
  • color: string - Change the text color of the labels
  • show_overlap: boolean - Show labels for every point even when they overlap
y2
String | Array
Column name for secondary y-axis
line_options
default:"{}"
Example:
line_options={
  color = "string"
  width = 0
  type = value
  opacity = 0
  markers = { ... }
  step = value
}
Attributes:
  • color: string
  • width: number - Width of the line
  • type: enum
  • opacity: number - Between 0 and 1
  • markers: object
  • step: enum - Show a stepped line rather than a smooth line between points and control where the step happens (start, middle, or end)