From 12e44f81e849d76893ccf24249f78f8573d1a73e Mon Sep 17 00:00:00 2001 From: Alex Fedotyev <61838744+alex-fedotyev@users.noreply.github.com> Date: Thu, 18 Jun 2026 01:00:15 +0000 Subject: [PATCH 1/5] feat(dashboards): add background trend sparkline to number tiles Number tiles can render a faint line or area sparkline behind the value, derived from a time-bucketed version of the same query, so the trend over the selected range is visible at a glance. Useful for SLO / error-budget tiles where the burn over time matters as much as the current number. - common-utils: BackgroundChartSchema (line / area + optional palette color override) on SharedChartSettingsSchema, mirroring color / colorRules. - app: NumberTileBackgroundChart draws the sparkline behind DBNumberChart, reusing convertToTimeChartConfig + formatResponseForTimeChart for the bucketed series. Builder number tiles only; raw SQL has no time dimension to bucket. - Display Settings: a Background chart control (type + optional color), gated on builder number tiles. Co-Authored-By: Claude Opus 4.8 --- .changeset/number-tile-background-chart.md | 15 ++ .../src/components/BackgroundChartInput.tsx | 59 +++++ .../components/ChartDisplaySettingsDrawer.tsx | 22 ++ .../DBEditTimeChartForm/EditTimeChartForm.tsx | 8 +- packages/app/src/components/DBNumberChart.tsx | 19 +- .../components/NumberTileBackgroundChart.tsx | 201 ++++++++++++++++++ .../__tests__/DBNumberChart.test.tsx | 44 ++++ .../NumberTileBackgroundChart.test.tsx | 46 ++++ .../common-utils/src/__tests__/types.test.ts | 41 +++- packages/common-utils/src/types.ts | 32 ++- 10 files changed, 478 insertions(+), 9 deletions(-) create mode 100644 .changeset/number-tile-background-chart.md create mode 100644 packages/app/src/components/BackgroundChartInput.tsx create mode 100644 packages/app/src/components/NumberTileBackgroundChart.tsx create mode 100644 packages/app/src/components/__tests__/NumberTileBackgroundChart.test.tsx 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..d4f04acf69 --- /dev/null +++ b/packages/app/src/components/BackgroundChartInput.tsx @@ -0,0 +1,59 @@ +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 left unset the sparkline inherits the tile's static color. + */ +export function BackgroundChartInput({ + value, + onChange, +}: { + value?: BackgroundChart; + onChange: (value: BackgroundChart | undefined) => void; +}) { + return ( + + + Background chart + +