Skip to content

Commit

Permalink
#418 clusteringByGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Thieurmel committed Oct 2, 2021
1 parent 7c9bd7f commit 89c92a5
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions inst/htmlwidgets/visNetwork.js
Expand Up @@ -532,13 +532,18 @@ function resetOneNode(node, options, network){
}

// Global function to reset all node
function resetAllNodes(nodes, update, options, network){
var nodesToReset = nodes.get({
filter: function (item) {
return item.isHardToRead === true;
},
returnType :'Array'
});
function resetAllNodes(nodes, update, options, network, all){

if(all === false){
var nodesToReset = nodes.get({
filter: function (item) {
return item.isHardToRead === true;
},
returnType :'Array'
});
} else {
var nodesToReset = nodes.get({returnType :'Array'});
}

var have_cluster_nodes = false;
var nodes_in_clusters;
Expand Down Expand Up @@ -1897,7 +1902,7 @@ if (HTMLWidgets.shinyMode){

//reset nodes
resetAllEdges(el.edges, el.highlightColor, el.byselectionColor, el.chart);
resetAllNodes(el.nodes, true, el.options, el.chart);
resetAllNodes(el.nodes, true, el.options, el.chart, false);

if (main_el.selectActive === true){
main_el.selectActive = false;
Expand Down Expand Up @@ -1982,7 +1987,7 @@ if (HTMLWidgets.shinyMode){
// reset some parameters / date before
if (main_el.selectActive === true | main_el.highlightActive === true) {
//reset nodes
resetAllNodes(el.nodes, true, el.options, el.chart);
resetAllNodes(el.nodes, true, el.options, el.chart, false);

if (main_el.selectActive === true){
main_el.selectActive = false;
Expand Down Expand Up @@ -3295,7 +3300,7 @@ HTMLWidgets.widget({
}
else if (el_id.selectActive === true) {
//reset nodes
resetAllNodes(nodes, update, options, instance.network)
resetAllNodes(nodes, update, options, instance.network, false)
el_id.selectActive = false
}
}
Expand Down Expand Up @@ -3709,7 +3714,7 @@ HTMLWidgets.widget({
resetList("nodeSelect", el.id, 'selected');
}
//reset nodes
resetAllNodes(nodes, update, options, instance.network)
resetAllNodes(nodes, update, options, instance.network, false)
el_id.highlightActive = false;
is_clicked = false;

Expand Down Expand Up @@ -4042,13 +4047,15 @@ HTMLWidgets.widget({
if(x.clusteringGroup || x.clusteringColor || x.clusteringOutliers || x.clusteringHubsize || x.clusteringConnection){
// if we click on a node, we want to open it up!
instance.network.on("doubleClick", function (params){

if (params.nodes.length === 1) {
if (instance.network.isCluster(params.nodes[0]) === true) {
is_clicked = false;
instance.network.openCluster(params.nodes[0], {releaseFunction : function(clusterPosition, containedNodesPositions) {
return containedNodesPositions;
}});
// must be better...
resetAllEdges(edges, el_id.highlightColor, el_id.byselectionColor, instance.network);
resetAllNodes(nodes, true, options, instance.network, true);
} else {
if(x.clusteringGroup){
var array_group = nodes.get({
Expand Down

0 comments on commit 89c92a5

Please sign in to comment.