Provides support for opening and saving graphs from and to GraphML.
Remarks
The methods openFile and saveFile open and save GraphML.
In addition, the OPEN and SAVE commands can be enabled by setting a non-NONE storage location and registering the commands with a GraphComponent. The constructor of this class registers these commands if a GraphComponent is passed to it.
Type Details
- yfiles module
- view-graphml
- yfiles-umd modules
- view-graphml, view
- Legacy UMD name
- yfiles.graphml.GraphMLSupport
See Also
Constructors
Creates a new instance of this class.
Remarks
graphComponent
is given, the method registerCommands is called to register the OPEN and SAVE commands with that GraphComponent.Parameters
A map of options to pass to the method.
- graphComponent - GraphComponent
- graphMLIOHandler - GraphMLIOHandler
The graphMLIOHandler to use for the various I/O methods in this instance. This option sets the graphMLIOHandler property on the created object.
- storageLocation - StorageLocation
A value indicating the type of storage used by the OPEN and SAVE commands. This option sets the storageLocation property on the created object.
Examples
Properties
Gets or sets the graphMLIOHandler to use for the various I/O methods in this instance.
Remarks
See Also
Methods
Creates the HTMLInputElement that is used by the openFile methods.
Returns
- ↪HTMLInputElement
- The pre-configured element to use.
See Also
Creates the HTMLElement that is used by the saveFile method.
Remarks
Returns
- ↪HTMLElement
- The pre-configured element to use or
null
if element creation failed.
Shows a open file dialog and imports the selected GraphML file into the graph of the provided graphComponent
.
Remarks
This method is called in response to the OPEN command if storageLocation is set to a value different from NONE. It delegates to openFile, then calls fitGraphBounds and clears the UndoEngine of the graphComponent
.
Any exception thrown during loading of the GraphML file will reject the promise.
Parameters
A map of options to pass to the method.
- graphComponent - GraphComponent
- The GraphML file is imported into the graph of this GraphComponent.
- storageLocation - StorageLocation
- The storageLocation to open from. If not provided, the value of the storageLocation property is used.
Returns
- ↪Promise<IGraph>
- A promise that will resolve to the loaded graph instance or reject upon exceptions during loading. Note that if the file open dialog is canceled by the user, the promise will stay unresolved because there is no API available that can be used to determine whether the user has pressed cancel. Depending on the UA implementation it may be possible to listen to focus or other input device events on the page to detect when the user has closed the file open dialog.
See Also
Shows a open file dialog and imports the selected GraphML file into the provided graph
.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- The GraphML file is imported into this graph.
- storageLocation - StorageLocation
- The storageLocation to open from. If not provided, the value of the storageLocation property is used.
Returns
- ↪Promise<IGraph>
- A promise that will resolve to the loaded graph instance or reject upon exceptions during loading. Note that if the file open dialog is canceled by the user, the promise will stay unresolved because there is no API available that can be used to determine whether the user has pressed cancel. Depending on the UA implementation it may be possible to listen to focus or other input device events on the page to detect when the user has closed the file open dialog.
See Also
Registers the OPEN and SAVE commands on the given graphComponent
with the current storageLocation.
Parameters
A map of options to pass to the method.
- graphComponent - GraphComponent
- The GraphComponent to register the commands on.
Exports the graph as GraphML and saves it to the provided storage location.
Remarks
This method is called in response to the SAVE command if storageLocation /// is set to a value different from NONE.
Any exception thrown during loading of the GraphML file will be caught and an error message displayed to the user. For more control over error behavior it is recommended to use graphMLIOHandler directly, e.g. from a custom command handler.
Parameters
A map of options to pass to the method.
- graph - IGraph
- The graph to save as GraphML.
- storageLocation - StorageLocation
- The storageLocation to open from. If not provided, the value of the storageLocation property is used.
Returns
- ↪Promise<string>
- A promise that will either resolve to the GraphML string representation of the graph or reject upon exceptions during the save operation.