Skip to content

Commit 7ce9a79

Browse files
committed
added code to drop data after certain time period (raster chart)
1 parent fe3f763 commit 7ce9a79

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ yarn-debug.log*
2424
yarn-error.log*
2525

2626
.idea/
27+
.vscode/
28+
.history/
29+
2730
stream-charts-*.tgz

src/app/charts/RasterChart.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ interface Props {
9292
// data to plot: time-window is the time-range of data shown (slides in time)
9393
timeWindow: number;
9494
seriesList: Array<Series>;
95+
dropDataAfter?: number;
9596

9697
// regex filter used to select which series are displayed
9798
filter?: RegExp;
@@ -126,6 +127,7 @@ export function RasterChart(props: Props): JSX.Element {
126127
onUpdateTime = (_: number) => { },
127128
filter = /./,
128129
timeWindow,
130+
dropDataAfter = Infinity,
129131
height,
130132
backgroundColor = '#202020',
131133
} = props;
@@ -1084,6 +1086,11 @@ export function RasterChart(props: Props): JSX.Element {
10841086

10851087
// add the new data to the series
10861088
series.data.push(...newData);
1089+
1090+
// drop data that is older than the max time-window
1091+
while (currentTimeRef.current - series.data[0].time > dropDataAfter) {
1092+
series.data.shift();
1093+
}
10871094
})
10881095

10891096
// update the data

0 commit comments

Comments
 (0)