attachTo method

  1. @override
void attachTo(
  1. BaseChart<D> chart
)
override

Injects the behavior into a chart.

Implementation

@override
void attachTo(BaseChart<D> chart) {
  if (chart is! CartesianChart<D>) {
    throw ArgumentError(
        'RangeAnnotation can only be attached to a CartesianChart<D>');
  }

  _chart = chart;

  _view = _RangeAnnotationLayoutView<D>(
      defaultColor: defaultColor,
      labelPadding: labelPadding,
      chart: _chart,
      rangeAnnotation: this,
      layoutPaintOrder: layoutPaintOrder);

  chart.addView(_view);

  chart.addLifecycleListener(_lifecycleListener);
}