How to :: add sparklines to your charts¶
Sparklines are used to represent the trend of a metric with a small line.
They are available for :
- horizontal barcharts
- leaderboards centered average
Sparklines are setup in two steps:
- define an historical dataset
- configure the sparkline parameter
Define an historical dataset¶
For the data in the sparklines to match your labels, Toucan needs to understand the relationship between two datasets:
- the one from your chart
- the one from your sparklines
You need to add a
history block in your dataset configuration from
the code mode.
datasets: my_dataset: query: [...] [...] history: data: query: domain: "sparklines-formation" joins: [ "Label" ]
data attribute, you have to specify the
query needed to
retrieve the historical data, what data source contains your sparkline
All parameters available for querying a dataset are available there:
joins specifies a list of columns to match dataset rows with their
For example, a historical/sparkline dataset could look like:
and could be joined on the
"Label" column with a chart dataset like:
Filters can be applied to the history dataset. Make sure to add the column filter’s name in the join parameter.
Set up sparklines in the chart parameters¶
Switch back to the visual mode of the studio and make sure you are on a compatible chart parameters menu.
Just follow the steps to add your sparklines and make sure to use the preview to test what you’re building!