getEntryForHighlight method

  1. @override
Entry? getEntryForHighlight(
  1. Highlight? highlight
)
override

Get the Entry for a corresponding highlight object

@param highlight @return the entry that is highlighted

Implementation

@override
Entry? getEntryForHighlight(Highlight? highlight) {
  if (highlight!.dataIndex >= getAllData().length ||
      highlight.dataIndex < 0) {
    return null;
  }

  ChartData data = getDataByIndex(highlight.dataIndex)!;

  if (highlight.dataSetIndex! >= data.getDataSetCount()) return null;

  // The value of the highlighted entry could be NaN -
  //   if we are not interested in highlighting a specific value.

  List<Entry?> entries = data
      .getDataSetByIndex(highlight.dataSetIndex ?? 0)!
      .getEntriesForXValue(highlight.x ?? 0);
  for (Entry? entry in entries) {
    if (entry!.y == highlight.y || highlight.y!.isNaN) return entry;
  }

  return null;
}