@basic-genomics/hivtrace-viz 1.1.10 → 1.2.0

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.
@@ -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) {
package/dist/hivtrace.css CHANGED
@@ -11950,14 +11950,41 @@ circle.cluster {
11950
11950
  stroke-opacity: 0.3;
11951
11951
  }
11952
11952
 
11953
- #network_tag {
11953
+ /* Network SVG container - only in main network tab */
11954
+ #trace-results #network_tag {
11954
11955
  margin-top: 15px;
11956
+ overflow: scroll;
11957
+ height: calc(100vh - 200px);
11958
+ position: relative;
11959
+ border: 1px solid #e5e7eb;
11960
+ border-radius: 6px;
11961
+ }
11962
+
11963
+ /* Hide the cloned empty #network_tag in dynamic cluster views */
11964
+ .hivtrace-cluster-view #network_tag {
11965
+ display: none;
11966
+ }
11967
+
11968
+ /* SVG container for dynamic cluster views - same style as main network_tag */
11969
+ .hivtrace-network-svg-container {
11970
+ margin-top: 15px;
11971
+ overflow: scroll;
11972
+ height: calc(100vh - 200px);
11973
+ position: relative;
11974
+ border: 1px solid #e5e7eb;
11975
+ border-radius: 6px;
11955
11976
  }
11956
11977
 
11957
11978
  .nav-trace {
11958
11979
  margin-top: 5px;
11959
11980
  }
11960
11981
 
11982
+ /* Checkbox and label vertical alignment - only for hide_filter addon */
11983
+ input[data-hivtrace-ui-role="hide_filter"] {
11984
+ vertical-align: middle;
11985
+ margin-top: -3px !important;
11986
+ }
11987
+
11961
11988
  .input-group-sm > .form-control, .input-group-sm > .input-group-addon, .input-group-sm > .input-group-btn > .btn{
11962
11989
  height: 36px !important;
11963
11990
  }