forked from rakannimer/react-google-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
89 lines (86 loc) · 1.66 KB
/
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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import React from "react";
import ReactDOM from "react-dom";
import Chart from "react-google-charts";
function daysToMilliseconds(days) {
return days * 24 * 60 * 60 * 1000;
}
const columns = [
{ type: "string", label: "Task ID" },
{ type: "string", label: "Task Name" },
{ type: "date", label: "Start Date" },
{ type: "date", label: "End Date" },
{ type: "number", label: "Duration" },
{ type: "number", label: "Percent Complete" },
{ type: "string", label: "Dependencies" }
];
const rows = [
[
"Research",
"Find sources",
new Date(2015, 0, 1),
new Date(2015, 0, 5),
null,
100,
null
],
[
"Write",
"Write paper",
null,
new Date(2015, 0, 9),
daysToMilliseconds(3),
25,
"Research,Outline"
],
[
"Cite",
"Create bibliography",
null,
new Date(2015, 0, 7),
daysToMilliseconds(1),
20,
"Research"
],
[
"Complete",
"Hand in paper",
null,
new Date(2015, 0, 10),
daysToMilliseconds(1),
0,
"Cite,Write"
],
[
"Outline",
"Outline paper",
null,
new Date(2015, 0, 6),
daysToMilliseconds(1),
100,
"Research"
]
];
class App extends React.Component {
state = {
chartImageURI: ""
};
render() {
return (
<div className="App">
<Chart
chartType="Gantt"
data={[columns, ...rows]}
width="100%"
height="50%"
legendToggle
/>
<div>
I'm a picture of the chart
<img src={this.state.chartImageURI} />
</div>
</div>
);
}
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);