BridgesUNCC/bridgesAPI

Labels not appearing..

Opened this issue · 1 comments

Hitting the 'l' button used to bring up the labels in the BRIDGES visualization. This doesnt seem to be working.

So there is a difference in the code between the graph SVG backend and the graph canvas backend. They seem to be using different logic to decide whether to draw the labels or not.

here is the graph-canvas.js logic:

    // draw text labels with line breaks
    function drawText(d) {
      if(BridgesVisualizer.showingNodeLabels || d.hovering) {
        context.fillStyle = "black";
        d.lines.forEach(function(line, i) {
          context.fillText(line, d.x+10, d.y+(i*10)+3);
        });
      }
    }

    // draw text labels with line breaks
    function drawLinkText(d, anchor) {
      if((BridgesVisualizer.showingLinkLabels || d.hovering) && d.lines && d.lines.length > 0 ) {
        d.lines.forEach(function(line, i) {
          context.fillStyle = "black";
          context.fillText(line, anchor.x, anchor.y+(i*10));
          context.fillStyle = BridgesVisualizer.getColor(d.color);
        });
      }
    }

See how that uses BridgesVisualize.showingLinkLabels. (BTW doesn't that code ignore color?)

The svg backend uses:

  if(BridgesVisualizer.labels_shown === true){
    d3.selectAll(".nodeLabel").each(BridgesVisualizer.displayNodeLabels)
  }
  if(BridgesVisualizer.link_labels_shown === true){
    d3.selectAll(".linkLabel").each(BridgesVisualizer.displayLinkLabels)
  }

notice how that uses BridgesVisualizer.labels_shown and BridgesVisualizer.link_labels_shown