forked from rakannimer/react-google-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (35 loc) · 972 Bytes
/
index.js
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
import React from "react";
import ReactDOM from "react-dom";
import Chart from "react-google-charts";
// Reference : https://developers.google.com/chart/interactive/docs/gallery/timeline
const columns = [
{ type: "string", id: "President" },
{ type: "date", id: "Start" },
{ type: "date", id: "End" }
];
const rows = [
["Washington", new Date(1789, 3, 30), new Date(1797, 2, 4)],
["Adams", new Date(1797, 2, 4), new Date(1801, 2, 4)],
["Jefferson", new Date(1801, 2, 4), new Date(1809, 2, 4)]
];
class App extends React.Component {
componentDidMount() {
setInterval(() => {
this.setState({ refresh: Date.now() });
}, 1000);
}
render() {
return (
<div className="App">
<Chart
chartType="Timeline"
data={[columns, ...rows]}
width="100%"
height="400px"
/>
</div>
);
}
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);