highlightValue method

void highlightValue(
  1. double x,
  2. int dataSetIndex, {
  3. double y = double.nan,
  4. int dataIndex = -1,
  5. int stackIndex = -1,
  6. bool callListener = true,
})

Highlights the entry closest to the given x value (and, when y is a number, closest to y among entries with the same x) in one data set and redraws.

x is the x value to search for; dataSetIndex the index of the data set to search, where an index outside the data clears the highlight; y the y value to search for, NaN (the default) to accept any y value; dataIndex the index of the data object inside the data of a combined chart only; stackIndex the index inside a stacked bar, or -1 for the whole bar; callListener whether the value selected listeners are notified.

Covers Kotlin's highlightValue(x, dataSetIndex, ...) and highlightValue(x, y, dataSetIndex, ...) overloads; the Highlight overload is highlightValueOf.

Implementation

void highlightValue(
  double x,
  int dataSetIndex, {
  double y = double.nan,
  int dataIndex = -1,
  int stackIndex = -1,
  bool callListener = true,
}) {
  final dataSetCount = data?.dataSetCount ?? 0;
  if (dataSetIndex < 0 || dataSetIndex >= dataSetCount) {
    highlightValueOf(null, callListener: callListener);
  } else {
    highlightValueOf(
      Highlight(x, y, dataSetIndex, dataIndex)..stackIndex = stackIndex,
      callListener: callListener,
    );
  }
}