Skip to main content

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
DataValues 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 fieldField that holds the number when Data is a list of rows.Text. Default: value
TypeShape of the chart: a line, a filled area or column bars.line, area, column. Default: line
SmoothDraws a line or area as a smooth curve instead of straight segments.On or off. Default: On
Color by trendColors 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 betterSwaps 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
ColorColor of the chart. It overrides Color by trend. Leave it empty to use the theme's primary color.Text
Value prefixText shown before the value in the tooltip, such as $.Text
Value suffixText shown after the value in the tooltip, such as % or users.Text
Empty textText 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
VisibilityShows or hides the component. Hidden components keep their space unless Collapse when hidden is on.On or off. Default: On
Collapse when hiddenRemoves the hidden component's space, so the components below it move up.On or off. Default: Off
Loading stateShows the component's loading look and blocks interaction, for example while a query runs.On or off. Default: Off
DisableStops the user from interacting with the component.On or off. Default: Off

Devices​

Property
Description
Expected Value
Show on desktopShows the component in the desktop layout.On or off. Default: On
Show on mobileShows 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 clickTriggers when the user clicks the chart.
On double clickTriggers 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 visibilityShows the component when true, hides it when false.components.sparkline1.setVisibility(false)
Set disableDisables the component when true, enables it when false.components.sparkline1.setDisable(false)
Set loadingTurns the loading state on with true, off with false.components.sparkline1.setLoading(false)

Exposed Variables​

Variable
Description
How To Access
dataValues to plot in order, as numbers such as [12, 18, 15, 22] or as rows such as [{ value: 12 }].{{components.sparkline1.data}}
valueFieldField that holds the number when Data is a list of rows.{{components.sparkline1.valueField}}
typeShape of the chart: a line, a filled area or column bars.{{components.sparkline1.type}}
smoothDraws a line or area as a smooth curve instead of straight segments.{{components.sparkline1.smooth}}
colorByTrendColors the chart green when the last value is higher than the first and red when it's lower.{{components.sparkline1.colorByTrend}}
lowerIsBetterSwaps the trend colors, so a fall is green and a rise is red, for figures such as costs or errors.{{components.sparkline1.lowerIsBetter}}
colorColor of the chart. It overrides Color by trend. Leave it empty to use the theme's primary color.{{components.sparkline1.color}}
valuePrefixText shown before the value in the tooltip, such as $.{{components.sparkline1.valuePrefix}}
valueSuffixText shown after the value in the tooltip, such as % or users.{{components.sparkline1.valueSuffix}}
emptyTextText shown when there's no data.{{components.sparkline1.emptyText}}
trendDirection from the first value to the last: up, down or flat, or empty with fewer than two values.{{components.sparkline1.trend}}
lastValueThe last value in the data.{{components.sparkline1.lastValue}}
isVisibleWhether the component is visible.{{components.sparkline1.isVisible}}
isLoadingWhether the component is in its loading state.{{components.sparkline1.isLoading}}
isDisabledWhether the component is disabled.{{components.sparkline1.isDisabled}}

Styles​

Style
Default
Primary colorTheme: Brand primary
Text colorTheme: Primary text
Container backgroundTheme: Surface 1
Border colorTheme: Default border
Border radius—
Box shadow0px 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.