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!
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.
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.