-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.ts
42 lines (34 loc) · 1.38 KB
/
dashboard.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {Color, BackgroundColor, MultiPlotChart, PlotAxisScale, PlotSeriesAggregationFn, PlotSeriesOverflow} from "../src";
const chart = new MultiPlotChart({
title: "Dashboard chart",
titleBoundary: 2,
titleSpacing: 8,
titleForeground: Color.blue,
titleBackground: BackgroundColor.black,
});
chart.addPlot({xOffset: 0, yOffset: 0, width: 40, height: 31}, {
title: "overflow: skip",
});
chart.addPlot({xOffset: 42, yOffset: 0, width: 60, height: 15}, {
title: "overflow: logScale (agg: max)",
axisScale: PlotAxisScale.log,
});
chart.addPlot({xOffset: 42, yOffset: 16, width: 60, height: 15}, {
title: "overflow: linearScale (agg: mean)",
axisScale: PlotAxisScale.logInverted,
aggregation: PlotSeriesAggregationFn.mean
});
chart.addPlotSeries(0, {color: Color.red, overflow: PlotSeriesOverflow.clamp});
chart.addPlotSeries(1, {color: Color.blue, overflow: PlotSeriesOverflow.linearScale});
chart.addPlotSeries(2, {color: Color.yellow});
let delay = 66; // Delay in milliseconds
for (let i = 0; i < 2000; i++) {
setTimeout(() => {
chart.addSeriesEntry(0, 0, Math.cos(i * Math.PI / 15));
chart.addSeriesEntry(1, 0, Math.sin(i * Math.PI / 30) * 100 + 2);
chart.addSeriesEntry(2, 0, Math.cos(i * Math.PI / 30) * 100 + 2);
const chartData = chart.paint();
console.clear();
console.log(chartData);
}, delay * i);
}