attachTo method

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

Injects the behavior into a chart.

Implementation

@override
void attachTo(BaseChart<D> chart) {
  _chart = chart;

  _view = _LinePointLayoutView<D>(
    chart: chart,
    layoutPaintOrder: LayoutViewPaintOrder.linePointHighlighter,
    showHorizontalFollowLine: showHorizontalFollowLine,
    showVerticalFollowLine: showVerticalFollowLine,
    dashPattern: dashPattern,
    drawFollowLinesAcrossChart: drawFollowLinesAcrossChart,
    symbolRenderer: symbolRenderer,
  );

  if (chart is CartesianChart) {
    // Only vertical rendering is supported by this behavior.
    assert(
      (chart as CartesianChart).vertical,
      'Only vertical charts are supported for LinePointHighlighter.',
    );
  }

  chart
    ..addView(_view)
    ..addLifecycleListener(_lifecycleListener);
  chart
      .getSelectionModel(selectionModelType)
      .addSelectionChangedListener(_selectionChanged);
}