Status Tracker
A status tracker: a run of steps as a row of blocks, each in the colour of what was the case at it. The days a service was up, the builds that passed: where the bad ones are is seen at a glance, and which they were is read by pointing at them.
import com.pantrixui.components.chart.statustracker.PantrixStatusTracker
- The block pointed at. The name of the block under the pointer, or of the one that is touched, is written under the row beside its colour; the others are drawn faint. With a finger, another touch on the block that is pointed at lets go of it.
- The line under the row. With
captionoff the name is not written. The line's room is kept whether a block is pointed at or not: the row does not move. - Pressing.
onSelectgives the place of the block that is pressed, counted from nought. - State. The block that is pointed at is kept in
ChartState, as a selection whosexis the block's place. - Direction. In a language read from right to left the first block stands at the right, and the arrows go the way they point.
- Export.
exportputs a button over the chart: the chart is made, as it is on the screen and without the part that is pointed at or its tooltip, into a PNG, an SVG or a PDF file and handed to the app. - Automation.
StatusTracker_<tagKey>; the row.Blocks, the blocks.Block_<number>, the line under the row.Caption.
Examples
The days of a service
The last thirty days of a service: up on the green days, slow on the yellow ones, down on the red one; the grey day has no record.
Move the pointer over a block, or touch it: the day's name is written under the row and the other days fade. On the keyboard the arrows go from day to day.
PantrixStatusTracker(
blocks = uptimeDays(),
description = "Status of the last thirty days",
tagKey = "plain"
)
@Composable
private fun uptimeDays(): List<StatusBlock> {
val colors = PantrixTheme.colors
return List(30) { index ->
val day = "Day ${index + 1}"
when (index) {
7, 21 -> StatusBlock("$day: Slow", colors.warning.color)
13 -> StatusBlock("$day: Outage", colors.danger.color)
26 -> StatusBlock("$day: No record")
else -> StatusBlock("$day: No problems", colors.success.color)
}
}
}
Pressing a block
onSelect gives the place of the block that is pressed: press a day, or go to one with the keyboard and press Enter, and the line under the card writes what was pressed. The line of the name under the row is off here (caption = false).
val report = LocalExampleEvents.current
val days = uptimeDays()
PantrixStatusTracker(
blocks = days,
caption = false,
description = "Status of the last thirty days",
onSelect = { report(days[it].name) },
tagKey = "pressed"
)
@Composable
private fun uptimeDays(): List<StatusBlock> {
val colors = PantrixTheme.colors
return List(30) { index ->
val day = "Day ${index + 1}"
when (index) {
7, 21 -> StatusBlock("$day: Slow", colors.warning.color)
13 -> StatusBlock("$day: Outage", colors.danger.color)
26 -> StatusBlock("$day: No record")
else -> StatusBlock("$day: No problems", colors.success.color)
}
}
}
Your own sizes
A row's own sizes: taller blocks (trackerHeight), wider gaps between them (barGap) and sharp corners (barRadius). A field that is not given stays the theme's.
PantrixStatusTracker(
blocks = uptimeDays().take(14),
description = "Status of the last two weeks",
style = ChartStyle(trackerHeight = 48.dp, barGap = 6.dp, barRadius = 0.dp),
tagKey = "own_look"
)
@Composable
private fun uptimeDays(): List<StatusBlock> {
val colors = PantrixTheme.colors
return List(30) { index ->
val day = "Day ${index + 1}"
when (index) {
7, 21 -> StatusBlock("$day: Slow", colors.warning.color)
13 -> StatusBlock("$day: Outage", colors.danger.color)
26 -> StatusBlock("$day: No record")
else -> StatusBlock("$day: No problems", colors.success.color)
}
}
}
Export
export = ChartExport(...) puts an export button over the chart: press it and choose the kind (PNG, SVG or PDF). The chart makes the file and hands it to onExport; below, its name and size show, and a PNG's picture, and "Save the file" hands it over in the platform's way.
The file has the row of blocks; the line under it, which names the block that is pointed at, is not in it.
var file by remember { mutableStateOf<ChartExportFile?>(null) }
PantrixStatusTracker(
blocks = uptimeDays(),
description = "Status of the last thirty days",
tagKey = "exported",
export = ChartExport(fileName = "last-thirty-days") { file = it }
)
ExportedFile(file, tagKey = "exported")
@Composable
private fun uptimeDays(): List<StatusBlock> {
val colors = PantrixTheme.colors
return List(30) { index ->
val day = "Day ${index + 1}"
when (index) {
7, 21 -> StatusBlock("$day: Slow", colors.warning.color)
13 -> StatusBlock("$day: Outage", colors.danger.color)
26 -> StatusBlock("$day: No record")
else -> StatusBlock("$day: No problems", colors.success.color)
}
}
}
API
blocks
A status tracker: a run of steps as a row of blocks, each in the colour of what was the case at it. The days a service was up, the builds that passed: where the bad ones are is seen at a glance, and which they were is read by pointing at them.
| Parameter | Type | Default | What it is |
|---|---|---|---|
blocks | List<StatusBlock> | the blocks, in the order they are read. | |
modifier | Modifier | Modifier | the tracker's modifier. |
caption | Boolean | true | whether the name of the block that is pointed at is written under the row. The line's room is kept whether a block is pointed at or not, so that the row does not move. |
state | ChartState | rememberChartState() | what the reader points at: the tracker's own where none is given. |
description | String? | null | what the row shows, in a few words, for a screen reader. |
onSelect | ((Int) -> Unit)? | null | called with the place of the block that is pressed, counted from nought. |
style | ChartStyle? | null | this tracker's own geometry: the fields set here, with the theme's for the rest. |
colors | ChartColors? | null | this tracker's own colours, where they are not the theme's. |
tagKey | String? | null | the tracker's automation key: the tracker is StatusTracker_<tagKey>, its row StatusTracker_<tagKey>.Blocks, a block StatusTracker_<tagKey>.Block_<number> counted from one and the line under the row StatusTracker_<tagKey>.Caption. A press on a block is reported as a StatusTracker select event with the block's number. Nothing of the names is reported. |
export | ChartExport? | null | what lets the reader take the chart out of the app as a PNG, an SVG or a PDF: a button over the chart makes the file of it as it is and hands it over (see ChartExport). null, the chart has no such button. The line under the row is not in it. |
ChartStyle
A chart's geometry: how tall it is where nothing says, how thick its lines and how large its marks are, and the room between its parts; and whether its fills have textures besides their colours.
| Parameter | Type | Default | What it is |
|---|---|---|---|
height | Dp | Dp.Unspecified | How tall a chart's plot is, with its axes, where the chart's modifier gives it no height. A legend above or under the plot adds its own. |
lineWidth | Dp | Dp.Unspecified | The width of a series' line. |
markerSize | Dp | Dp.Unspecified | The width and height of the mark on a point. |
selectedMarkerSize | Dp | Dp.Unspecified | The same of the mark on the point that is pointed at. |
gridWidth | Dp | Dp.Unspecified | The width of the grid's lines, of the lines along the axes and of the line that marks the place pointed at. Zero draws none. |
labelGap | Dp | Dp.Unspecified | Between the plot and what is written beside it and under it, and between that and an axis' title. |
tickSpacing | Dp | Dp.Unspecified | The least room between two values marked along the axis of values: what decides how many are marked where the axis does not say. |
legendGap | Dp | Dp.Unspecified | Between the legend and the chart it stands beside. |
legendItemGap | Dp | Dp.Unspecified | Between one entry of the legend and the next. |
swatchSize | Dp | Dp.Unspecified | How wide the sample of a series is in the legend and in the tooltip: a short run of its line, or a patch of its fill. |
swatchGap | Dp | Dp.Unspecified | Between that sample and the name after it. |
tooltipShape | ShapeSpec | ShapeSpec.Unspecified | The tooltip's corners: a step of the brand's shape scale, or a fixed shape. |
tooltipHorizontalPadding | Dp | Dp.Unspecified | Between the tooltip's sides and what it holds. |
tooltipVerticalPadding | Dp | Dp.Unspecified | Between its top and bottom and what it holds, and between its heading and rows. |
tooltipGap | Dp | Dp.Unspecified | Between the place pointed at and the tooltip beside it. |
tooltipElevation | Dp | Dp.Unspecified | The tooltip's shadow. |
barGap | Dp | Dp.Unspecified | Between two bars that stand side by side at a place. Bars too thin for it stand closer. |
barMaxWidth | Dp | Dp.Unspecified | The widest a bar is, however much room its place has: a chart of three places is not three slabs. |
barRadius | Dp | Dp.Unspecified | How round the corners of a bar's end are, the end away from nought. |
sliceGap | Dp | Dp.Unspecified | Between two slices of a pie that lie side by side, the same from the pie's middle to its rim. |
selectedSliceOffset | Dp | Dp.Unspecified | How far the slice of a pie that is pointed at stands out past the pie's rim. The pie keeps this much room about itself, so that the slice has where to stand. |
gaugeWidth | Dp | Dp.Unspecified | How thick the arc of a gauge is. An arc is no thicker than half its radius. |
meterHeight | Dp | Dp.Unspecified | How tall the bar of a meter group is. |
trackerHeight | Dp | Dp.Unspecified | How tall the blocks of a status tracker are. |
bubbleMinSize | Dp | Dp.Unspecified | How far across the smallest bubble of a scatter chart is: a point whose size is nothing, or too little to be seen as an area, is still a point. |
bubbleMaxSize | Dp | Dp.Unspecified | How far across its largest bubble is: the one whose size is the most of the chart's. |
navigatorHeight | Dp | Dp.Unspecified | How tall the strip under a chart's plot is, on which the part of the chart that is in view is marked and moved, in a chart whose zoom has one: how wide, beside a plot whose places go down its side. |
barBandShare | Float | Float.NaN | How much of a place's band its bars take, more than nought and one at the most: the rest is the room between one place's bars and the next's. Bars are no wider than barMaxWidth all the same. |
markLineWidth | Dp | Dp.Unspecified | The width of a mark's line: a target, a limit, a day. Zero draws none, and the mark's words are written all the same. |
markBandAlpha | Float | Float.NaN | How much of its colour a mark's band is drawn in, from nought to one: a band lies behind the series, and is a tint. |
patterns | Boolean? | null | Whether the fills of a chart's series, slices and tiles are drawn with textures besides their colours, and its lines broken in turn (ChartPattern): what tells them apart for a reader who cannot tell the colours apart. Left out, as the system is set: on where it is set to tell things apart without colour, iOS's "Differentiate Without Color" and Android's colour correction, and off otherwise. |
nodeWidth | Dp | Dp.Unspecified | How wide a node of a sankey is. |
nodeGap | Dp | Dp.Unspecified | Between two nodes of a column of a sankey. |
ChartColors
What a chart is painted with, for a chart that does not take the theme's colours: a colour that is set is used, and one that is left out stays the theme's.
| Parameter | Type | Default | What it is |
|---|---|---|---|
series | List<Color> | emptyList() | The colours the series are drawn in, in the order they are handed out, for the series that name none of their own. Empty, they are the theme's chart colours. |
grid | Color | Color.Unspecified | The lines drawn across the chart at the marks of an axis. The theme's divider. |
axis | Color | Color.Unspecified | The line along an axis. The theme's border. |
label | Color | Color.Unspecified | What is written beside the axes: the values, the places and the axes' titles, and the names in the legend. The theme's textSecondary. |
crosshair | Color | Color.Unspecified | The line that marks the place pointed at. The theme's borderHover: stronger than the grid it crosses, and quieter than the series it stands behind. |
tooltipContainer | Color | Color.Unspecified | The tooltip's fill. The theme's surface. |
tooltipBorder | Color | Color.Unspecified | The tooltip's edge. The theme's border. |
tooltipText | Color | Color.Unspecified | The tooltip's heading and its values. The theme's textPrimary. |
tooltipLabel | Color | Color.Unspecified | The names of the series in the tooltip. The theme's textSecondary. |
rising | Color | Color.Unspecified | What a value that goes up is drawn in: a step of a waterfall that adds. The theme's success. |
falling | Color | Color.Unspecified | What a value that goes down is drawn in: a step of a waterfall that takes away. The theme's danger. |
Accessibility
- Keyboard. The row is one stop for Tab: the arrows go from block to block and stop at the ends, Home and End go to the first and the last block, Escape lets go, Enter and Space press the block that is pointed at.
- Screen reader. The row says its
description, then each block by its name. A row of more than two hundred blocks is told by its description alone.