forked from rakannimer/react-google-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (39 loc) · 1012 Bytes
/
index.js
File metadata and controls
41 lines (39 loc) · 1012 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
import * as React from "react";
import { render } from "react-dom";
import { Chart } from "react-google-charts";
const data = [
["Country", "Popularity"],
["Germany", 200],
["United States", 300],
["Brazil", 400],
["Canada", 500],
["France", 600],
["RU", 700]
];
class App extends React.Component {
render() {
return (
<div className="App">
<Chart
chartEvents={[
{
eventName: "select",
callback: ({ chartWrapper }) => {
const chart = chartWrapper.getChart();
const selection = chart.getSelection();
if (selection.length === 0) return;
const region = data[selection[0].row + 1];
console.log("Selected : " + region);
}
}
]}
chartType="GeoChart"
width="100%"
height="400px"
data={data}
/>
</div>
);
}
}
render(<App />, document.getElementById("root"));