Skip to content

Commit 6713bff

Browse files
authored
Merge pull request #4 from yuxizhe/main
feat: enhance hypergraph viewer with additional edge properties and dynamic attribute display
2 parents c531b9a + 20c054d commit 6713bff

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,
@@ -216,6 +217,9 @@
216217
key: `bubble-sets-${key}`,
217218
type: "bubble-sets",
218219
members: nodes,
220+
keywords: edge.keywords || "",
221+
summary: edge.summary || "",
222+
weight: edge.weight || nodes.length,
219223
...createStyle(colors[i % colors.length]),
220224
});
221225
}
@@ -241,6 +245,19 @@
241245
.join("; ");
242246
result += `<p><strong>Description:</strong> ${desc}</p>`;
243247
}
248+
//展示所有剩余属性
249+
Object.entries(item).forEach(([key, value]) => {
250+
if (
251+
key !== "id" &&
252+
key !== "entity_name" &&
253+
key !== "entity_type" &&
254+
key !== "style" &&
255+
key !== "data" &&
256+
key !== "description"
257+
) {
258+
result += `<p><strong>${key}:</strong> ${value}</p>`;
259+
}
260+
});
244261
});
245262
return result;
246263
},
@@ -322,16 +339,6 @@
322339
console.log("Clicked node:", itemId);
323340
});
324341

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

0 commit comments

Comments
 (0)