preprocessSeries method

  1. @override
void preprocessSeries(
  1. List<MutableSeries<D>> seriesList
)

Pre-calculates some details for the series that will be needed later during the drawing phase.

Implementation

@override
void preprocessSeries(List<MutableSeries<D>> seriesList) {
  _nodeToArcRenderElementMap.clear();
  for (final series in seriesList) {
    final elements = <SunburstArcRendererElement<D>>[];

    final measureFn = series.measureFn;

    // The seriesMeasureTotal needs to be computed from currently displayed
    // top level.
    for (var i = 0; i < series.data.length; i++) {
      final node = series.data[i] as TreeNode<Object>;
      final measure = measureFn(i);
      if (node.depth == 1 && measure != null) {}
    }

    // On the canvas, arc measurements are defined as angles from the positive
    // x axis. Start our first slice at the positive y axis instead.
    final startAngle = config.startAngle;
    final arcLength = config.arcLength;

    // No data processing is same as the regular arc renderer.
    if (series.data.isEmpty) {
      // If the series has no data, generate an empty arc element that
      // occupies the entire chart.
      //
      // Use a tiny epsilon difference to ensure that the canvas renders a
      // "full" circle, in the correct direction.
      final angle = arcLength == 2 * pi ? arcLength * .999999 : arcLength;
      final endAngle = startAngle + angle;

      final details = SunburstArcRendererElement<D>(
        startAngle: startAngle,
        endAngle: endAngle,
        index: 0,
        key: 0,
        series: series,
      );

      elements.add(details);
    } else {
      // Create SunburstArcRendererElement for each item in the tree,
      // excluding the root node.
      (series.data.first as TreeNode<D>).visit((node) {
        elements.addAll(_createArcRenderElementForNode(series, node));
      });
    }

    series.setAttr(arcElementsKey, elements);
  }
}