toSeries method

Series<TreeNode<T>, D> toSeries()

Creates a Series that contains all TreeNodes traversing from the root of this tree.

Considers the following tree:

      A
    / | \
   B  C  D      --->    [A, B, C, D, E, F]
        / \
       E   F

This method traverses from root node "A" in breadth-first order and adds all its children to a list. The order of TreeNodes in the list is based on the insertion order to children of a particular node. All TreeNodes are accessible through Series.data.

Implementation

Series<TreeNode<T>, D> toSeries() {
  final data = <TreeNode<T>>[];
  root.visit(data.add);

  return Series(
    id: id,
    data: data,
    domainFn: domainFn,
    measureFn: measureFn,
    colorFn: colorFn,
    fillColorFn: fillColorFn,
    fillPatternFn: fillPatternFn,
    patternColorFn: patternColorFn,
    strokeWidthPxFn: strokeWidthPxFn,
    labelAccessorFn: labelFn,
    insideLabelStyleAccessorFn: labelStyleFn,
  )..attributes.mergeFrom(attributes);
}