This section compares the different axis types that are available to all sparklines.
In order to select an appropriate sparkline axis type, it is important to consider the data the sparkline is displaying. This ensures that X values are scaled correctly along the axis.
The following axis types are available to all sparklines:
The Y values supplied in the sparkline data will always be plotted using the Number Axis on a continuous scale.
Here's an illustration showing how sparklines can look visually different when different axis types are configured.
Time Axis
Category Axis
The Category Axis is the default axis. X values will be plotted on a band scale which means the data points will be evenly spaced out along the axis making it ideal for small datasets with discrete values or categories.
The Category Axis is configured through the Chart Category Axis Options as follows:
const gridOptions = {
columnDefs: [
{
field: 'rateOfChange',
cellRenderer: 'agSparklineCellRenderer',
cellRendererParams: {
sparklineOptions: {
axis: {
type: 'category'
}
}
},
},
],
}
In the snippet above, the axis type is set to 'category'
but this is optional as the axis uses the 'category'
axis by default.
The example below demonstrates the Category Axis used in an Area Sparkline. Note the following:
[string, number][]
.string
X values are evenly spaced across the axis using a fixed width between each data point.string
X values are included in the tooltip.The Number Axis is used as a value axis. When the Number Axis is used, the distance between the data points depends on the magnitude of the X values. X values must be number
values as they are plotted on a continuous scale with numeric intervals.
The Number Axis is configured through the Chart Number Axis Options as follows:
const gridOptions = {
columnDefs: [
{
field: 'history',
cellRenderer: 'agSparklineCellRenderer',
cellRendererParams: {
sparklineOptions: {
axis: {
type: 'number'
}
}
},
},
],
}
In the snippet above, the axis type is set to 'number'
to select a Number Axis instead of the default Category Axis.
The example below demonstrates the Number Axis used in an Area Sparkline. Note the following:
[number, number][]
.The Time Axis is similar to the Number Axis in that it is also used to plot continuous values. X values can be number
or Date
objects, where number
values are interpreted as timestamps derived from Unix time.
The Time Axis is configured through the Chart Time Axis Options as follows:
const gridOptions = {
columnDefs: [
{
field: 'rateOfChange',
cellRenderer: 'agSparklineCellRenderer',
cellRendererParams: {
sparklineOptions: {
axis: {
type: 'time'
}
}
},
},
],
}
In the snippet above, the axis type is set to 'time'
to select a Time Axis instead of the default Category Axis.
The example below demonstrates the Time Axis used in an Area Sparkline. Note the following:
[Date, number][]
.Date
X values are placed in chronological order and spread along the axis based on the time between data points.Date
X values are included in the tooltip.Continue to the next section to learn about: Sparkline Tooltips.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4