Repository navigation
feat(dashboards): background trend sparkline on number tiles #2489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
12e44f8
feat(dashboards): add background trend sparkline to number tiles
alex-fedotyev fcb80bd
feat(dashboards): add a reference line to the number-tile sparkline
alex-fedotyev 79f69f4
fix(dashboards): keep the number-tile sparkline query stable across v…
alex-fedotyev 84fb774
refactor(dashboards): drop the number-tile sparkline reference line
alex-fedotyev 4fa65c9
feat(dashboards): show the number-tile background chart control disab…
alex-fedotyev 273f8ed
Merge branch 'main' into alex/HDX-1360-number-tile-background-chart
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 ( | ||
| <Box> | ||
| <Text size="xs" c="dimmed" mb={4}> | ||
| Background chart | ||
| </Text> | ||
| <Select | ||
| size="xs" | ||
| data={TYPE_OPTIONS} | ||
| value={value?.type ?? 'none'} | ||
| disabled={disabled} | ||
| allowDeselect={false} | ||
| comboboxProps={{ withinPortal: false }} | ||
| aria-label="Number tile background chart type" | ||
| onChange={next => { | ||
| if (next === 'line' || next === 'area') { | ||
| onChange({ ...value, type: next }); | ||
| } else { | ||
| onChange(undefined); | ||
| } | ||
| }} | ||
| /> | ||
| {disabled ? ( | ||
| <Text size="xs" c="dimmed" mt={4}> | ||
| Available on query-builder number tiles. | ||
| </Text> | ||
| ) : ( | ||
| value && ( | ||
| <Box mt="xs"> | ||
| <Text size="xs" c="dimmed" mb={4}> | ||
| Background color | ||
| </Text> | ||
| <ColorSwatchInput | ||
| value={value.color} | ||
| onChange={color => onChange({ ...value, color })} | ||
| ariaLabel="Number tile background chart color" | ||
| /> | ||
| </Box> | ||
| ) | ||
| )} | ||
| </Box> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ux: maybe if it's a sql chart we can just show a disabled state with a message instead of disappearing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Done in 4fa65c9. On a SQL number tile the control now stays visible but disabled, with a hint ("Available on query-builder number tiles"), instead of disappearing. Keeps it discoverable, and the slot is already in place for when the SQL background query lands.