-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
Description
Sometimes, when creating a graph from a mugl string instead of using ajax to fetch the mugl file, Multigraph's div has a width and/or height of 0 at the time that multigraph inspects the div size, resulting in all kinds of problems. This happens even when the div is given an explicit size in CSS.
See db078ba
and
js-multigraph/src/graphics/canvas/multigraph.js
Lines 111 to 138 in db078ba
| muglPromise.done(function (data) { | |
| try { | |
| // TODO: div size IS available here; see below. What's going on???!!! | |
| var multigraph = generateInitialGraph(data, options); | |
| deferred.resolve(multigraph); | |
| } catch (e) { | |
| options.messageHandler.error(e); | |
| } | |
| }); | |
| return deferred.promise(); | |
| }; | |
| window.multigraph.core.Multigraph.createCanvasGraphFromString = function (options) { | |
| var deferred; | |
| try { | |
| applyMixins(options); | |
| deferred = $.Deferred(); | |
| // TODO: figure this out! div size is not available here? Apparently, at this point in | |
| // code execution, the browser hasn't laid things out enough for the div to have been | |
| // assigned a size, at least sometimes??? But it IS available at the corresponding place in | |
| // createCanvasGraph above? This is worked around by the code in | |
| // src/core/multigraph.js:createGraph() that forces the div to have the size specified in | |
| // the options --- so we can work around the problem by passing an explicit size in the | |
| // options. But we need to really figure out what's going on and resolve it. | |
| var multigraph = generateInitialGraph(options.muglString, options); | |
| deferred.resolve(multigraph); |