getLinearPoints method
List<CartesianChartPoint>
getLinearPoints(
- List<
CartesianChartPoint> points, - dynamic xValues,
- List<
num> yValues, - CartesianSeriesRenderer seriesRenderer,
- _SlopeIntercept slopeInterceptLinear,
Defines the linear points
Implementation
List<CartesianChartPoint<dynamic>> getLinearPoints(
List<CartesianChartPoint<dynamic>> points,
dynamic xValues,
List<num> yValues,
CartesianSeriesRenderer seriesRenderer,
_SlopeIntercept slopeInterceptLinear) {
num x1Linear, x2Linear;
final List<CartesianChartPoint<dynamic>> pts =
<CartesianChartPoint<dynamic>>[];
if (seriesRenderer._xAxisRenderer is DateTimeAxisRenderer) {
x1Linear = _increaseDateTimeForecast(
seriesRenderer._xAxisRenderer as DateTimeAxisRenderer,
xValues[0],
-_trendline.backwardForecast);
x2Linear = _increaseDateTimeForecast(
seriesRenderer._xAxisRenderer as DateTimeAxisRenderer,
xValues[xValues.length - 1],
_trendline.forwardForecast);
} else {
x1Linear = xValues[0] - _trendline.backwardForecast;
x2Linear = xValues[xValues.length - 1] + _trendline.forwardForecast;
}
final num y1Linear =
slopeInterceptLinear.slope * x1Linear + slopeInterceptLinear.intercept;
final num y2Linear =
slopeInterceptLinear.slope * x2Linear + slopeInterceptLinear.intercept;
pts.add(getDataPoint(
x1Linear, y1Linear, points[0], seriesRenderer, pts.length));
pts.add(getDataPoint(x2Linear, y2Linear, points[points.length - 1],
seriesRenderer, pts.length));
return pts;
}