Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zcemycl committed Aug 3, 2024
1 parent f8420ae commit 9645ced
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/containers/docker/neo4j/frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import NeoVis, { NeovisConfig, NeoVisEvents } from "neovis.js";

export default function Home() {
const [vis, setVis] = useState<any>(null);
const [visNetwork, setVisNetwork] = useState<any>(null);
const [x, setX] = useState(0);
const [y, setY] = useState(0);

useEffect(() => {
const draw = () => {
Expand Down Expand Up @@ -71,6 +74,31 @@ export default function Home() {
};
const viz = new NeoVis(config);
viz.render();
viz.network?.on("click", () => {
console.log("hello");
});
viz.registerOnEvent(NeoVisEvents.CompletionEvent, (e) => {
console.log("hh");
viz.network?.on("click", (event) => {
// console.log(event)
console.log("click");
const selection = viz.network?.getSelectedNodes();
console.log(selection);
console.log(e);
console.log(event.event.target.getBoundingClientRect());
console.log(event.event.center);
const rect = event.event.target.getBoundingClientRect();
// let correctedX = event.event.center.x - rect.x;
// let correctedY = event.event.center.y - rect.y;
let correctedX = event.event.center.x;
let correctedY = event.event.center.y;
console.log(correctedX, correctedY);
setX(correctedX);
setY(correctedY);
});
});

console.log(viz.network);
setVis(viz);
};
draw();
Expand All @@ -83,6 +111,12 @@ export default function Home() {
>
<div className="flex items-center content-center align-middle flex-row justify-center">
<div id="viz" className="border border-white bg-white"></div>
<div
className={`absolute bg-slate-600 text-white`}
style={{ left: x, top: y }}
>
<h1>Hello</h1>
</div>
</div>
</section>
);
Expand Down

0 comments on commit 9645ced

Please sign in to comment.