Allow for opening details pane after node clicked
This commit is contained in:
@@ -25,7 +25,7 @@ export function Home() {
|
|||||||
A great introduction to the dataset on a curated set of examples
|
A great introduction to the dataset on a curated set of examples
|
||||||
</p>
|
</p>
|
||||||
<p className="text-center">
|
<p className="text-center">
|
||||||
Also <a className="underline" href="#3d">available in 3D</a>
|
Also <a className="underline" href="#3d">available in 3D</a> (experimental)
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import SpriteText from 'three-spritetext';
|
|||||||
|
|
||||||
export function VizSmall3D() {
|
export function VizSmall3D() {
|
||||||
const fgRef = useRef();
|
const fgRef = useRef();
|
||||||
|
const detailsPanelRef = useRef();
|
||||||
const [selectedNode, setSelectedNode] = useState(null);
|
const [selectedNode, setSelectedNode] = useState(null);
|
||||||
const [minGraphSize, setMinGraphSize] = useState(10);
|
const [minGraphSize, setMinGraphSize] = useState(10);
|
||||||
const [showLabel, setShowLabel] = useState(false);
|
const [showLabel, setShowLabel] = useState(false);
|
||||||
@@ -53,7 +54,7 @@ export function VizSmall3D() {
|
|||||||
nodeAutoColorBy="type"
|
nodeAutoColorBy="type"
|
||||||
linkColor={() => "black"}
|
linkColor={() => "black"}
|
||||||
linkWidth={2.5}
|
linkWidth={2.5}
|
||||||
onNodeClick={(node) => setSelectedNode(node)}
|
onNodeClick={(node) => { detailsPanelRef.current.open(); setSelectedNode(node)}}
|
||||||
backgroundColor="white"
|
backgroundColor="white"
|
||||||
nodeThreeObject={(node) => {
|
nodeThreeObject={(node) => {
|
||||||
const circle = new THREE.Mesh(
|
const circle = new THREE.Mesh(
|
||||||
@@ -83,7 +84,7 @@ export function VizSmall3D() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<FloatingPanelStack>
|
<FloatingPanelStack>
|
||||||
<DetailsPanel selectedNode={selectedNode} data={data} />
|
<DetailsPanel selectedNode={selectedNode} data={data} ref={detailsPanelRef} />
|
||||||
<FloatingPanel title={"Config"}>
|
<FloatingPanel title={"Config"}>
|
||||||
<label className="flex">
|
<label className="flex">
|
||||||
<span className="mr-1 grow">Show Labels</span>
|
<span className="mr-1 grow">Show Labels</span>
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ export function buildGraph(data) {
|
|||||||
|
|
||||||
export function VizSmallConnected() {
|
export function VizSmallConnected() {
|
||||||
const fgRef = useRef();
|
const fgRef = useRef();
|
||||||
|
const detailsPanelRef = useRef();
|
||||||
const [selectedNode, setSelectedNode] = useState(null);
|
const [selectedNode, setSelectedNode] = useState(null);
|
||||||
const [minGraphSize, setMinGraphSize] = useState(10);
|
const [minGraphSize, setMinGraphSize] = useState(10);
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ export function VizSmallConnected() {
|
|||||||
nodeAutoColorBy="type"
|
nodeAutoColorBy="type"
|
||||||
linkColor={() => "black"}
|
linkColor={() => "black"}
|
||||||
linkWidth={2.5}
|
linkWidth={2.5}
|
||||||
onNodeClick={(node) => setSelectedNode(node)}
|
onNodeClick={(node) => { detailsPanelRef.current.open(); setSelectedNode(node) }}
|
||||||
linkDirectionalArrowLength={100}
|
linkDirectionalArrowLength={100}
|
||||||
linkDirectionalArrowRelPos={0.9}
|
linkDirectionalArrowRelPos={0.9}
|
||||||
nodeCanvasObject={(node, ctx, globalScale) => {
|
nodeCanvasObject={(node, ctx, globalScale) => {
|
||||||
@@ -175,7 +176,7 @@ export function VizSmallConnected() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<FloatingPanelStack>
|
<FloatingPanelStack>
|
||||||
<DetailsPanel selectedNode={selectedNode} data={data} />
|
<DetailsPanel selectedNode={selectedNode} data={data} ref={detailsPanelRef} />
|
||||||
<FloatingPanel title={"Key"}>
|
<FloatingPanel title={"Key"}>
|
||||||
<p style={{ backgroundColor: "green" }} className="text-white p-1 text-xl mb-3">Trigger Event Cluster</p>
|
<p style={{ backgroundColor: "green" }} className="text-white p-1 text-xl mb-3">Trigger Event Cluster</p>
|
||||||
<p style={{ backgroundColor: "DarkMagenta" }} className="text-white p-1 text-xl rounded-3xl">Claim Cluster</p>
|
<p style={{ backgroundColor: "DarkMagenta" }} className="text-white p-1 text-xl rounded-3xl">Claim Cluster</p>
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ function buildGraph(data) {
|
|||||||
|
|
||||||
export function VizTimeFilter() {
|
export function VizTimeFilter() {
|
||||||
const fgRef = useRef();
|
const fgRef = useRef();
|
||||||
|
const detailsPanelRef = useRef();
|
||||||
const [selectedNode, setSelectedNode] = useState(null);
|
const [selectedNode, setSelectedNode] = useState(null);
|
||||||
const [inputDate, setInputDate] = useState(1682353753000); //some time in 2023
|
const [inputDate, setInputDate] = useState(1682353753000); //some time in 2023
|
||||||
const [showAll, setShowAll] = useState(false);
|
const [showAll, setShowAll] = useState(false);
|
||||||
@@ -204,7 +205,7 @@ export function VizTimeFilter() {
|
|||||||
return bothHighlighted ? "black" : "rgba(0,0,0,0)";
|
return bothHighlighted ? "black" : "rgba(0,0,0,0)";
|
||||||
}}
|
}}
|
||||||
linkWidth={2.5}
|
linkWidth={2.5}
|
||||||
onNodeClick={(node) => setSelectedNode(node)}
|
onNodeClick={(node) => { detailsPanelRef.current.open(); setSelectedNode(node)}}
|
||||||
nodeCanvasObject={(node, ctx) => {
|
nodeCanvasObject={(node, ctx) => {
|
||||||
const label = node.label;
|
const label = node.label;
|
||||||
|
|
||||||
@@ -258,7 +259,7 @@ export function VizTimeFilter() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<FloatingPanelStack bot="lg">
|
<FloatingPanelStack bot="lg">
|
||||||
<DetailsPanel selectedNode={selectedNode} data={data} />
|
<DetailsPanel selectedNode={selectedNode} data={data} ref={detailsPanelRef} />
|
||||||
<FloatingPanel title={"Key"}>
|
<FloatingPanel title={"Key"}>
|
||||||
<p style={{ backgroundColor: "green" }} className="text-white p-1 text-xl mb-3">Trigger Event Cluster</p>
|
<p style={{ backgroundColor: "green" }} className="text-white p-1 text-xl mb-3">Trigger Event Cluster</p>
|
||||||
<p style={{ backgroundColor: "DarkMagenta" }} className="text-white p-1 text-xl rounded-3xl">Claim Cluster</p>
|
<p style={{ backgroundColor: "DarkMagenta" }} className="text-white p-1 text-xl rounded-3xl">Claim Cluster</p>
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
|
import { forwardRef, useImperativeHandle, useRef } from "react";
|
||||||
import { FloatingPanel } from "./FloatingPanel";
|
import { FloatingPanel } from "./FloatingPanel";
|
||||||
|
|
||||||
export function DetailsPanel({ selectedNode, data }) {
|
export const DetailsPanel = forwardRef(function DetailsPanel(
|
||||||
|
{ selectedNode, data }, ref) {
|
||||||
|
const fpref = useRef();
|
||||||
|
|
||||||
|
useImperativeHandle(ref, () => ({
|
||||||
|
open: () => { fpref.current.open() },
|
||||||
|
}));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FloatingPanel title="Details">
|
<FloatingPanel title="Details" ref={fpref}>
|
||||||
|
|
||||||
{selectedNode ? (
|
{selectedNode ? (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
@@ -40,4 +48,4 @@ export function DetailsPanel({ selectedNode, data }) {
|
|||||||
)}
|
)}
|
||||||
</FloatingPanel>
|
</FloatingPanel>
|
||||||
);
|
);
|
||||||
}
|
})
|
||||||
@@ -1,15 +1,17 @@
|
|||||||
import { useState } from "react";
|
import { useState, forwardRef, useImperativeHandle } from "react";
|
||||||
|
|
||||||
export function FloatingPanel({
|
export const FloatingPanel = forwardRef(function FloatingPanel(
|
||||||
title,
|
{ title, children, defaultOpen = true },
|
||||||
children,
|
ref
|
||||||
defaultOpen = true,
|
) {
|
||||||
}) {
|
|
||||||
const [open, setOpen] = useState(defaultOpen);
|
const [open, setOpen] = useState(defaultOpen);
|
||||||
|
|
||||||
|
useImperativeHandle(ref, () => ({
|
||||||
|
open: () => setOpen(true),
|
||||||
|
}));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white shadow-lg rounded-2xl w-80 overflow-hidden transition-all">
|
<div className="bg-white shadow-lg rounded-2xl w-80 overflow-hidden transition-all">
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={() => setOpen(!open)}
|
onClick={() => setOpen(!open)}
|
||||||
className="w-full flex items-center justify-between px-4 py-2 bg-gray-100 hover:bg-gray-200 transition"
|
className="w-full flex items-center justify-between px-4 py-2 bg-gray-100 hover:bg-gray-200 transition"
|
||||||
@@ -17,8 +19,7 @@ export function FloatingPanel({
|
|||||||
<span className="font-semibold">{title}</span>
|
<span className="font-semibold">{title}</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
className={`transform transition-transform ${
|
className={`transform transition-transform ${open ? "rotate-180" : ""
|
||||||
open ? "rotate-180" : ""
|
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
▼
|
▼
|
||||||
@@ -26,12 +27,11 @@ export function FloatingPanel({
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={`overflow-scroll transition-all duration-300 ${
|
className={`overflow-scroll transition-all duration-300 ${open ? "max-h-[50vh] p-4" : "max-h-0 p-0"
|
||||||
open ? "max-h-[50vh] p-4" : "max-h-0 p-0"
|
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
Reference in New Issue
Block a user