calculate method

void calculate(
  1. double dataMin,
  2. double dataMax
)

Calculates the minimum / maximum and range values of the axis with the given minimum and maximum values from the chart data.

@param dataMin the min value according to chart data @param dataMax the max value according to chart data

Implementation

void calculate(double dataMin, double dataMax) {
  // if custom, use value as is, else use data value
  double min = _customAxisMin ? _axisMinimum! : (dataMin - _spaceMin);
  double max = _customAxisMax ? _axisMaximum! : (dataMax + _spaceMax);

  // temporary range (before calculations)
  double range = (max - min).abs();

  // in case all values are equal
  if (range == 0) {
    max = max + 1;
    min = min - 1;
  }

  _axisMinimum = min;
  _axisMaximum = max;

  // actual range
  _axisRange = (max - min).abs();
}