-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (39 loc) · 1021 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
39
40
41
42
43
44
45
import React, { useState, useEffect } from 'react';
import { render } from 'react-dom';
import './style.css';
import { OrgChartComponent } from './OrgChart';
import { MessageEnvelope } from './MessageEnvelope';
import * as d3 from 'd3';
const App = props => {
const [data, setData] = useState(null);
let addNodeChildFunc = null;
function addNode() {
const node = {
nodeId: 'new Node',
parentNodeId: 'O-6066'
};
addNodeChildFunc(node);
}
function onNodeClick(nodeId) {
console.log('d3', d3.event);
alert('clicked ' + nodeId);
}
useEffect(() => {
d3.csv(
'https://raw.githubusercontent.com/siddharthpal/farewell-org-chart/master/org.csv'
).then(data => {
setData(data);
});
}, [true]);
return (
<div>
<OrgChartComponent
setClick={click => (addNodeChildFunc = click)}
onNodeClick={onNodeClick}
data={data}
/>
<MessageEnvelope />
</div>
);
};
render(<App />, document.getElementById('root'));