11import { OcelInfoContext } from "@/App" ;
22import { BackendProviderContext } from "@/BackendProviderContext" ;
33import { Button } from "@/components/ui/button" ;
4- import { Checkbox } from "@/components/ui/checkbox" ;
54import { Input } from "@/components/ui/input" ;
65import { Label } from "@/components/ui/label" ;
76import { ToggleGroup , ToggleGroupItem } from "@/components/ui/toggle-group" ;
@@ -15,10 +14,9 @@ import ForceGraph2D, {
1514 type NodeObject ,
1615} from "react-force-graph-2d" ;
1716import toast from "react-hot-toast" ;
18- import { CgUndo } from "react-icons/cg" ;
19- import { LuAsterisk , LuClipboardCopy , LuUndo , LuUndo2 } from "react-icons/lu" ;
17+ import { LuClipboardCopy , LuUndo2 } from "react-icons/lu" ;
2018import { MdOutlineZoomInMap } from "react-icons/md" ;
21- import { PiInfoBold , PiInfoFill } from "react-icons/pi" ;
19+ import { PiInfoBold } from "react-icons/pi" ;
2220import { TbFocusCentered } from "react-icons/tb" ;
2321
2422import AutoSizer from "react-virtualized-auto-sizer" ;
@@ -83,8 +81,8 @@ export default function OcelGraphViewer({
8381
8482 useEffect ( ( ) => {
8583 setTimeout ( ( ) => {
86- graphRef . current ?. zoomToFit ( ) ;
87- // graphRef.current?.zoomToFit(200, 100);
84+ // graphRef.current?.zoomToFit();
85+ graphRef . current ?. zoomToFit ( 200 , 100 ) ;
8886 } , 300 ) ;
8987 } , [ data ] ) ;
9088
@@ -161,7 +159,23 @@ export default function OcelGraphViewer({
161159 < GraphOptions options = { options } setOptions = { setOptions } initialGrapOptions = { initialGrapOptions }
162160 setGraphData = { ( gd ) => {
163161 prevGraphDataRef . current = undefined ;
164- graphRef . current ! . d3Force ( "link" ) ! . distance ( 10 ) ;
162+ const link = graphRef . current ! . d3Force ( "link" ) ! ;
163+ const charge =
164+ graphRef . current ! . d3Force ( "charge" ) ! ;
165+
166+ // link.distance(100);
167+ // link.strength(0.6);
168+ charge . strength ( - 5000 ) ;
169+ // charge.distanceMax(500);
170+ // charge.distanceMin(10);
171+
172+ // graphRef.current!.d3Force("link")!.distance(300);
173+
174+ // graphRef.current!.d3Force('charge')!.strength(-1);
175+ // graphRef.current!.d3Force('charge')!.distanceMax(1010);
176+ // graphRef.current!.d3Force('charge')!.distanceMin(110);
177+
178+ console . log ( graphRef . current ! . d3Force ) ;
165179
166180 if ( gd === undefined ) {
167181 setGraphData ( { nodes : [ ] , links : [ ] } ) ;
@@ -239,14 +253,18 @@ export default function OcelGraphViewer({
239253 graphData = { data }
240254 width = { width }
241255 height = { height }
256+ // d3AlphaMin={0.01}
257+ // d3AlphaDecay={0.025}
258+ warmupTicks = { 5 }
259+ // cooldownTicks={100}
242260 nodeAutoColorBy = { "type" }
243261 linkColor = { ( ) => "#d6d6d6" }
244262 backgroundColor = "white"
245- linkWidth = { ( link ) => ( highlightLinks . has ( link ) ? 5 : 2 ) }
263+ linkWidth = { ( link ) => ( highlightLinks . has ( link ) ? 4 : 3 ) }
246264 linkDirectionalParticleColor = { ( ) => "#556166" }
247265 linkDirectionalParticles = { 4 }
248266 linkDirectionalParticleWidth = { ( link ) =>
249- highlightLinks . has ( link ) ? 4 : 0
267+ highlightLinks . has ( link ) ? 8 : 0
250268 }
251269 onNodeHover = { handleNodeHover }
252270 onLinkHover = { handleLinkHover }
@@ -259,24 +277,25 @@ export default function OcelGraphViewer({
259277 } (${ "time" in x ? "Event" : "Object" } )</span></div>`
260278 }
261279 nodeCanvasObject = { ( node , ctx ) => {
280+
262281 if ( node . x === undefined || node . y === undefined ) {
263282 return ;
264283 }
265284 const isFirstNode = node . id === graphData ?. nodes [ 0 ] . id ;
266- let width = 4 ;
267- let height = 4 ;
285+ let width = 40 ;
286+ let height = 40 ;
268287 const fillStyle = isFirstNode
269288 ? node . color
270289 : node . color + "74" ;
271- ctx . lineWidth = isFirstNode ? 0.4 : 0.2 ;
290+ ctx . lineWidth = 10 * ( isFirstNode ? 0.4 : 0.2 ) ;
272291 ctx . strokeStyle = highlightNodes . has ( node )
273292 ? "black"
274293 : isFirstNode
275294 ? "#515151"
276295 : node . color ;
277296 if ( "time" in node ) {
278- width = 7 ;
279- height = 7 ;
297+ width = 70 ;
298+ height = 70 ;
280299 ctx . beginPath ( ) ;
281300 ctx . fillStyle = "white" ;
282301 ctx . roundRect (
@@ -314,11 +333,10 @@ export default function OcelGraphViewer({
314333 // Maybe because of the very small font size?
315334
316335 // if ((window as any).__TAURI__ === undefined) {
317- let fontSize = 1 ;
318- ctx . font
319- ctx . font = `${ fontSize } px Inter, system-ui, Avenir, Helvetica, Arial, sans-serif` ;
336+ let fontSize = 10 ;
337+ ctx . font = `${ fontSize } px Inter` ;
320338 const label = node . id ;
321- const maxLength = 13 ;
339+ const maxLength = 12 ;
322340 const text =
323341 label . length > maxLength
324342 ? label . substring ( 0 , maxLength - 3 ) + "..."
@@ -327,8 +345,9 @@ export default function OcelGraphViewer({
327345
328346 ctx . textAlign = "center" ;
329347 ctx . textBaseline = "bottom" ;
348+ ctx . fontKerning = "none" ;
330349 ctx . fillText ( text , node . x , node . y ) ;
331- fontSize = 0. 8;
350+ fontSize = 8 ;
332351 ctx . font = `${ fontSize } px Inter, system-ui, Avenir, Helvetica, Arial, sans-serif` ;
333352 ctx . fillStyle = "#3f3f3f" ;
334353 const typeText =
0 commit comments