-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.tsx
70 lines (65 loc) · 1.24 KB
/
example.tsx
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { Chart } from "react-chartjs-2";
import { WaffleController, WaffleElement } from ".";
import "./App.css";
import {
ChartData,
Chart as ChartJS,
LinearScale,
CategoryScale,
ChartOptions,
Tooltip,
} from "chart.js";
function App() {
const data: ChartData<"waffle"> = {
labels: ["A", "B", "C"],
datasets: [
{
label: "hehehhe",
data: [10, 3, 5],
backgroundColor: [
"rgba(255, 26, 104, 1)",
"rgba(54, 162, 235, 1)",
"rgba(255, 206, 86, 1)",
],
},
],
};
const options: ChartOptions<"waffle"> = {
row: 8,
column: 8,
gap: 16,
total: 50,
fill: true,
fillColor: "#eee",
radius: 8,
};
ChartJS.register(
WaffleController,
WaffleElement,
LinearScale,
CategoryScale,
Tooltip
);
return (
<div
style={{
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
padding: "20px",
}}
>
<p>Waffle ChartJS Example</p>
<div
style={{
height: 500,
width: 500,
}}
>
<Chart type="waffle" data={data} options={options} />
</div>
</div>
);
}
export default App;