forked from oslabs-beta/QLens
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0457ead
commit 674f2c2
Showing
7 changed files
with
292 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import React from 'react'; | ||
import Tree from 'react-d3-tree'; | ||
import '../public/custom-tree.css'; | ||
// This is a simplified example of an org chart with a depth of 2. | ||
// Note how deeper levels are defined recursively via the `children` property. | ||
const orgChart = { | ||
name: 'CEO', | ||
children: [ | ||
{ | ||
name: 'Manager', | ||
attributes: { | ||
department: 'Production', | ||
}, | ||
children: [ | ||
{ | ||
name: 'Foreman', | ||
attributes: { | ||
department: 'Fabrication', | ||
}, | ||
children: [ | ||
{ | ||
name: "kill me" | ||
}, | ||
{ | ||
name: 'love me' | ||
} | ||
], | ||
}, | ||
{ | ||
name: 'Foreman', | ||
attributes: { | ||
department: 'Assembly', | ||
}, | ||
children: [ | ||
{ | ||
name: 'Worker', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
|
||
// users: | ||
// email: {type: "string", required: true} | ||
// forum: {type: "Array", required: true} | ||
// password: {type: "string", required: true} | ||
// username: {type: "string", required: true} | ||
// __v: {type: "number", required: true} | ||
// _id: {primaryKey: true, type: "Object | ||
|
||
// mongodb+srv://judy:coderepforum@coderep-forum-idfny.mongodb.net/Forum?retryWrites=true&w=majority | ||
|
||
export default function OrgChartTree({selectedSchemaData}) { | ||
let schemaChart = {}; | ||
if (selectedSchemaData[0]) { | ||
schemaChart = { | ||
name: 'Database Schema', | ||
children: [], | ||
} | ||
let i = 0; | ||
let childArr = []; | ||
for (let key in selectedSchemaData[0]) { | ||
console.log(selectedSchemaData[0][key]) | ||
for (let prop in selectedSchemaData[0][key]) { | ||
childArr.push({name: prop}) | ||
} | ||
console.log(childArr); | ||
schemaChart.children[i] = { | ||
name: key, | ||
children: childArr, | ||
}; | ||
childArr = []; | ||
i++ | ||
} | ||
} | ||
|
||
// iterate over the selectedSchemaData | ||
// console.log(Object.keys(selectedSchemaData)) | ||
function getName(obj) { | ||
let name = ''; | ||
for (let key in obj) { | ||
name += obj[key]; | ||
} | ||
return name; | ||
} | ||
|
||
let array = []; | ||
|
||
for (let key in selectedSchemaData) { | ||
console.log('LALLALALALALLA', selectedSchemaData[key]) | ||
} | ||
const straightPathFunc = (linkDatum, orientation) => { | ||
const { source, target } = linkDatum; | ||
return orientation === 'vertical' | ||
? `M${source.x},${source.y}L${target.x},${target.y}` | ||
: `M${source.y},${source.x}L${target.y},${target.x}`; | ||
}; | ||
|
||
return ( | ||
// `<Tree />` will fill width/height of its container; in this case `#treeWrapper`. | ||
<div id="treeWrapper" style={{ width: '100%', height: '75vh', backgroundColor: 'white', marginTop: '5.5%'}}> | ||
<Tree | ||
data={schemaChart} | ||
rootNodeClassName="node__root" | ||
branchNodeClassName="node__branch" | ||
leafNodeClassName="node__leaf" | ||
// style={{color: "white"}} | ||
pathFunc={straightPathFunc} | ||
/> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.