Repository navigation
feat(dashboards): release markers on tile charts #2894
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
3 commits
Select commit
Hold shift + click to select a range
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,10 @@ | ||
| --- | ||
| '@hyperdx/app': minor | ||
| --- | ||
|
|
||
| Overlay release markers on dashboard tile charts, showing when each version of a | ||
| service first appeared so a deployment can be lined up against a change in the | ||
| data. Markers are scoped to the data each tile is charting and tinted to match | ||
| their service's series color, and are suppressed on charts where they can't be | ||
| tied to a visible line, so an aggregate line spanning many services isn't | ||
| annotated with releases you can't attribute to it. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ import { COLORS, formatNumber, truncateMiddle } from '@/utils'; | |
| import { | ||
| ChartAnnotation, | ||
| getAnnotationElements, | ||
| resolveAnnotationSeries, | ||
| } from './components/charts/chartAnnotations'; | ||
| import { ChartOverlayControls } from './components/charts/ChartOverlayControls'; | ||
| import { | ||
|
|
@@ -48,6 +49,7 @@ import { | |
| import { useChartSyncId } from './chartSync'; | ||
| import { | ||
| findNearestSeriesKey, | ||
| getSeriesColorForGroup, | ||
| LineData, | ||
| MAX_TIME_CHART_SERIES, | ||
| toStartOfInterval, | ||
|
|
@@ -796,7 +798,7 @@ export const MemoChart = memo(function MemoChart({ | |
| lineData: LineData[]; | ||
| referenceLines?: React.ReactNode; | ||
| /** | ||
| * Event markers (alerts, deploys, …) drawn as dashed vertical lines with a | ||
| * Event markers (alerts, releases, …) drawn as dashed vertical lines with a | ||
| * label above. Passed as data rather than pre-rendered elements so the chart | ||
| * can clamp them to its own x-axis domain. Distinct from `referenceLines` | ||
| * (threshold lines). | ||
|
|
@@ -1395,7 +1397,9 @@ export const MemoChart = memo(function MemoChart({ | |
| [buildActivePayloadFromState, setIsClickActive], | ||
| ); | ||
|
|
||
| const xAxisDomain: AxisDomain = useMemo(() => { | ||
| // Typed as the tuple it actually is (assignable to AxisDomain) so the | ||
| // annotation helpers can take it without an unsafe cast. | ||
| const xAxisDomain: [number, number] = useMemo(() => { | ||
| let startTime = toStartOfInterval(dateRange[0], granularity); | ||
| let endTime = toStartOfInterval(dateRange[1], granularity); | ||
| const endTimeIsBoundaryAligned = isSameSecond(dateRange[1], endTime); | ||
|
|
@@ -1420,15 +1424,29 @@ export const MemoChart = memo(function MemoChart({ | |
| // Alert/event markers as dashed lines, clamped to the chart's x-axis domain so | ||
| // an edge marker (e.g. an alert already firing at window open) stays visible | ||
| // instead of being dropped. Labels float in the reserved top headroom. | ||
| const annotationElements = useMemo(() => { | ||
| // Tint each marker to match the series it describes and drop the ones that | ||
| // can't be tied to anything on this chart — see `resolveAnnotationSeries`. | ||
| const coloredAnnotations = useMemo(() => { | ||
| if (!annotations?.length) { | ||
| return annotations; | ||
| } | ||
| return resolveAnnotationSeries(annotations, group => | ||
| getSeriesColorForGroup(lineData, group), | ||
| ); | ||
| }, [annotations, lineData]); | ||
|
teeohhem marked this conversation as resolved.
Resolved
|
||
|
|
||
| const annotationElements = useMemo(() => { | ||
| if (!coloredAnnotations?.length) { | ||
| return null; | ||
| } | ||
| // xAxisDomain is a [min, max] tuple at runtime (declared as AxisDomain). | ||
| return getAnnotationElements(annotations, { | ||
| domain: xAxisDomain as [number, number], | ||
| return getAnnotationElements(coloredAnnotations, { | ||
| domain: xAxisDomain, | ||
| // Drawable width, so markers too close together share one label. Zero on | ||
| // the first paint (before ResponsiveContainer measures), which the | ||
| // renderer treats as "label everything". | ||
| plotWidth: Math.max(0, containerWidth - Y_AXIS_WIDTH), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is nice |
||
| }); | ||
| }, [annotations, xAxisDomain]); | ||
| }, [coloredAnnotations, xAxisDomain, containerWidth]); | ||
|
|
||
| return ( | ||
| <div | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.