Closed xhluca closed 6 years ago
This is expected behaviour. While the core lib accepts either the []
or { nodes: [], edges: [] }
formats, the []
format is preferred. This is consistent with the formats used in other parts of the core lib's API --- the { nodes: [], edges: [] }
format isn't allowed anywhere except the initialisation JSON. Eventually, the { nodes: [], edges: [] }
format will be deprecated, and then it will be removed altogether in Cytoscape v4.
So this React component only supports the preferred []
format.
The Tokyo railway example had its JSON generated from an export from the Cytoscape Java desktop app. Unfortunately, the Java JSON exporter isn't up-to-date and it uses the old format. However, that is something that the Cytoscape Consortium is working on.
That makes sense, thank you! I'll try out the updated examples by the Consortium once they solved the problem!
@xhlulu After further analysis, it may not be practical to drop support for the { nodes: [], edges: [] }
format in the future -- given the number of old JSON files that users have created. I've created a utility function to help with these old files: Component.normalizeElements()
You can try it in v1.1.0
Description
I tried to work through a few examples, and one problem that came up was that the element prop of the react version only accepts an array of objects, whereas the original implementation accepts both arrays and objects. Particularly, objects contain specifications for
nodes
andedges
, for example:Whereas the only format accepted (for the element prop) is the following:
Here's an example of
elements
in the object (1st) formatHere's an example of
elements
in the list (2nd) format.Files
data.json
is directly downloaded from the tokyo railway exampleApp.js
is written as such:Error Output
The console output error is:
Here is the screenshot of react app output:
Reproducing Error
Steps toward reproducing the error in command line: