christophergandrud / networkD3

D3 JavaScript Network Graphs from R
http://christophergandrud.github.io/networkD3
652 stars 268 forks source link

Target Font-size for mouseover transition is hardcoded #299

Open Seferin opened 1 year ago

Seferin commented 1 year ago

In diagonalNetwork.js the font-size for mouseover transition is hardcoded to 25px:

// mouseover event handler
function mouseover() {
  d3.select(this).select("circle").transition()
    .duration(750)
    .attr("r", 9);

  d3.select(this).select("text").transition()
    .duration(750)
    .style("stroke-width", ".5px")
    .style("font", "25px " + x.options.fontFamily)
    .style("opacity", 1);
}

This works fine when networkD3::diagonalNetwork() is called with a fontsize of 10 - mouseover makes the label text larger - but when networkD3::diagonalNetwork() is called with a fontsize of 35 the label becomes smaller with mouseover.

Can a transition target fontsize parameter option be added to the call?

Or alternatively, can the px value be set relative to the fontsize option in the call?

Example of issue in report created from DataExplorer that passes a fontsize default of 35 to a networkD3::diagonalNetwork() call:

image