Sparkline
Ant Design
The Sparkline component is a small chart with no axes that shows the shape of a trend at a glance, such as daily sign-ups next to a key figure.
Properties​
Property | Description | Expected Value |
|---|---|---|
| Data | Values to plot in order, as numbers such as [12, 18, 15, 22] or as rows such as [{ value: 12 }]. | Array. Default: [12, 18, 15, 22, 19, 26, 24, 31] |
| Value field | Field that holds the number when Data is a list of rows. | Text. Default: value |
| Type | Shape of the chart: a line, a filled area or column bars. | line, area, column. Default: line |
| Smooth | Draws a line or area as a smooth curve instead of straight segments. | On or off. Default: On |
| Color by trend | Colors the chart green when the last value is higher than the first and red when it's lower. | On or off. Default: Off |
| Lower is better | Swaps the trend colors, so a fall is green and a rise is red, for figures such as costs or errors. | On or off. Default: Off |
| Color | Color of the chart. It overrides Color by trend. Leave it empty to use the theme's primary color. | Text |
| Value prefix | Text shown before the value in the tooltip, such as $. | Text |
| Value suffix | Text shown after the value in the tooltip, such as % or users. | Text |
| Empty text | Text shown when there's no data. | Text. Default: No data |
Additional Actions​
Each of these can be switched on or off, or set with a logical expression by clicking fx.
Property | Description | Expected Value |
|---|---|---|
| Visibility | Shows or hides the component. Hidden components keep their space unless Collapse when hidden is on. | On or off. Default: On |
| Collapse when hidden | Removes the hidden component's space, so the components below it move up. | On or off. Default: Off |
| Loading state | Shows the component's loading look and blocks interaction, for example while a query runs. | On or off. Default: Off |
| Disable | Stops the user from interacting with the component. | On or off. Default: Off |
Devices​
Property | Description | Expected Value |
|---|---|---|
| Show on desktop | Shows the component in the desktop layout. | On or off. Default: On |
| Show on mobile | Shows the component in the mobile layout. | On or off. Default: Off |
Events​
Add a handler from the Events section of the properties panel. See Event Triggers for the steps.
Event | Description |
|---|---|
| On click | Triggers when the user clicks the chart. |
| On double click | Triggers when the user double-clicks the chart. |
Component Specific Actions (CSA)​
Run these from an event handler with Control Component, or from a RunJS query. See Component Specific Actions.
Action | Description | How To Access |
|---|---|---|
| Set visibility | Shows the component when true, hides it when false. | components.sparkline1.setVisibility(false) |
| Set disable | Disables the component when true, enables it when false. | components.sparkline1.setDisable(false) |
| Set loading | Turns the loading state on with true, off with false. | components.sparkline1.setLoading(false) |
Exposed Variables​
Variable | Description | How To Access |
|---|---|---|
data | Values to plot in order, as numbers such as [12, 18, 15, 22] or as rows such as [{ value: 12 }]. | {{components.sparkline1.data}} |
valueField | Field that holds the number when Data is a list of rows. | {{components.sparkline1.valueField}} |
type | Shape of the chart: a line, a filled area or column bars. | {{components.sparkline1.type}} |
smooth | Draws a line or area as a smooth curve instead of straight segments. | {{components.sparkline1.smooth}} |
colorByTrend | Colors the chart green when the last value is higher than the first and red when it's lower. | {{components.sparkline1.colorByTrend}} |
lowerIsBetter | Swaps the trend colors, so a fall is green and a rise is red, for figures such as costs or errors. | {{components.sparkline1.lowerIsBetter}} |
color | Color of the chart. It overrides Color by trend. Leave it empty to use the theme's primary color. | {{components.sparkline1.color}} |
valuePrefix | Text shown before the value in the tooltip, such as $. | {{components.sparkline1.valuePrefix}} |
valueSuffix | Text shown after the value in the tooltip, such as % or users. | {{components.sparkline1.valueSuffix}} |
emptyText | Text shown when there's no data. | {{components.sparkline1.emptyText}} |
trend | Direction from the first value to the last: up, down or flat, or empty with fewer than two values. | {{components.sparkline1.trend}} |
lastValue | The last value in the data. | {{components.sparkline1.lastValue}} |
isVisible | Whether the component is visible. | {{components.sparkline1.isVisible}} |
isLoading | Whether the component is in its loading state. | {{components.sparkline1.isLoading}} |
isDisabled | Whether the component is disabled. | {{components.sparkline1.isDisabled}} |
Styles​
Style | Default |
|---|---|
| Primary color | Theme: Brand primary |
| Text color | Theme: Primary text |
| Container background | Theme: Surface 1 |
| Border color | Theme: Default border |
| Border radius | — |
| Box shadow | 0px 0px 0px 0px #00000040 |
A default that starts with Theme: follows the app's theme until the style is set to another value. See App Themes.