getPowerPoints method

List<CartesianChartPoint> getPowerPoints(
  1. List<CartesianChartPoint> points,
  2. dynamic xValues,
  3. List<num> yValues,
  4. CartesianSeriesRenderer seriesRenderer,
  5. _SlopeIntercept slopeInterceptPow,
)

Defines Power Points

Implementation

List<CartesianChartPoint<dynamic>> getPowerPoints(
    List<CartesianChartPoint<dynamic>> points,
    dynamic xValues,
    List<num> yValues,
    CartesianSeriesRenderer seriesRenderer,
    _SlopeIntercept slopeInterceptPow) {
  num x1, x2, x3;
  final int midPoint = (points.length / 2).round();
  final List<CartesianChartPoint<dynamic>> ptsPow =
      <CartesianChartPoint<dynamic>>[];
  if (seriesRenderer._xAxisRenderer is DateTimeAxisRenderer) {
    x1 = _increaseDateTimeForecast(
        seriesRenderer._xAxisRenderer as DateTimeAxisRenderer,
        xValues[0],
        -_trendline.backwardForecast);
    x2 = xValues[midPoint - 1];
    x3 = _increaseDateTimeForecast(
        seriesRenderer._xAxisRenderer as DateTimeAxisRenderer,
        xValues[xValues.length - 1],
        _trendline.forwardForecast);
  } else {
    x1 = xValues[0] - _trendline.backwardForecast;
    x1 = x1 > -1 ? x1 : 0;
    x2 = xValues[midPoint - 1];
    x3 = xValues[xValues.length - 1] + _trendline.forwardForecast;
  }
  final num y1 = x1 == 0
      ? 0
      : slopeInterceptPow.intercept * math.pow(x1, slopeInterceptPow.slope);
  final num y2 =
      slopeInterceptPow.intercept * math.pow(x2, slopeInterceptPow.slope);
  final num y3 =
      slopeInterceptPow.intercept * math.pow(x3, slopeInterceptPow.slope);
  ptsPow.add(getDataPoint(x1, y1, points[0], seriesRenderer, ptsPow.length));
  ptsPow.add(getDataPoint(
      x2, y2, points[midPoint - 1], seriesRenderer, ptsPow.length));
  ptsPow.add(getDataPoint(
      x3, y3, points[points.length - 1], seriesRenderer, ptsPow.length));
  return ptsPow;
}