-
-
Notifications
You must be signed in to change notification settings - Fork 257
Expand file tree
/
Copy pathLine.tsx
More file actions
49 lines (45 loc) · 1022 Bytes
/
Line.tsx
File metadata and controls
49 lines (45 loc) · 1022 Bytes
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
43
44
45
46
47
48
49
import ResizableBox from "../ResizableBox";
import useDemoConfig from "../useDemoConfig";
import React from "react";
import { AxisOptions, Chart } from "react-charts";
export default function Line() {
const { data, randomizeData } = useDemoConfig({
series: 10,
dataType: "time",
});
const primaryAxis = React.useMemo<
AxisOptions<typeof data[number]["data"][number]>
>(
() => ({
getValue: (datum) => datum.primary as unknown as Date,
}),
[]
);
const secondaryAxes = React.useMemo<
AxisOptions<typeof data[number]["data"][number]>[]
>(
() => [
{
getValue: (datum) => datum.secondary,
alternatingBackgroundColor: "#f5f5f5",
},
],
[]
);
return (
<>
<button onClick={randomizeData}>Randomize Data</button>
<br />
<br />
<ResizableBox>
<Chart
options={{
data,
primaryAxis,
secondaryAxes,
}}
/>
</ResizableBox>
</>
);
}