@basic-genomics/hivtrace-viz 1.1.10 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embed/hivtrace.js +1 -1
- package/dist/embed/hivtrace.js.map +1 -1
- package/dist/embed/index.html +57 -0
- package/dist/hivtrace.js +1 -1
- package/dist/hivtrace.js.map +1 -1
- package/package.json +1 -1
package/dist/embed/index.html
CHANGED
|
@@ -1031,9 +1031,66 @@
|
|
|
1031
1031
|
user_graph.handle_attribute_categorical(user_graph.colorizer['category_id'], false);
|
|
1032
1032
|
}
|
|
1033
1033
|
}
|
|
1034
|
+
|
|
1035
|
+
// 更新 pill badges(唯一值数量)
|
|
1036
|
+
updatePillBadges(selectedClusterId, clusters);
|
|
1034
1037
|
}
|
|
1035
1038
|
});
|
|
1036
1039
|
|
|
1040
|
+
// 更新 pill badges 以反映选定簇的唯一值数量
|
|
1041
|
+
function updatePillBadges(selectedClusterId, clusters) {
|
|
1042
|
+
var pills = document.querySelectorAll('.hivtrace-pill-row .hivtrace-pill');
|
|
1043
|
+
if (!pills.length) return;
|
|
1044
|
+
|
|
1045
|
+
// 确定要统计的节点集合
|
|
1046
|
+
var nodes = [];
|
|
1047
|
+
if (!selectedClusterId) {
|
|
1048
|
+
// 全网:使用所有节点
|
|
1049
|
+
nodes = user_graph.nodes || [];
|
|
1050
|
+
} else {
|
|
1051
|
+
// 特定簇:只使用该簇的节点
|
|
1052
|
+
var cluster = clusters.find(function (c) {
|
|
1053
|
+
return String(c.cluster_id) === String(selectedClusterId);
|
|
1054
|
+
});
|
|
1055
|
+
if (cluster && cluster.children) {
|
|
1056
|
+
nodes = cluster.children;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// 更新每个 pill 的 badge
|
|
1061
|
+
pills.forEach(function (pill) {
|
|
1062
|
+
var badge = pill.querySelector('.badge');
|
|
1063
|
+
if (!badge) return;
|
|
1064
|
+
|
|
1065
|
+
// 从 pill 的原始 HTML 中提取属性 ID(通过闭包数据不可用,需要通过文本匹配)
|
|
1066
|
+
var pillText = pill.textContent.trim();
|
|
1067
|
+
var attrId = null;
|
|
1068
|
+
|
|
1069
|
+
// 遍历 user_graph.json 中的属性来匹配
|
|
1070
|
+
if (user_graph.json && user_graph.json.patient_attribute_schema) {
|
|
1071
|
+
for (var key in user_graph.json.patient_attribute_schema) {
|
|
1072
|
+
var attr = user_graph.json.patient_attribute_schema[key];
|
|
1073
|
+
if (attr.label && pillText.indexOf(attr.label) === 0) {
|
|
1074
|
+
attrId = key;
|
|
1075
|
+
break;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
if (attrId) {
|
|
1081
|
+
// 计算选定节点中该属性的唯一值数量
|
|
1082
|
+
var uniqueValues = new Set();
|
|
1083
|
+
nodes.forEach(function (node) {
|
|
1084
|
+
var value = user_graph.attribute_node_value_by_id(node, attrId);
|
|
1085
|
+
if (value !== null && value !== undefined && value !== 'missing') {
|
|
1086
|
+
uniqueValues.add(value);
|
|
1087
|
+
}
|
|
1088
|
+
});
|
|
1089
|
+
badge.textContent = uniqueValues.size;
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1037
1094
|
|
|
1038
1095
|
// 计算并显示单个 cluster 的统计
|
|
1039
1096
|
function updateClusterStatistics(cluster) {
|