Skip to content

Commit ca055eb

Browse files
committed
Merge branch '2024-refactoring-RF2' of github.com:veg/hivtrace-viz into 2024-refactoring-RF2
2 parents 9a03bd1 + c718353 commit ca055eb

5 files changed

+88
-36
lines changed

src/clusternetwork.js

+31-19
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,9 @@ var hivtrace_cluster_network_graph = function (
825825
.attr("tabindex", "-1")
826826
.text((d) => "Add this node to the cluster of interest")
827827
.on("click", (d) => {
828-
clustersOfInterest.get_editor().append_node(node.id, true);
828+
clustersOfInterest
829+
.get_editor()
830+
.append_node(self.entity_id(node), true);
829831
});
830832
}
831833

@@ -2146,8 +2148,8 @@ var hivtrace_cluster_network_graph = function (
21462148
sort: "value",
21472149
},
21482150
{
2149-
value: "Nodes",
2150-
help: "How many nodes are in this cluster of interest",
2151+
value: "Persons",
2152+
help: "How many persons are in this cluster of interest",
21512153
sort: "value",
21522154
},
21532155
{
@@ -2174,7 +2176,9 @@ var hivtrace_cluster_network_graph = function (
21742176
current_node_objects = {};
21752177
_.each(self.defined_priority_groups, (pg) => {
21762178
if (current_selection.has(pg.name)) {
2177-
clusterOITotalNOdes += pg.nodes.length;
2179+
clusterOITotalNOdes += self.unique_entity_list(
2180+
pg.node_objects
2181+
).length;
21782182
_.each(pg.nodes, (n) => {
21792183
current_node_set.add(n.name);
21802184
current_node_objects[n.name] = {
@@ -2189,9 +2193,10 @@ var hivtrace_cluster_network_graph = function (
21892193
current_selection.size +
21902194
" clusterOI with " +
21912195
clusterOITotalNOdes +
2192-
" nodes, creating a new clusterOI with " +
2193-
current_node_set.size +
2194-
" nodes. <br><small>Note that the clusters of interest being merged will <b>not</b> be automatically deleted</small>"
2196+
" persons, creating a new clusterOI with " +
2197+
self.unique_entity_list_from_ids([...current_node_set])
2198+
.length +
2199+
" persons. <br><small>Note that the clusters of interest being merged will <b>not</b> be automatically deleted</small>"
21952200
);
21962201
proceed_btn.attr("disabled", null);
21972202
} else {
@@ -2210,7 +2215,11 @@ var hivtrace_cluster_network_graph = function (
22102215
);
22112216
clustersOfInterest
22122217
.get_editor()
2213-
.append_nodes([...current_node_set], current_node_objects);
2218+
.append_nodes(
2219+
[...current_node_set],
2220+
current_node_objects,
2221+
true
2222+
);
22142223
}
22152224
$(modal.node()).modal("hide");
22162225
};
@@ -2220,12 +2229,15 @@ var hivtrace_cluster_network_graph = function (
22202229
var rows = [];
22212230
_.each(self.defined_priority_groups, (pg) => {
22222231
const my_overlaps = new Set();
2223-
_.each(pg.nodes, (n) => {
2224-
_.each([...self.priority_node_overlap[n.name]], (ps) => {
2225-
if (ps !== pg.name) {
2226-
my_overlaps.add(ps);
2232+
_.each(pg.node_objects, (n) => {
2233+
_.each(
2234+
[...self.priority_node_overlap[self.entity_id(n)]],
2235+
(ps) => {
2236+
if (ps !== pg.name) {
2237+
my_overlaps.add(ps);
2238+
}
22272239
}
2228-
});
2240+
);
22292241
});
22302242

22312243
rows.push([
@@ -2243,7 +2255,7 @@ var hivtrace_cluster_network_graph = function (
22432255
},
22442256
},
22452257
{ value: pg.name },
2246-
{ value: pg.nodes.length },
2258+
{ value: self.unique_entity_list(pg.node_objects).length },
22472259
{
22482260
value: [...my_overlaps],
22492261
format: (d) => d.join("<br>"),
@@ -4830,17 +4842,17 @@ var hivtrace_cluster_network_graph = function (
48304842
self.legend_svg
48314843
.append("g")
48324844
.classed("hiv-trace-legend", true)
4833-
.attr("transform", "translate(0," + offset + ")")
4845+
.attr("transform", "translate(3," + (offset + 5) + ")")
48344846
.append("circle")
4835-
.attr("cx", "8")
4847+
.attr("cx", "6")
48364848
.attr("cy", "-4")
4837-
.attr("r", "8")
4849+
.attr("r", "6")
48384850
.classed("multi_sequence", true)
48394851
.style("fill", "none");
48404852
self.legend_svg
48414853
.append("g")
48424854
.classed("hiv-trace-legend", true)
4843-
.attr("transform", "translate(20," + offset + ")")
4855+
.attr("transform", "translate(20," + (offset + 5) + ")")
48444856
.append("text")
48454857
.text("Represents >1 sequence");
48464858
offset += 24;
@@ -4861,7 +4873,7 @@ var hivtrace_cluster_network_graph = function (
48614873
.classed("legend", true)
48624874
.style(
48634875
"fill",
4864-
"url(#" + self.generate_cross_hatch_pattern("#ccc") + ")"
4876+
"url(#" + self.generate_cross_hatch_pattern("#cab") + ")"
48654877
);
48664878
self.legend_svg
48674879
.append("g")

src/clustersOfInterest.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,11 @@ function open_editor(
655655
}
656656
};
657657

658-
panel_object.append_nodes = function (nodes_to_add, existing_attributes) {
658+
panel_object.append_nodes = function (
659+
nodes_to_add,
660+
existing_attributes,
661+
mspp_raw
662+
) {
659663
if (!panel_object.can_add_nodes()) {
660664
return;
661665
}
@@ -667,6 +671,7 @@ function open_editor(
667671

668672
let need_update = false;
669673
let valid_ids = {};
674+
670675
_.each(self.json["Nodes"], (n) => {
671676
if (!existing_ids[n.id]) {
672677
if (existing_attributes) {
@@ -677,16 +682,19 @@ function open_editor(
677682
}
678683
});
679684

680-
nodes_to_add = _.flatten(
681-
_.map(nodes_to_add, (d) => self.fetch_sequences_for_pid(d))
682-
);
685+
if (!mspp_raw) {
686+
nodes_to_add = _.flatten(
687+
_.map(nodes_to_add, (d) => self.fetch_sequences_for_pid(d))
688+
);
689+
}
683690

684691
_.each(nodes_to_add, (n) => {
685692
if (!(n in existing_ids) && n in valid_ids) {
686-
console.log(n);
687693
panel_object._append_node(valid_ids[n]);
688694
existing_ids[n] = 1;
689695
need_update = true;
696+
} else {
697+
console.log("***", n);
690698
}
691699
});
692700

src/hiv_tx_network.js

+32-3
Original file line numberDiff line numberDiff line change
@@ -675,9 +675,15 @@ class HIVTxNetwork {
675675
generate_cross_hatch_pattern(color) {
676676
let id = "id" + this.dom_prefix + "_diagonalHatch_" + color.substr(1, 10);
677677
if (this.network_svg.select("#" + id).empty()) {
678-
this.network_svg
679-
.append("defs")
680-
.append("pattern")
678+
function getComplementaryColor(backgroundColor) {
679+
const color = d3.rgb(backgroundColor);
680+
const luminance = color.r * 0.299 + color.g * 0.587 + color.b * 0.114;
681+
return luminance > 128 ? "#000000" : "#ffffff";
682+
}
683+
684+
let defs = this.network_svg.append("defs");
685+
686+
/*defs.append("pattern")
681687
.attr("id", id)
682688
.attr("patternUnits", "userSpaceOnUse")
683689
.attr("width", "2")
@@ -687,6 +693,29 @@ class HIVTxNetwork {
687693
.attr("d", "M -1,2 l 6,0")
688694
.attr("stroke", color)
689695
.attr("stroke-width", "3"); //this is actual shape for arrowhead
696+
*/
697+
698+
let pattern = defs
699+
.append("pattern")
700+
.attr("id", id)
701+
.attr("patternUnits", "userSpaceOnUse")
702+
.attr("width", "6")
703+
.attr("height", "6")
704+
.attr("patternTransform", "rotate(45)");
705+
706+
pattern
707+
.append("rect")
708+
.attr("width", "3")
709+
.attr("height", "6")
710+
.attr("fill", color)
711+
.attr("transform", "translate(0,0)");
712+
713+
pattern
714+
.append("rect")
715+
.attr("width", "3")
716+
.attr("height", "6")
717+
.attr("fill", getComplementaryColor(color))
718+
.attr("transform", "translate(3,0)");
690719
}
691720
return id;
692721
}

src/hivtrace.css

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
@keyframes selected_object_animation {
22
from {
3-
stroke-width: 1px;
4-
stroke: #ccc;
3+
stroke-width: 3px;
4+
stroke: #350e6b;
55
}
66

77
50% {
88
stroke-width: 5px;
9-
stroke: #000;
9+
stroke: #350e6b;
1010
}
1111

1212
to {
13-
stroke-width: 1px;
14-
stroke: #ccc;
13+
stroke-width: 3px;
14+
stroke: #350e6b;
1515
}
1616
}
1717

@@ -100,13 +100,13 @@ circle.cluster {
100100
}
101101

102102
.link {
103-
stroke: #aaaaaa;
103+
stroke: #cccccc;
104104
stroke-width: 1.5px;
105105
fill: none;
106106
}
107107

108108
.mspp-link {
109-
stroke: #666666;
109+
stroke: #aaaaaa;
110110
stroke-width: 2px;
111111
fill: none;
112112
}
@@ -194,8 +194,11 @@ circle.selected_object {
194194
g.multi_sequence,
195195
path.multi_sequence,
196196
circle.multi_sequence {
197-
stroke-width: 3px;
197+
stroke-width: 1px;
198198
stroke: #350e6b;
199+
border-radius: 50%;
200+
outline: 8px dotted black;
201+
outline-offset: -0.2rem;
199202
/*stroke-dasharray: 10 1;*/
200203
}
201204

src/network.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function handle_cluster_click(self, cluster, release) {
224224
.on("click", (d) => {
225225
clustersOfInterest
226226
.get_editor()
227-
.append_nodes(_.map(cluster.children, (c) => c.id));
227+
.append_nodes(_.map(cluster.children, (c) => self.entity_id(c)));
228228
});
229229
}
230230

0 commit comments

Comments
 (0)