In our application the user can create a diagram. Based on the location and attributes of the nodes, we additionally create a “line chart” below the diagram:
Currently we don’t persist any data for the line chart in the model, it is calculated on demand based on the diagram model data.
The line chart is created in the “InitialLayoutCompleted” event handler by manually adding a part with panels/shaped/textBoxes to the diagram (
The line chart is updated in the “ModelChanged” event handler by manually recreating the whole contents of the part.
Now we have the issue that warnings are thrown when the user modifies the diagram:
Change not within a transaction: !dEnumValue.Insert elements: Part#7940 new: Panel([object Object])#8847 2 go-debug.js:14 Change not within a transaction: !d location: Part#7940 old: Point(442,695) new: Point(385,695) go-debug.js:14 Change not within a transaction: !d position: Part#7940 old: Point(442,695) new: Point(385,695) go-debug.js:14 Change not within a transaction: !d desiredSize: Part#7940 old: Size(2207,NaN) new: Size(2264,NaN)
I don’t understand this, as the
InitialLayoutCompleted event should be within a transaction?
Anyways, if I try to wrap my code manually in a transaction, the gojs warnings are gone when changing the diagram. However now the undo/redo is somehow broken and the “Change not within a transaction” warnings are displayed at the time of an undo/redo.
So maybe it is a bad idea to modify the diagram in the
InitialLayoutCompleted event handler? What could I do instead?