MCPcopy
hub / github.com/opentrace/opentrace / GraphPlayground

Function GraphPlayground

ui/src/components/stories/GraphPlayground.tsx:47–611  ·  view source on GitHub ↗
({
  dataset: initialDataset,
  width: widthProp,
  height: heightProp,
}: GraphPlaygroundProps)

Source from the content-addressed store, hash-verified

45}
46
47export default function GraphPlayground({
48 dataset: initialDataset,
49 width: widthProp,
50 height: heightProp,
51}: GraphPlaygroundProps) {
52 // ── Dataset selection ──────────────────────────────────────────────
53 const [currentDataset, setCurrentDataset] = useState<Dataset>(
54 initialDataset ?? DATASETS[0],
55 );
56 const { nodes, links } = currentDataset;
57
58 // ── Dimensions ─────────────────────────────────────────────────────
59 const containerRef = useRef<HTMLDivElement>(null);
60 const width = widthProp ?? 900;
61 const height = heightProp ?? 600;
62
63 // ── Graph ref ──────────────────────────────────────────────────────
64 const graphRef = useRef<GraphCanvasHandle>(null);
65
66 // ── Search ─────────────────────────────────────────────────────────
67 const [searchQuery, setSearchQuery] = useState('');
68 const [activeSearch, setActiveSearch] = useState('');
69 const [hops, setHops] = useState(2);
70
71 // ── Selection ──────────────────────────────────────────────────────
72 const [selectedNodeId, setSelectedNodeId] = useState<string | null>(null);
73 const [selectedNode, setSelectedNode] = useState<GraphNode | null>(null);
74
75 // ── Color / Display ────────────────────────────────────────────────
76 const [colorMode, setColorMode] = useState<'type' | 'community'>('type');
77 const [labelsVisible, setLabelsVisible] = useState(true);
78
79 // ── Physics ────────────────────────────────────────────────────────
80 const [repulsion, setRepulsion] = useState(D.repulsion);
81 const [isPhysicsRunning, setIsPhysicsRunning] = useState(true);
82
83 // ── Pixi-specific ──────────────────────────────────────────────────
84 const [linkDistance, setLinkDistance] = useState(D.pixiLinkDist);
85 const [centerStrength, setCenterStrength] = useState(D.pixiCenter);
86 const [edgesEnabled, setEdgesEnabled] = useState(D.edgesVisible);
87 const [layoutMode, setLayoutMode] = useState<'spread' | 'compact'>(
88 D.layoutMode,
89 );
90 const [zoomSizeExponent, setZoomSizeExponent] = useState(D.pixiZoomExponent);
91
92 // ── Filters ────────────────────────────────────────────────────────
93 const [hiddenNodeTypes, setHiddenNodeTypes] = useState<Set<string>>(
94 new Set(),
95 );
96 const [hiddenLinkTypes, setHiddenLinkTypes] = useState<Set<string>>(
97 new Set(),
98 );
99
100 // ── Side panel ─────────────────────────────────────────────────────
101 const [showFilters, setShowFilters] = useState(true);
102 const [showSettings, setShowSettings] = useState(false);
103
104 // ── Computed data ──────────────────────────────────────────────────

Callers

nothing calls this directly

Calls 8

getNodeColorFunction · 0.90
getLinkColorFunction · 0.90
setEdgesEnabledMethod · 0.80
setLayoutModeMethod · 0.80
setZoomSizeExponentMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected