This repository has been archived by the owner on Jun 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sarbull/main
Initial commit
- Loading branch information
Showing
15 changed files
with
17,015 additions
and
0 deletions.
There are no files selected for viewing
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,2 @@ | ||
/node_modules/ | ||
.DS_Store |
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,78 @@ | ||
# happi-graph component | ||
|
||
Happi Graph Component using Polymer 3.0. | ||
|
||
## Demo | ||
|
||
```html | ||
<button id="zoom-in">+</button> | ||
<button id="zoom-out">-</button> | ||
<button id="center-graph">center-graph</button> | ||
<button id="remove-data">remove-data</button> | ||
<button id="add-data">add-data</button> | ||
|
||
<happi-graph id="happi-graph"></happi-graph> | ||
``` | ||
|
||
```js | ||
let propertiesMap = { | ||
SimpleSquare: 'simple-square' | ||
}; | ||
|
||
let iconsMap = { | ||
'simple-square': `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 0H20V20H0V0Z" fill="white"/></svg>`, | ||
}; | ||
|
||
let happiGraphInstance = document.querySelector('#happi-graph'); | ||
|
||
let data = { | ||
graphDirection: 'VERTICAL', | ||
selectedNodeId: 0, | ||
nodes: [ | ||
{ id: 0, properties: {} }, | ||
{ id: 1, properties: {} }, | ||
{ id: 2, properties: {} }, | ||
{ id: 3, properties: {} }, | ||
{ id: 4, properties: {} }, | ||
], | ||
links: [] | ||
}; | ||
|
||
data.links = [ | ||
{ from: 0, to: 1, connectionFrom: false, connectionTo: true }, | ||
{ from: 0, to: 2, connectionFrom: false, connectionTo: true }, | ||
{ from: 0, to: 3, connectionFrom: false, connectionTo: true }, | ||
{ from: 3, to: 4, connectionFrom: false, connectionTo: true } | ||
]; | ||
|
||
happiGraphInstance.data = { ...data }; | ||
happiGraphInstance.iconsMap = iconsMap; | ||
happiGraphInstance.propertiesMap = propertiesMap; | ||
|
||
zoomIn.addEventListener('click', () => { | ||
happiGraphInstance.customZoomIn(); | ||
}); | ||
|
||
zoomOut.addEventListener('click', () => { | ||
happiGraphInstance.customZoomOut(); | ||
}); | ||
|
||
centerGraph.addEventListener('click', () => { | ||
happiGraphInstance.centerGraph(); | ||
}); | ||
|
||
document.querySelector('#remove-data').addEventListener('click', () => { | ||
happiGraphInstance.removeData(); | ||
}); | ||
|
||
document.querySelector('#add-data').addEventListener('click', () => { | ||
happiGraphInstance.data = { ...data }; | ||
}); | ||
``` | ||
|
||
## Example | ||
|
||
![3 nodes graph example](./docs/print-screen-happi-graph-3-nodes.png?raw=true "3 nodes graph example") | ||
|
||
## License | ||
[MIT](https://choosealicense.com/licenses/mit/) |
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,201 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes"> | ||
|
||
<title>happi-graph demo</title> | ||
|
||
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script> | ||
|
||
<script type="module"> | ||
import '@polymer/iron-demo-helpers/demo-pages-shared-styles'; | ||
import '@polymer/iron-demo-helpers/demo-snippet'; | ||
</script> | ||
|
||
<script type="module" src="../happi-graph.js"></script> | ||
|
||
<style> | ||
.buttons { | ||
width:1200px; | ||
margin: 0 auto; | ||
margin-bottom:20px; | ||
} | ||
|
||
.container { | ||
height:700px; | ||
width: 1200px; | ||
margin: 0 auto; | ||
margin-bottom:20px; | ||
} | ||
|
||
.bordered { | ||
border:2px solid #777; | ||
} | ||
|
||
:root { | ||
--happi-graph-font-family: sans-serif; | ||
--happi-graph-primary-color-rgb: 113, 204, 220; | ||
--happi-graph-primary-color: rgb(var(--happi-graph-primary-color-rgb)); | ||
--happi-graph-secondary-color: #24272a; | ||
--happi-graph-gray-color: #AFAFAF; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="buttons"> | ||
<button id="zoom-in">+</button> | ||
<button id="zoom-out">-</button> | ||
<button id="center-graph">center-graph</button> | ||
<button id="remove-data">remove-data</button> | ||
<button id="add-data">add-data</button> | ||
</div> | ||
|
||
<div class="container bordered"> | ||
<happi-graph id="happi-graph"></happi-graph> | ||
</div> | ||
|
||
<div class="container bordered"> | ||
<happi-graph id="happi-graph-two"></happi-graph> | ||
</div> | ||
|
||
<div class="container bordered"> | ||
<happi-graph id="happi-graph-three"></happi-graph> | ||
</div> | ||
|
||
<script type="module"> | ||
import { iconsMap } from 'egeria-js-commons'; | ||
|
||
let propertiesMap = { | ||
SimpleSquare: { | ||
icon: 'simple-square' | ||
}, | ||
GroupName: { | ||
icon: 'simple-square' | ||
} | ||
}; | ||
|
||
let data = { | ||
graphDirection: 'HORIZONTAL', | ||
selectedNodeId: 0, | ||
nodes: [ | ||
{ id: 0, label: 'This is the value of Node 0', group: 'GroupName', properties: { GroupName: 'IBS_UTBLIACML' } }, | ||
|
||
{ id: 2, label: 'This is the value of Node 2', group: 'GroupName', properties: {} }, | ||
{ id: 3, label: 'This is the value of Node 3', group: 'GroupName', properties: {} }, | ||
{ id: 4, label: 'This is the value of Node 4', group: 'GroupName', properties: {} }, | ||
|
||
{ id: 5, label: 'This is the value of Node 5', group: 'GroupName', properties: {} }, | ||
{ id: 6, label: 'This is the value of Node 6', group: 'GroupName', properties: {} }, | ||
{ id: 7, label: 'This is the value of Node 7', group: 'GroupName', properties: {} }, | ||
|
||
{ id: 9, label: 'This is the value of Node 9', group: 'GroupName', properties: {} }, | ||
{ id: 10, label: 'This is the value of Node 10', group: 'GroupName', properties: {} }, | ||
{ id: 11, label: 'This is the value of Node 11', group: 'GroupName', properties: {} } | ||
], | ||
links: [ | ||
{ from: 0, to: 2, connectionFrom: false, connectionTo: true }, | ||
{ from: 0, to: 5, connectionFrom: false, connectionTo: true }, | ||
{ from: 0, to: 6, connectionFrom: false, connectionTo: true }, | ||
{ from: 0, to: 7, connectionFrom: false, connectionTo: true }, | ||
|
||
{ from: 2, to: 3, connectionFrom: false, connectionTo: true }, | ||
{ from: 3, to: 4, connectionFrom: false, connectionTo: true }, | ||
{ from: 4, to: 9, connectionFrom: false, connectionTo: true }, | ||
{ from: 9, to: 10, connectionFrom: false, connectionTo: true }, | ||
{ from: 10, to: 11, connectionFrom: false, connectionTo: true } | ||
] | ||
}; | ||
|
||
let happiGraphInstance = document.querySelector('#happi-graph'); | ||
happiGraphInstance.iconsMap = iconsMap; | ||
happiGraphInstance.propertiesMap = propertiesMap; | ||
happiGraphInstance.graphData = { ...data }; | ||
happiGraphInstance.addEventListener('happi-graph-on-node-click', ({ detail }) => { | ||
console.log(detail); | ||
}); | ||
happiGraphInstance.addEventListener('happi-graph-on-cached-graph', ({ id }) => { | ||
happiGraphInstance.graphData = { ...data }; | ||
}); | ||
|
||
let data2 = { | ||
graphDirection: 'VERTICAL', | ||
selectedNodeId: 0, | ||
nodes: [ | ||
{ id: 0, label: 'This is the value of Node 0', group: 'GroupName', properties: {} }, | ||
{ id: 1, label: 'This is the value of Node 1', group: 'GroupName', properties: {} }, | ||
{ id: 2, label: 'This is the value of Node 2', group: 'GroupName', properties: {} }, | ||
{ id: 3, label: 'This is the value of Node 3', group: 'GroupName', properties: {} }, | ||
{ id: 4, label: 'This is the value of Node 4', group: 'GroupName', properties: {} }, | ||
], | ||
links: [ | ||
{ from: 0, to: 1, connectionFrom: false, connectionTo: true }, | ||
{ from: 0, to: 2, connectionFrom: false, connectionTo: true }, | ||
{ from: 0, to: 3, connectionFrom: false, connectionTo: true }, | ||
{ from: 3, to: 4, connectionFrom: false, connectionTo: true } | ||
] | ||
}; | ||
|
||
let happiGraphInstance2 = document.querySelector('#happi-graph-two'); | ||
happiGraphInstance2.iconsMap = iconsMap; | ||
happiGraphInstance2.propertiesMap = propertiesMap; | ||
happiGraphInstance2.graphData = { ...data2 }; | ||
happiGraphInstance2.addEventListener('happi-graph-on-node-click', ({ detail }) => { | ||
console.log(detail); | ||
}); | ||
happiGraphInstance2.addEventListener('happi-graph-on-cached-graph', ({ id }) => { | ||
happiGraphInstance2.graphData = { ...data2 }; | ||
}); | ||
|
||
let data3 = { | ||
graphDirection: 'VERTICAL', | ||
"selectedNodeId": 'term@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.e1b1ec6c.66k78i6du.uchsna1.rn2epa.rfn2fjqf7h4qvmt5lflm8', | ||
"nodes":[{"id":"database_column@68e36496-7167-4af7-abdd-a0cd36e24084:b1c497ce.60641b50.c6hn1iao9.e5opbug.skdff2.0ekpogs1n7p2e8g2ru549","label":"DATA_DATE","group":"RelationalColumn","properties":{"relationalTable":"IBS_UTBLIACML"},"level":-1},{"id":"category@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.ee6a64fe.66k7apfcs.bebeg0j.94uekn.8fp27imt10gg820m1e61i","label":"DARE Test","group":"GlossaryCategory","properties":{"glossary":"Esperanto Test"},"level":-1},{"id":"database_column@68e36496-7167-4af7-abdd-a0cd36e24084:b1c497ce.60641b50.c6hn1ib9v.2ou4ifi.hjrj69.11bqnhkl7fkk571disar9","label":"FIRST_NAME","group":"RelationalColumn","properties":{"schema":"ES_OS_ADMIN","database":"ESDLPROD_3505","relationalTable":"FOS_UC_USER"},"level":-1},{"id":"data_file_field@68e36496-7167-4af7-abdd-a0cd36e24084:b1c497ce.60641b50.c6hn1ha5v.9v5ostf.mlc4hd.olsa4vbci8lntrsvs5so5","label":"LO_DATA_DT","group":"TabularColumn","properties":{"schema":"AR_X_LO_RLTNP_V7_ES"},"level":-1},{"id":"database_column@68e36496-7167-4af7-abdd-a0cd36e24084:b1c497ce.60641b50.ov1n236ed.4ff0tu8.255r33.efp3bg2di19qevd09glie","label":"A9_TSECIDX","group":"RelationalColumn","properties":{"relationalTable":"ODS_LOAD_LIQUIDATION_COMPTE"},"level":-1},{"id":"term@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.e1b1ec6c.66k78i6du.uchsna1.rn2epa.rfn2fjqf7h4qvmt5lflm8","label":"test_egeria","group":"GlossaryTerm","properties":{"glossary":"CheckCategoryH"},"level":0},{"id":"database_column@68e36496-7167-4af7-abdd-a0cd36e24084:b1c497ce.60641b50.ov1n236ed.3jr9ga7.86f7jr.s6pq1jgtv9t7mrfn6cdql","label":"AB_HCREA","group":"RelationalColumn","properties":{"relationalTable":"ODS_LOAD_LIQUIDATION_COMPTE"},"level":-1},{"id":"database_column@68e36496-7167-4af7-abdd-a0cd36e24084:b1c497ce.60641b50.c6hn1ibca.rrt5qk9.v38l76.112ugrtovqr01o8i1f7g3","label":"ABA","group":"RelationalColumn","properties":{"schema":"ES_OS_ADMIN","database":"ESDLPROD_3505","relationalTable":"IBS_COL"},"level":-1},{"id":"category@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.ee6a64fe.66k78i6d4.8d7g3u1.e5u373.a41osc1ankjf7c5grpf0v","label":"TEST","group":"GlossaryCategory","properties":{"glossary":"CheckCategoryH"},"level":-1}], | ||
"links":[{"from":"data_file_field@68e36496-7167-4af7-abdd-a0cd36e24084:b1c497ce.60641b50.c6hn1ha5v.9v5ostf.mlc4hd.olsa4vbci8lntrsvs5so5","to":"term@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.e1b1ec6c.66k78i6du.uchsna1.rn2epa.rfn2fjqf7h4qvmt5lflm8","label":"SemanticAssignment"},{"from":"database_column@68e36496-7167-4af7-abdd-a0cd36e24084:b1c497ce.60641b50.c6hn1ibca.rrt5qk9.v38l76.112ugrtovqr01o8i1f7g3","to":"term@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.e1b1ec6c.66k78i6du.uchsna1.rn2epa.rfn2fjqf7h4qvmt5lflm8","label":"SemanticAssignment"},{"from":"database_column@68e36496-7167-4af7-abdd-a0cd36e24084:b1c497ce.60641b50.ov1n236ed.4ff0tu8.255r33.efp3bg2di19qevd09glie","to":"term@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.e1b1ec6c.66k78i6du.uchsna1.rn2epa.rfn2fjqf7h4qvmt5lflm8","label":"SemanticAssignment"},{"from":"database_column@68e36496-7167-4af7-abdd-a0cd36e24084:b1c497ce.60641b50.c6hn1iao9.e5opbug.skdff2.0ekpogs1n7p2e8g2ru549","to":"term@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.e1b1ec6c.66k78i6du.uchsna1.rn2epa.rfn2fjqf7h4qvmt5lflm8","label":"SemanticAssignment"},{"from":"database_column@68e36496-7167-4af7-abdd-a0cd36e24084:b1c497ce.60641b50.c6hn1ib9v.2ou4ifi.hjrj69.11bqnhkl7fkk571disar9","to":"term@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.e1b1ec6c.66k78i6du.uchsna1.rn2epa.rfn2fjqf7h4qvmt5lflm8","label":"SemanticAssignment"},{"from":"term@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.e1b1ec6c.66k78i6du.uchsna1.rn2epa.rfn2fjqf7h4qvmt5lflm8","to":"category@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.ee6a64fe.66k78i6d4.8d7g3u1.e5u373.a41osc1ankjf7c5grpf0v","label":"TermCategorization"},{"from":"term@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.e1b1ec6c.66k78i6du.uchsna1.rn2epa.rfn2fjqf7h4qvmt5lflm8","to":"category@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.ee6a64fe.66k7apfcs.bebeg0j.94uekn.8fp27imt10gg820m1e61i","label":"TermCategorization"},{"from":"database_column@68e36496-7167-4af7-abdd-a0cd36e24084:b1c497ce.60641b50.ov1n236ed.3jr9ga7.86f7jr.s6pq1jgtv9t7mrfn6cdql","to":"term@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.e1b1ec6c.66k78i6du.uchsna1.rn2epa.rfn2fjqf7h4qvmt5lflm8","label":"SemanticAssignment"}] | ||
}; | ||
|
||
let happiGraphInstance3 = document.querySelector('#happi-graph-three'); | ||
happiGraphInstance3.iconsMap = iconsMap; | ||
happiGraphInstance3.propertiesMap = propertiesMap; | ||
happiGraphInstance3.graphData = { ...data3 }; | ||
happiGraphInstance3.addEventListener('happi-graph-on-node-click', ({ detail }) => { | ||
console.log(detail); | ||
}); | ||
happiGraphInstance3.addEventListener('happi-graph-on-cached-graph', ({ id }) => { | ||
happiGraphInstance3.graphData = { ...data3 }; | ||
}); | ||
|
||
/* Buttons */ | ||
|
||
document.querySelector('#zoom-in').addEventListener('click', () => { | ||
happiGraphInstance.customZoomIn(); | ||
happiGraphInstance2.customZoomIn(); | ||
happiGraphInstance3.customZoomIn(); | ||
}); | ||
|
||
document.querySelector('#zoom-out').addEventListener('click', () => { | ||
happiGraphInstance.customZoomOut(); | ||
happiGraphInstance2.customZoomOut(); | ||
happiGraphInstance3.customZoomOut(); | ||
}); | ||
|
||
document.querySelector('#center-graph').addEventListener('click', () => { | ||
happiGraphInstance.centerGraph(); | ||
happiGraphInstance2.centerGraph(); | ||
happiGraphInstance3.centerGraph(); | ||
}); | ||
|
||
document.querySelector('#remove-data').addEventListener('click', () => { | ||
happiGraphInstance.removeData(); | ||
happiGraphInstance2.removeData(); | ||
happiGraphInstance3.removeData(); | ||
}); | ||
|
||
document.querySelector('#add-data').addEventListener('click', () => { | ||
happiGraphInstance.graphData = { ...data }; | ||
happiGraphInstance2.graphData = { ...data2 }; | ||
happiGraphInstance3.graphData = { ...data3 }; | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.