aboutsummaryrefslogtreecommitdiffstats
path: root/stats/statsview.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-06 14:17:51 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-06 12:31:22 -0800
commit405e6b6b693234024ae541a74cfb9733f3b8f09d (patch)
treef95b47d547c77ed492f357118b5b87071e199b99 /stats/statsview.h
parentab324ed769b4d39816020bf649defb61cb4bff41 (diff)
downloadsubsurface-405e6b6b693234024ae541a74cfb9733f3b8f09d.tar.gz
statistics: fix chart features: regression line and median/mean
The coordinates of these were calculated when creating the feature. This is wrong, because the min/max values of the axes can change on resize to get "nice" number. Therefore, recalculate after resizing. This means that the general "LineMarker" class has to be split into two classes, one for regression lines and one for median/mean markers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/statsview.h')
-rw-r--r--stats/statsview.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/stats/statsview.h b/stats/statsview.h
index 92dbedf03..fd8ec1e2c 100644
--- a/stats/statsview.h
+++ b/stats/statsview.h
@@ -106,17 +106,27 @@ private:
void updatePosition();
};
- // A general line marker
- struct LineMarker {
+ // A regression line
+ struct RegressionLine {
std::unique_ptr<QGraphicsLineItem> item;
StatsAxis *xAxis, *yAxis;
- QPointF from, to; // In local coordinates
+ double a, b; // y = ax + b
void updatePosition();
- LineMarker(QPointF from, QPointF to, QPen pen, QtCharts::QChart *chart, StatsAxis *xAxis, StatsAxis *yAxis);
+ RegressionLine(double a, double b, QPen pen, QtCharts::QChart *chart, StatsAxis *xAxis, StatsAxis *yAxis);
+ };
+
+ // A line marking median or mean in histograms
+ struct HistogramMarker {
+ std::unique_ptr<QGraphicsLineItem> item;
+ StatsAxis *xAxis, *yAxis;
+ double val;
+ bool horizontal;
+ void updatePosition();
+ HistogramMarker(double val, bool horizontal, QPen pen, QtCharts::QChart *chart, StatsAxis *xAxis, StatsAxis *yAxis);
};
void addLinearRegression(double a, double b, double minX, double maxX, double minY, double maxY, StatsAxis *xAxis, StatsAxis *yAxis);
- void addHistogramMarker(double pos, double low, double high, const QPen &pen, bool isHorizontal, StatsAxis *xAxis, StatsAxis *yAxis);
+ void addHistogramMarker(double pos, const QPen &pen, bool isHorizontal, StatsAxis *xAxis, StatsAxis *yAxis);
StatsState state;
QtCharts::QChart *chart;
@@ -126,7 +136,8 @@ private:
std::vector<std::unique_ptr<StatsSeries>> series;
std::unique_ptr<Legend> legend;
std::vector<QuartileMarker> quartileMarkers;
- std::vector<LineMarker> lineMarkers;
+ std::vector<RegressionLine> regressionLines;
+ std::vector<HistogramMarker> histogramMarkers;
std::unique_ptr<QGraphicsSimpleTextItem> title;
StatsSeries *highlightedSeries;
StatsAxis *xAxis, *yAxis;