Skip to content

Commit 36d1130

Browse files
committed
fix chartjs-plugin-zoom build error
1 parent 480e1af commit 36d1130

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

frontend/app/components/LineChart.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { RefObject, useEffect, useRef } from "react";
2-
import ZoomPlugin from "chartjs-plugin-zoom";
32
import {
43
Chart,
54
ChartItem,
@@ -26,7 +25,6 @@ Chart.register(
2625
Legend,
2726
Decimation,
2827
Tooltip,
29-
ZoomPlugin,
3028
);
3129

3230
// ArrayLike<any> is used for data because chartjs supports TypedArrays and we
@@ -60,6 +58,11 @@ function initChart(
6058
chartRef: RefObject<ChartItem>,
6159
{ dataY, datasetNames, dataXUnits, dataYUnits }: LineChartProps,
6260
) {
61+
// Zoom plugin to be registered here because it references `window` which breaks SSR
62+
import("chartjs-plugin-zoom").then((ZoomPlugin) => {
63+
Chart.register(ZoomPlugin.default);
64+
});
65+
6366
const config: ChartConfiguration<ChartType, (typeof dataY)[0], number> = {
6467
type: CHART_TYPE,
6568
data: {
@@ -249,7 +252,7 @@ export default function LineChart(props: LineChartProps) {
249252
// max: Math.ceil(dataPoints[dataPoints.length - 1][0]),
250253
// };
251254

252-
chartInstanceRef.current.update('none');
255+
chartInstanceRef.current.update("none");
253256
}
254257
}, [numRows]);
255258

frontend/app/http.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export async function availableRecordings(): Promise<string[] | null> {
5959
}
6060

6161
export async function getRecording(filepath: string) {
62-
// if (typeof window === "undefined") return;
6362
// Initializes WebAssembly memory for parquet-wasm, and gets a reference to it
6463
await wasmInit();
6564
const WASM_MEMORY = wasmMemory();

0 commit comments

Comments
 (0)