diff --git a/.changeset/number-tile-background-chart.md b/.changeset/number-tile-background-chart.md new file mode 100644 index 0000000000..07eb9f2929 --- /dev/null +++ b/.changeset/number-tile-background-chart.md @@ -0,0 +1,15 @@ +--- +'@hyperdx/app': minor +'@hyperdx/common-utils': minor +--- + +feat(dashboards): add a background trend sparkline to number tiles + +Number tiles can now render a faint line or area sparkline behind the value, +derived from a time-bucketed version of the same query, so the value's trend +over the selected range is visible at a glance. This is handy for SLO / +error-budget tiles where the burn over time matters as much as the current +number. The sparkline inherits the tile's color by default and can be +overridden to any palette token. Configure it under Display Settings > +Background chart on a number tile. Available on builder number tiles (raw SQL +number tiles return a single value with no time dimension to bucket). diff --git a/packages/app/src/components/BackgroundChartInput.tsx b/packages/app/src/components/BackgroundChartInput.tsx new file mode 100644 index 0000000000..54d3e5011b --- /dev/null +++ b/packages/app/src/components/BackgroundChartInput.tsx @@ -0,0 +1,72 @@ +import { BackgroundChart } from '@hyperdx/common-utils/dist/types'; +import { Box, Select, Text } from '@mantine/core'; + +import { ColorSwatchInput } from './ColorSwatchInput'; + +const TYPE_OPTIONS = [ + { value: 'none', label: 'None' }, + { value: 'line', label: 'Line' }, + { value: 'area', label: 'Area' }, +]; + +/** + * Editor for a number tile's optional background sparkline. The type select + * drives the `backgroundChart` config object: "None" clears it, "Line" / + * "Area" set the shape. The color swatch is an optional palette-token + * override; when unset the sparkline inherits the tile's static color. + * + * `disabled` is set for raw SQL number tiles, which have no time dimension to + * bucket: the control stays visible but inert with a hint, so the option is + * discoverable rather than missing. + */ +export function BackgroundChartInput({ + value, + onChange, + disabled = false, +}: { + value?: BackgroundChart; + onChange: (value: BackgroundChart | undefined) => void; + disabled?: boolean; +}) { + return ( + + + Background chart + +