diff --git a/graphviz/frontend/src/App2.tsx b/graphviz/frontend/src/App2.tsx index c0174b1..bb2bca5 100644 --- a/graphviz/frontend/src/App2.tsx +++ b/graphviz/frontend/src/App2.tsx @@ -139,7 +139,7 @@ function getConnectedComponents(nodes, links) { export function App2() { const fgRef = useRef(); const [selectedNode, setSelectedNode] = useState(null); - const [inputDate, setInputDate] = useState(""); + const [inputDate, setInputDate] = useState(Date.now()); const parsedInputDate = useMemo(() => { const d = new Date(inputDate); @@ -182,11 +182,31 @@ export function App2() { fgRef.current.d3ReheatSimulation(); }, [graphData]); + + const timeRange = useMemo(() => { + let min = Infinity; + let max = -Infinity; + + [...data.claims, ...data.events].forEach(d => { + if (!d.date) return; + const t = parseDateSafe(d.date)?.getTime(); + if (t == null) { + return + } + if (t < min) min = t; + if (t > max) max = t; + }); + + return { min, max }; + }, []); + + function isNodeHighlighted(node, referenceDate) { if (!referenceDate || !node.avgDate) return false; const diffMonths = Math.abs(referenceDate - node.avgDate) / (1000 * 60 * 60 * 24 * 30.44); return diffMonths <= 6; } + const highlightedNodeIds = useMemo(() => { if (!parsedInputDate) return new Set(); @@ -291,22 +311,13 @@ export function App2() { maxWidth: "500px" }} > -

FILTERS

- -

Details

{selectedNode ? (
-

Title: {selectedNode.label}

+

Title: {selectedNode.label}

+

Date: {new Date(selectedNode.avgDate).toISOString().slice(0, 10)}

{selectedNode.members && (

Members:

@@ -330,6 +341,33 @@ export function App2() {

Click a node to see details

)}
+
+ setInputDate(new Number(e.target.value))} + style={{ + width: "100%" + }} + /> + +
+ {new Date(inputDate).toISOString().slice(0, 10)} (± 6 months window) +
+
); } \ No newline at end of file