Browse Source

Network: Prevent image loading for hidden cluster nodes (#3492)

Fixes #3483.

If `shape: 'image'` is defined as option, this was used for initializing hidden cluster nodes during layout initialization.
However, because no image is being passed, this led to an exception.

This fix prevens shape `image` from being used for hidden cluster nodes. In addition, some extra fields for these nodes are
now overridden for some performance improvament.
jittering-top
wimrijnders 6 years ago
committed by Yotam Berkowitz
parent
commit
9fa9b00fda
2 changed files with 23 additions and 4 deletions
  1. +22
    -3
      lib/network/modules/LayoutEngine.js
  2. +1
    -1
      lib/network/modules/components/shared/Label.js

+ 22
- 3
lib/network/modules/LayoutEngine.js View File

@ -561,13 +561,32 @@ class LayoutEngine {
if (positionDefined < 0.5 * indices.length) {
let MAX_LEVELS = 10;
let level = 0;
let clusterThreshold = 150;
// Performance enhancement, during clustering edges need only be simple straight lines.
let clusterThreshold = 150; // TODO add this to options
//
// Define the options for the hidden cluster nodes
// These options don't propagate outside the clustering phase.
//
// Some options are explicitly disabled, because they may be set in group or default node options.
// The clusters are never displayed, so most explicit settings here serve as performance optimizations.
//
// The explicit setting of 'shape' is to avoid `shape: 'image'`; images are not passed to the hidden
// cluster nodes, leading to an exception on creation.
//
// All settings here are performance related, except when noted otherwise.
//
let clusterOptions = {
clusterNodeProperties:{
shape: 'ellipse', // Bugfix: avoid type 'image', no images supplied
label: '', // avoid label handling
group: '', // avoid group handling
font: {multi: false}, // avoid font propagation
},
clusterEdgeProperties:{
label: '', // avoid label handling
font: {multi: false}, // avoid font propagation
smooth: {
enabled: false
enabled: false // avoid drawing penalty for complex edges
}
}
};

+ 1
- 1
lib/network/modules/components/shared/Label.js View File

@ -64,7 +64,7 @@ class Label {
this.initFontOptions(options.font);
if (options.label !== undefined) {
if (options.label !== undefined && options.label !== null && options.label !== '') {
this.labelDirty = true;
}

Loading…
Cancel
Save