Comments (4)
So you actually have cyclical references in your data? I do not believe that either Model.toJson or Model.toIncrementalJson** check for that.
For now, I do not have a good work-around for you. Are you depending on maintaining those cyclical or shared references when loading the model back in?
from gojs.
If you do really think there is a bug, some data that we can experiment with would be very helpful.
from gojs.
Hmm.. saw the below Model documentation and i guess it's a limitation that i have to get around with when it comes to integrating GOJs graph's Transaction ChangeEvents with de.polygonal.ds.Graph data structures class. (I'm storing a dynamically Graph-created de.polygonal.ds.GraphNode as a property called "node" within each GOJS Model node's data when a GOJS node is created, and each GraphNode consist of a dynamic val object where all my app-specific data is stored including positioning info). Whatever transactions made on GoJS, is mirrored onto the related de.polygonal.ds.GraphNode/Graph instances accordingly (and i also then run whatever de.polygonal.ds.Graph traversal functions to perform any pathfinding/visibility calculated preview updates, etc. in real time). The thing is, GraphNode class has a next/prev property because it's part of a linked list...which thus results in the "Too much Recursion" problem when more than 1 GraphNode is added to the Graph because Model.toJSON will scan this custom "node" property and run through the "next/prev" pointers in the node's linked list. Also, each GraphNode class instance has a reference pointer back to the Graph that it belongs to, and the Graph also consist of references back to it's GraphNodes.
In Model documentation...
Note that JSON and other textual data formats cannot faithfully store all JavaScript functions. toJson and Model.fromJson do not try to save and load functional property values. You should arrange that all such functions, including event handlers, are established by your app. toJson and Model.fromJson also cannot handle circular references; any sharing of references will be lost too. They also skip properties that are not enumerable, those whose names start with an underscore, and those whose values are undefined.
What I could do though, is perhaps, underscore prefix "_" the node property? Would that skip it? BUt anyway, I think i'm just going to avoid toIncrementalJson for now. But I think I should consider using an integer reference key ID or/and proxy helper setter/getter methods later on or something for the "node" reference, so the actual innards of the class instance doesn't get exposed to JSON.
eg. For the app-specific value object, I have sharing of certain "library" data objects between nodes.
GoJS Model GraphNode....contains
-> de.polygonal.ds.GraphNode....which contains
-> LocationPacket (unique per node) ...which contains ->
LocationDefinition (shared content between nodes),
LocationDefinitionOverwrites (shared or unique content among nodes),
LocationState (unique per node).
Basically, I need a binding system that allows changing one LocationDefinition's details to affect the visuals of all related Nodes that are using that same location definition library reference. But the data-binding paradigm is purely 1 to 1 (ie. it only visually updates the current instance being updated)...without the possibly of sharing library/theme references between nodes and having the other related nodes update as well. I guess i have to run through the model manually to visually update those nodes with any matching/related definitions via e.model.updateTargetBindings(o, "text");
.
My "text" property actually drills into the LocationPacket to see if there is an (optional) label in LocationDefinitionOverwrites or LocationDefinition itself (which can be shared between nodes).... In the end, I resorted to a getter/setter proxy using Object.defineProperty(o, "text", someProxyToHandleGetterSetterOps), because the GOJS two way databinding with conversion functions was a bit too hard to work with this situation which was more complex. I had to manually update the related nodes' bindings in the model that were sharing the same LocationDefinition when I detected a ChangedEvent for "text" property. With a getter/setter proxy, I could also handle various backend database/data-structure resolutions/linkage changes when the "text" property changes accordingly.
from gojs.
I was going to suggest making the "back-pointer" properties be non-enumerable, or prefixing them with "_", but I see now that you have updated your comment to anticipate that possibility.
Yes, using getter/setter properties is another way to solve the problem. It looks like you have a good grasp on the situation. If you have any other questions, contact us through our forum, https://forum.nwoods.com/c/gojs, or by email.
from gojs.
Related Issues (20)
- A bug in 2.2.12, when calling Diagram.makeSvg, link.geometry.figures might be null. HOT 1
- Minimal sample diagram not visible HOT 1
- TypeError: a.forEach is not a function HOT 3
- Too much data crashes the browser HOT 2
- How to get Name Key onclick marker leaflet HOT 1
- Getting issues in GuidedDraggingTool.ts HOT 1
- Please provide the source code for the Data Flow (vertical) for the angular project HOT 1
- Using gojs in node to render large layouts on the server side HOT 1
- Orthogonal + Grid Snap = Jank HOT 1
- "Error: GraphObject.make requires a class function or GoJS class name or name of an object builder, not: ScrollingTable" HOT 1
- Inconsistent snap with default grid, default gridSnap, and objects of different widths HOT 1
- Last
- when the parent node uses scaling, the gojs click event will cause an error HOT 1
- dwg support HOT 1
- Change the origin of the diagram's coordinate HOT 1
- Extracting user data for graphs/flowcharts rendering HOT 1
- Support and integration of GoJs to Excalidraw Elements HOT 2
- Compile warnings generated when using esbuild HOT 4
- Types not exported HOT 3
- v2.3.16 has console.log statement happening HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gojs.