Skip to main content

Sparkline

Rocket 2.0

The Sparkline component is a tiny chart with no axes or grid that shows the shape of a trend at a glance, such as daily sales next to a KPI or a table cell.

Properties​

Property
Description
Expected Value
DataValues to draw, as a list of numbers or as { x, y } objects.Array. Default: [12, 18, 15, 22, 19, 26, 24, 31]
TypeDraw the values as a line, a filled area or bars.line, area, bar. Default: area
CurveHow points are joined: a smooth curve (monotone), straight lines (linear) or steps (step).monotone, linear, step. Default: monotone
Line width (px)Thickness of the line in pixels.Number. Default: 2
End dotMarks the last value with a dot.On or off. Default: On
Color by trendColors the chart green when the last value is better than the first, and red when it is worse.On or off. Default: Off
Lower is betterTreats a fall as good, for measures such as costs or response times. Affects Color by trend and the trend value.On or off. Default: Off
Min/max bandShades a horizontal band behind the chart, from Band from to Band to, such as a normal or target range.On or off. Default: Off
Band from (blank = data min)Bottom of the band. Leave empty to start at the lowest value.Text
Band to (blank = data max)Top of the band. Leave empty to end at the highest value.Text
TooltipShows the value under the pointer in a tooltip.On or off. Default: Off
Value prefixText shown before values in the tooltip, such as $.Text
Value suffixText shown after values in the tooltip, such as %.Text
Empty messageMessage shown when there is no data to draw.Text. Default: No data
AnimateAnimates the chart when it first draws or its data changes.On or off. Default: On
Loading lookWhat shows while the chart is loading: a spinner or a skeleton block.Spinner, Skeleton. Default: Spinner

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 sparkline.
On double clickTriggers when the user double-clicks the sparkline.

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 draw, as a list of numbers or as { x, y } objects.{{components.sparkline1.data}}
typeDraw the values as a line, a filled area or bars.{{components.sparkline1.type}}
curveHow points are joined: a smooth curve (monotone), straight lines (linear) or steps (step).{{components.sparkline1.curve}}
strokeWidthThickness of the line in pixels.{{components.sparkline1.strokeWidth}}
showEndDotMarks the last value with a dot.{{components.sparkline1.showEndDot}}
colorByTrendColors the chart green when the last value is better than the first, and red when it is worse.{{components.sparkline1.colorByTrend}}
lowerIsBetterTreats a fall as good, for measures such as costs or response times. Affects Color by trend and the trend value.{{components.sparkline1.lowerIsBetter}}
showBandShades a horizontal band behind the chart, from Band from to Band to, such as a normal or target range.{{components.sparkline1.showBand}}
bandMinBottom of the band. Leave empty to start at the lowest value.{{components.sparkline1.bandMin}}
bandMaxTop of the band. Leave empty to end at the highest value.{{components.sparkline1.bandMax}}
showTooltipShows the value under the pointer in a tooltip.{{components.sparkline1.showTooltip}}
valuePrefixText shown before values in the tooltip, such as $.{{components.sparkline1.valuePrefix}}
valueSuffixText shown after values in the tooltip, such as %.{{components.sparkline1.valueSuffix}}
emptyTextMessage shown when there is no data to draw.{{components.sparkline1.emptyText}}
animateAnimates the chart when it first draws or its data changes.{{components.sparkline1.animate}}
loadingIndicatorWhat shows while the chart is loading: a spinner or a skeleton block.{{components.sparkline1.loadingIndicator}}
trendThe direction from the first value to the last: up, down or flat. With Lower is better on, a fall reads as up.{{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
Line colorTheme: Brand primary
Color when trend is upTheme: Success
Color when trend is downTheme: Error
Band colorTheme: Surface 3
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.