You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Label for the Node or Edge is longer than the width constraint
hover and hoverConnectedEdges interactions are true
All the chosen settings are set to false to disable them (so as not to confuse the issue)
When hovering over a such a Node or Edge, even though chosen settings are disabled, the Node changes width. This is distracting and incorrect behaviour. And when the mouse is removed from the node, the node with changes back. Similar for edge labels.
This is because the label measurement is not being performed correctly - specifically because the canvas context font has not been set properly.
On the initial and normal render of a frame, the label measurement is NOT being performed properly.
On hover over the node, the label measurement IS properly being performed.
Partial reverse stack trace for when the hover and correct measure is performed:
on mouse move
hover object (node is identified)
request redraw
...
_requestRedraw
_drawNodes
_draw
draw
shape.draw
resize
getDimensionsFromLabel
...
Specifically note that on mouse move happens, and the mouse is hovering over a node, which is identified correctly, and _drawNodes is performed.
In the normal situation where the incorrect measurement is performed:
on mouse move
hover object (no node identified as mouse is not hovering over anything)
request redraw
...
_requestRedraw
_drawEdges
Edge.draw
...
Note here that _drawEdges is called (instead of _drawNodes), which draws the edges and then draws the nodes that the edges are connected with.
When the label is eventually processed, in this case where the edge is drawn first, when the getLongestFit is performed in LabelSplitter for the node's label, the canvas context had a font setting of 10 sans-serif (when my node font was size 14) and the measurement is calculated incorrectly, so the lines of the label aren't split at the right place.
LabelSplitter needs to set the canvas context font to the correct value for the current block, before measuring the text - so that the node width and edge label width doesn't change incorrectly on hover... and so that width constraint is correctly applied on a normal frame render.
PR coming.
The text was updated successfully, but these errors were encountered:
channeladam
added a commit
to channeladam/visjs-network
that referenced
this issue
Jan 19, 2019
Prerequisites:
When hovering over a such a Node or Edge, even though chosen settings are disabled, the Node changes width. This is distracting and incorrect behaviour. And when the mouse is removed from the node, the node with changes back. Similar for edge labels.
This is because the label measurement is not being performed correctly - specifically because the canvas context font has not been set properly.
On the initial and normal render of a frame, the label measurement is NOT being performed properly.
On hover over the node, the label measurement IS properly being performed.
Partial reverse stack trace for when the hover and correct measure is performed:
Specifically note that on mouse move happens, and the mouse is hovering over a node, which is identified correctly, and _drawNodes is performed.
In the normal situation where the incorrect measurement is performed:
Note here that _drawEdges is called (instead of _drawNodes), which draws the edges and then draws the nodes that the edges are connected with.
When the label is eventually processed, in this case where the edge is drawn first, when the getLongestFit is performed in LabelSplitter for the node's label, the canvas context had a font setting of 10 sans-serif (when my node font was size 14) and the measurement is calculated incorrectly, so the lines of the label aren't split at the right place.
LabelSplitter needs to set the canvas context font to the correct value for the current block, before measuring the text - so that the node width and edge label width doesn't change incorrectly on hover... and so that width constraint is correctly applied on a normal frame render.
PR coming.
The text was updated successfully, but these errors were encountered: