Skip to content

Commit c6686c0

Browse files
committed
chore(docs): fix animation example
1 parent a5251b4 commit c6686c0

File tree

1 file changed

+21
-21
lines changed
  • sandboxes/advanced-animations/default

1 file changed

+21
-21
lines changed
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from "react";
1+
import React, { useEffect, useState } from "react";
22
import { Chart } from "react-google-charts";
33
import faker from "faker";
44

@@ -13,49 +13,49 @@ function getData() {
1313
}
1414

1515
export const options = {
16-
colors: ["#8e0152", "#276419"],
17-
pointSize: 10,
16+
title: "Company Performance",
17+
curveType: "function",
18+
legend: { position: "bottom" },
1819
animation: {
1920
duration: 1000,
2021
easing: "out",
21-
startup: true,
2222
},
2323
vAxis: {
2424
viewWindow: {
25-
max: -10,
26-
min: 100,
25+
max: 100,
26+
min: 0,
2727
},
2828
},
2929
hAxis: {
3030
viewWindow: {
3131
max: 100,
32-
min: -10,
32+
min: 0,
3333
},
3434
},
35-
legend: { position: "none" },
36-
enableInteractivity: false,
3735
};
3836

3937
export function App() {
4038
const [chartData, setChartData] = useState(getData);
41-
39+
const [year, setYear] = useState(new Date().getFullYear());
4240
useEffect(() => {
4341
const intervalId = setInterval(() => {
4442
setChartData(getData());
45-
}, 900);
46-
43+
setYear((y) => y - 1);
44+
}, 1000);
4745
return () => {
4846
clearInterval(intervalId);
4947
};
50-
});
51-
48+
}, [setChartData]);
5249
return (
53-
<Chart
54-
chartType="ScatterChart"
55-
width="80%"
56-
height="400px"
57-
data={chartData}
58-
options={options}
59-
/>
50+
<>
51+
<Chart
52+
chartType="ScatterChart"
53+
width="100%"
54+
height="400px"
55+
data={chartData}
56+
options={options}
57+
/>
58+
<div style={{ width: "100%", textAlign: "center" }}>{year}</div>
59+
</>
6060
);
6161
}

0 commit comments

Comments
 (0)