-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboards): Add incomplete bucket support to
LineChartWidget
(#…
…81405) Shamelessly adapted from #72469, with some minor changes to the code. In short, given a data delay of about 90s, any chart buckets that fall into that delay are plotted with a dotted line. Right now this is done using a series of crimes, in which we split the series into two: a complete and an incomplete. A future version of ECharts promised to allow styling line segments of a series, but right now that's not possible. Even using a custom renderer doesn't work because in that case the segments are plotted one-by-one, which creates a "broken" line, without proper caps.
- Loading branch information
Showing
8 changed files
with
427 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
126 changes: 113 additions & 13 deletions
126
static/app/views/dashboards/widgets/lineChartWidget/lineChartWidgetVisualization.tsx
This file contains 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
21 changes: 21 additions & 0 deletions
21
static/app/views/dashboards/widgets/lineChartWidget/shiftTimeserieToNow.tsx
This file contains 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,21 @@ | ||
import type {TimeseriesData} from '../common/types'; | ||
|
||
export function shiftTimeserieToNow(timeserie: TimeseriesData): TimeseriesData { | ||
const currentTimestamp = new Date().getTime(); | ||
|
||
const lastDatum = timeserie.data.at(-1); | ||
if (!lastDatum) { | ||
return timeserie; | ||
} | ||
|
||
const lastTimestampInTimeserie = new Date(lastDatum.timestamp).getTime(); | ||
const diff = currentTimestamp - lastTimestampInTimeserie; | ||
|
||
return { | ||
...timeserie, | ||
data: timeserie.data.map(datum => ({ | ||
...datum, | ||
timestamp: new Date(new Date(datum.timestamp).getTime() + diff).toISOString(), | ||
})), | ||
}; | ||
} |
Oops, something went wrong.