This section shows how Line Sparklines can be customised by overriding the default line options.
The following Line Sparkline Options can be used to customise Line Sparklines:
Also see Additional Customisations for more advanced customisations that are common across all sparklines.
The snippet below shows option overrides for the Line Sparkline:
sparklineOptions: {
type: 'line',
line: {
stroke: 'rgb(124, 255, 178)',
strokeWidth: 2,
},
padding: {
top: 5,
bottom: 5,
},
highlightStyle: {
size: 7,
fill: 'rgb(124, 255, 178)',
strokeWidth: 0
},
}The following example demonstrates the results of the Line Sparkline options above:
To apply custom stroke and strokeWidth attributes to the line, set these properties under line options as shown:
sparklineOptions: {
type: 'line',
// Customise the line path in the sparkline.
line: {
stroke: 'orange',
strokeWidth: 2,
},
}The result of the above configuration is displayed below on the right, compared with default line options on the left.


The markers are enabled by default but the size has been set to 0px, making them invisible.
The size property in the highlightStyle options is 6px by default, allowing the markers to become visible when in the highlighted state.
These formats can be modified to your liking by setting the marker and highlightStyle options as demonstated below.
sparklineOptions: {
type: 'line',
marker: {
size: 3,
shape: 'diamond',
fill: 'green',
stroke: 'green',
strokeWidth: 2
},
highlightStyle: {
size: 10,
fill: 'cyan',
stroke: 'cyan',
},
}3px in the un-highlighted normal state, and 10px in the highlighted state.The result of the above configuration is displayed below, compared with default marker options in the first sparkline.



Crosshairs display a vertical and horizontal line running across the sparklines when hovering on a data point. When the mouse is moved, the crosshairs will snap to the closest data point.
By default, the vertical crosshair line has been enabled for line sparklines and is displayed as a solid grey line.
The horizontal and vertical crosshair lines can be enabled or disabled independently by adding crosshairs options as shown below:
sparklineOptions: {
crosshairs: {
xLine: {
enabled: false // enabled by default, set to false to remove the default vertical crosshair line
},
yLine: {
enabled: false // disabled by default, set to true to enable the horizontal crosshair line
}
}
}The style of the crosshair line, including stroke, strokeWidth, lineDash and lineCap, can be customised via the xLine and yLine options:
sparklineOptions: {
crosshairs: {
xLine: {
enabled: true, // enabled by default
lineDash: 'dash',
stroke: 'rgba(0, 0, 0, 0.5)',
},
yLine: {
enabled: true,
lineDash: 'dash',
stroke: 'rgba(0, 0, 0, 0.5)',
},
}
}Below is an example to show crosshair customisation. Note that:
To add extra space around the sparklines, custom padding options can be applied in the following way.
sparklineOptions: {
type: 'line',
// Adjust the padding around the sparklines.
padding: {
top: 10,
right: 5,
bottom: 10,
left: 5
},
}top, right, bottom and left properties are all optional and can be modified independently.

More advanced customisations are discussed separately in the following sections:
axis options.tooltip options.formatter.Properties available on the LineSparklineOptions interface.
typeType'line' | The type of sparklines to create, in this case it would be 'line'. |
lineTypeSparklineLineOptions | The configuration for the line. |
markerTypeSparklineMarkerOptions | The configuration for the marker styles. |
crosshairsTypeSparklineCrosshairsOptions | The configuration for the crosshairs. |
x | The key to use to retrieve X values from the data. This will only be used if the data array contains objects with key-value pairs.
|
y | The key to use to retrieve Y values from the data. This will only be used if the data array contains objects with key-value pairs.
|
paddingTypePaddingOptions | Configuration for the padding in pixels shown around the sparklines. |
axisTypeSparklineAxisOptions | The options for the axis line in the sparklines. See: SparklineAxisOptions |
highlight | The configuration for the highlighting used when the items are hovered over. |
tooltipTypeSparklineTooltipOptions | Configuration for the tooltips. |
Properties available on the SparklineMarkerOptions interface.
Properties available on the SparklineAxisOptions interface.
Continue to the next section to learn about: Sparkline Data.