deserialize method

  1. @override
void deserialize(
  1. XmlElement xml
)
override

Deserializes the FML template elements, attributes and children

Implementation

@override
void deserialize(XmlElement xml) {
  // get the tooltip
  var tooltip = Xml.getChildElement(node: xml, tag: "TOOLTIP");
  if (tooltip != null) {
    xml.children.remove(tooltip);
    var prototype = prototypeOf(tooltip);
    if (prototype != null) {
      this.tooltip = BoxModel.fromXml(this, prototype,
          expandDefault: false, scope: Scope(), data: Data());
    }
  }

  //* Deserialize */
  super.deserialize(xml);

  // replace data references
  // important that this goes here as children may also have
  // prototypes with unresolved {data.xxx} references
  Xml.setAttribute(xml, "id", id);
  xml = prototypeOf(xml) ?? xml;

  // properties
  x = Xml.get(node: xml, tag: 'x');
  y = Xml.get(node: xml, tag: 'y');
  y0 = Xml.get(node: xml, tag: 'y0');
  color = Xml.get(node: xml, tag: 'color');
  stroke = Xml.get(node: xml, tag: 'stroke');
  radius = Xml.get(node: xml, tag: 'radius');
  size = Xml.get(node: xml, tag: 'size');
  type = Xml.get(node: xml, tag: 'type');
  label = Xml.get(node: xml, tag: 'label');
  name = Xml.get(node: xml, tag: 'name');
  group = Xml.get(node: xml, tag: 'group');
  stack = Xml.get(node: xml, tag: 'stack');
  showarea = Xml.get(node: xml, tag: 'showarea');
  showline = Xml.get(node: xml, tag: 'showline');
  showpoints = Xml.get(node: xml, tag: 'showpoints');
  curved = Xml.get(node: xml, tag: 'curved');
  tooltips = Xml.get(node: xml, tag: 'tooltips');
  onclick = Xml.get(node: xml, tag: 'onclick');

  // Remove datasource listener. The parent chart will take care of this.
  if ((datasource != null) &&
      (scope != null) &&
      (scope!.datasources.containsKey(datasource))) {
    scope!.datasources[datasource!]!.remove(this);
  }

  // Setup the Series type and some internal properties for supporting it
  if (type != null) type = type?.trim().toLowerCase();
}