mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
ab324ed769
commit
405e6b6b69
4 changed files with 70 additions and 34 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue