Fuzzy node text after resizing

We got some fuzzy node text on GoJS diagram after resizing. We could reproduce it with one of GoJS example.
Could anybody please suggest some way to avoid/solve it? Thanks a lot!

The step to reproduce it:

  1. zoom out your chrome browser to 50%.
  2. open the link Page Flow
  3. zoom in your chrome browser to 100%.

You could see the fuzzy node text on the diagram.

I don’t know if we can get an event when that happens – we can look.

I know there isn’t any such event when a DIV changes size. That’s why we wrote Resizing Diagrams -- Northwoods Software.

But now that I try it, I’m finding that calling Diagram.requestUpdate() doesn’t help for this situation.

Internally we call myDiagram.computePixelRatio() to return the resolution (pixel density) of the Diagram. You can override this to demand a different ratio, but be careful, as it is different on every screen.

We only compute the native pixel ratio once, when the Diagram is created, and so if you create a new Diagram you will get an updated value. This is why its different when you refresh the page, since you’re re-creating the diagram.

You could override computePixelRatio like this:

// note: assumes that an HTML canvas is the first child of the Diagram div (true today, but not necessarily true in the future)
var ctx = myDiagram.div.firstChild.getContext('2d'); 
myDiagram.computePixelRatio = function() {
  var dpr = window['devicePixelRatio'] || 1;
  var bsr = ctx['webkitBackingStorePixelRatio'] ||
      ctx['mozBackingStorePixelRatio'] ||
      ctx['msBackingStorePixelRatio'] ||
      ctx['oBackingStorePixelRatio'] ||
      ctx['backingStorePixelRatio'] || 1;
  return dpr / bsr;
}

And then it will always have the correct value.

This override may make some optimizations impossible (we lower the pixel ratio when panning, for instance), so it may impact performance.

Thank you all for your help!

I implemented what Simon suggested in our application and it works!

Good. We’ll implement that as the default behavior in the next release, 1.7.25 (currently in beta), which should be coming out in a few days. You’ll then be able to remove that override.

It’s now released as “latest”.