drawMarkers method

void drawMarkers(
  1. Canvas canvas
)

draws all MarkerViews on the highlighted positions

Implementation

void drawMarkers(Canvas canvas) {
  if (_marker == null || !_drawMarkers || !valuesToHighlight()) return;

  for (int i = 0; i < _indicesToHighlight!.length; i++) {
    Highlight highlight = _indicesToHighlight![i];

    IDataSet? dataset =
        _data?.getDataSetByIndex(highlight.dataSetIndex ?? 0)!;

    Entry? e = _data?.getEntryForHighlight(_indicesToHighlight![i]);
    if (e == null || dataset == null) continue;
    int entryIndex = dataset.getEntryIndex2(e);
    // make sure entry not null
    if (entryIndex > dataset.getEntryCount() * _animator!.getPhaseX()) {
      continue;
    }

    List<double> pos = getMarkerPosition(highlight);

    // check bounds
    if (!_viewPortHandler!.isInBounds(pos[0], pos[1])) continue;

    // callbacks to update the content
    _marker!.refreshContent(e, highlight);

    // draw the marker
    _marker!.draw(canvas, pos[0], pos[1]);
  }
}