qiita_pet/static/js/networkVue.js
/**
 *
 * Function to format the node labels so they don't overlap
 *
 * @param label str The node label
 *
 **/
Function to format the node labels so they don't overlap
@param label str The node label
Function to format the node labels so they don ' t overlap @param label str The node label
function formatNodeLabel(label) {
  var limit = 35;
  var labelArray = label.split(' ');
  var newLabel = labelArray[0];
  var aux;
  var lastNewLineIdx = 0;
  for (var i = 1; i < labelArray.length; i++) {
    aux = newLabel + ' ' + labelArray[i];
    if (aux.substr(lastNewLineIdx).length > limit) {
      lastNewLineIdx = newLabel.length;
      newLabel = newLabel + '\n' + labelArray[i];
    } else {
      newLabel = newLabel + ' ' + labelArray[i];
    }
  }
  return newLabel;
}
function formatNodeLabel ( label ) { var limit = 35 ; var labelArray = label . split ( ' ' ) ; var newLabel = labelArray [ 0 ] ; var aux ; var lastNewLineIdx = 0 ; for ( var i = 1 ; i < labelArray . length ; i ++ ) { aux = newLabel + ' ' + labelArray [ i ] ; if ( aux . substr ( lastNewLineIdx ) . length > limit ) { lastNewLineIdx = newLabel . length ; newLabel = newLabel + '\n' + labelArray [ i ] ; } else { newLabel = newLabel + ' ' + labelArray [ i ] ; } } return newLabel ; }
Function to format the node labels so they don't overlap
 @param label str The node label
Function to format the node labels so they don ' t overlap @param label str The node label
// After trying different values, 35 looks like a good value that will not make // the labels overlap in the network. // Split the input string by the space characters // Variable holding the new label // Note that the for loop starts with 1 because we have already used the // first word // We need to split the label here