Strange zOrder / font behavior


#1

I have an interesting situation where I have some hover over handling on a node which changes the zOrder of a link connected to it. that link has a label in the way of a TextBlock. when I change the zOrder (either by manipulating the view object directly, or by way of a property binding) the font i have set sometimes falls off and I get the default font.

Calling diagram.layout(true) right before setting the zOrder seems to alleviate the problem, but this is pretty bad in my case for performance reasons.

I’m trying to whittle this down to something I can put on jsfiddle, but any help would be greatly appreciated until then. Thanks!


#2

That does sound like a bug in our drawing code. Precisely which version of GoJS are you using? Does using the latest fix the problem? If we cannot reproduce the problem ourselves, we may need to ask you to come up with a simple example.


#3

Ok, this is actually a little more interesting than I thought. To get around the fact that gojs doesn’t support rich text, I have two labels side by side with different styled fonts that i want to appear as one string. In order to place them correctly, i call directly into the canvas context object. I take the font string from the text node, set it on the context, do some calculations to get the width, and am supposed to set the context font back. In one case, I was not setting the font back on the context, so the font of another graph object looked like it was falling off, because the object being calculated was explicitly set to the default font.

So, my fault!

However, when I found and fixed that bug, I encountered that after that, the font of the graph object that i was getting the font from would still change during this calculation phase. Odd. Also odd, the font size was set to a non integer (12.5px)

It turns out that directly setting the context’s font back to the font string of the graph object, when using non integer font sizes, is not the same as whatever happens when i set the font string via the gojs parameter object. This was surprising, but not a big deal. I just adjusted my font by half a pixel. Just following up in case this is something you want to be made aware of.

Once again, thanks for your time and your always quick responses.


#4

We do a lot of caching of resources, so “interrupting” what we do with the canvas could easily cause problems. Officially, the API does not support anyone doing anything with the DOM that is inside the DIV that the programmer provides as the diagram host element. That includes any Canvas elements that there might be.

But you could do your calculations in a separate singleton Canvas element.