modelData property

Object get modelData

Gets a JavaScript Object that can hold programmer-defined property values for the model as a whole, rather than just for one node or one link.

By default this an object with no properties. Any properties that you add to this object will be written out by #toJson and will be restored by Model.fromJson, if the following conditions are true:

  • the property is enumerable and its name does not start with an underscore ('_')
  • the property value is not undefined and is not a function
  • the model knows how to convert the property value to JSON format
  • property values that are Objects or Arrays form a tree structure -- no shared or cyclical references

Most object classes cannot be serialized into JSON without special knowledge and processing at both ends. The #toJson and Model.fromJson methods automatically do such processing for numbers that are NaN and for objects that are of class Point, Size, Rect, Margin, Spot, Brush (but not for brush patterns), and for Geometry.

At the current time one cannot have a Diagram as a binding target. Calling #setDataProperty will work to change a property value, but there are no target bindings in any Diagrams to be updated. Because the binding mechanism is unavailable for this object, we recommend that when you want to save a model that you explicitly set properties on this object just before calling #toJson. When loading a model, call Model.fromJson and explicitly get the properties that you want to set on a Diagram.

Implementation

_i2.Object get modelData => _i4.getProperty(
      this,
      'modelData',
    );
set modelData (Object value)

Implementation

set modelData(_i2.Object value) {
  _i4.setProperty(
    this,
    'modelData',
    value,
  );
}