void ChartRenderer::ScaleYFromData(const LeastSquares &lsdata) { if (lsdata.IsEmpty()) return; if (y.unscaled) { y.min = lsdata.GetMinY(); y.max = lsdata.GetMaxY(); y.unscaled = false; } else { y.min = std::min(y.min, lsdata.GetMinY()); y.max = std::max(y.max, lsdata.GetMaxY()); } if (lsdata.HasResult()) { auto y0 = lsdata.GetYAtMinX(); auto y1 = lsdata.GetYAtMaxX(); y.min = std::min({y.min, y0, y1}); y.max = std::max({y.max, y0, y1}); } if (fabs(y.max - y.min) > 50) { y.scale = (y.max - y.min); if (y.scale > 0) y.scale = (rc.bottom - rc.top - padding_bottom) / y.scale; } else { y.scale = 2000; } }
void ChartRenderer::ScaleXFromData(const LeastSquares &lsdata) { if (lsdata.IsEmpty()) return; if (x.unscaled) { x.min = lsdata.GetMinX(); x.max = lsdata.GetMaxX(); x.unscaled = false; } else { x.min = std::min(x.min, lsdata.GetMinX()); x.max = std::max(x.max, lsdata.GetMaxX()); } x.scale = (x.max - x.min); if (x.scale > 0) x.scale = (rc.right - rc.left - padding_left) / x.scale; }