Skip to content

Commit 20c054d

Browse files
committed
feat: enhance hypergraph viewer with additional edge properties and dynamic attribute display
1 parent 74e955a commit 20c054d

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

hyperdb/templates/hypergraph_viewer.html

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
if (!edgeSet.has(edgeId)) {
171171
edgeSet.add(edgeId);
172172
hyperData.edges.push({
173+
id: edgeId,
173174
source: a,
174175
target: b,
175176
...edge,
@@ -214,6 +215,9 @@
214215
key: `bubble-sets-${key}`,
215216
type: "bubble-sets",
216217
members: nodes,
218+
keywords: edge.keywords || "",
219+
summary: edge.summary || "",
220+
weight: edge.weight || nodes.length,
217221
...createStyle(colors[i % colors.length]),
218222
});
219223
}
@@ -239,6 +243,19 @@
239243
.join("; ");
240244
result += `<p><strong>Description:</strong> ${desc}</p>`;
241245
}
246+
//展示所有剩余属性
247+
Object.entries(item).forEach(([key, value]) => {
248+
if (
249+
key !== "id" &&
250+
key !== "entity_name" &&
251+
key !== "entity_type" &&
252+
key !== "style" &&
253+
key !== "data" &&
254+
key !== "description"
255+
) {
256+
result += `<p><strong>${key}:</strong> ${value}</p>`;
257+
}
258+
});
242259
});
243260
return result;
244261
},
@@ -320,16 +337,6 @@
320337
console.log("Clicked node:", itemId);
321338
});
322339

323-
// 添加节点悬停事件
324-
graph.on("node:pointerenter", (e) => {
325-
const { itemId } = e;
326-
const node = graph.getNodeData(itemId);
327-
if (node && node.data) {
328-
// 可以在这里显示tooltip
329-
console.log("Node data:", node.data);
330-
}
331-
});
332-
333340
// 添加窗口大小变化监听
334341
const handleResize = () => {
335342
if (graphRef.current && containerRef.current) {
@@ -491,12 +498,19 @@ <h2 className="text-2xl font-bold text-gray-800 mb-6 flex items-center">
491498
)}
492499
</div>
493500
<div className="text-sm text-gray-600 flex gap-2 items-center">
501+
{vertex.entity_type ? (
494502
<div className="flex items-center">
495503
<span className="font-medium">Type:</span>
496504
<span className="ml-2 px-2 py-1 bg-gray-100 rounded text-xs">
497-
{vertex.entity_type || "Unknown"}
505+
{vertex.entity_type}
498506
</span>
499-
</div>
507+
</div>) : (
508+
<div className="flex items-center">
509+
<span className="font-medium">ID:</span>
510+
<span className="ml-2 px-2 py-1 bg-gray-100 rounded text-xs">
511+
{vertex.id}
512+
</span>
513+
</div>)}
500514
<div className="flex items-center">
501515
<span className="font-medium">Degree:</span>
502516
<span className="ml-2 px-2 py-1 bg-blue-100 text-blue-700 rounded text-xs font-semibold">

0 commit comments

Comments
 (0)