aboutsummaryrefslogtreecommitdiffstats
path: root/stats
AgeCommit message (Collapse)Author
2021-01-02statistics: implement axesGravatar Berthold Stoeger
Implement five kinds of axes: - ValueAxis: a standard axis for plotting numerical linear data. - CountAxis: a ValueAxis for plotting counts of dives. - CategoryAxis: an axis for plotting discrete variables without any notion of distance. - HistogramAxis: an axis for plotting bins with a numeric value. - DateAxis: a HistogramAxis that formats dates. The axes derive from a common virtual base class that defines a small interface, notably, returning the minimum and maximum displayed value and redrawing the axis. The mapping and painting is performed by QtCharts' axes. On the one hand, using QtCharts turned out to be too inflexible. On the other hand it allowed us to quickly prototype the charts. Ultimately, we should do our own drawing of the axis. As a testament to the inflexibility, QtCharts' axes do not allow for repeated labels is needed for quarter-based date charts (year, Q2, Q3, Q4, year, Q2, Q3, ...). Therefore the code disambiguates labels by adding unicode zero-width spaces. Wonderful. When omitting labels due to space reasons, the histogram axis attempts to show "preferred" labels. In the quarter example above, it tries to show full years. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-02statistics: add a header file defining z-valuesGravatar Berthold Stoeger
z-values determine the order in which objects on the chart are painted. To reduce chaos, collect all z-values in a header file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01statistics: implement a legend boxGravatar Berthold Stoeger
For some chart (e.g. pie charts or stacked bar charts), we want to display a legend. QtCharts' legend interface happens to be private and therefore is of no use. This introduces a legend box which is implemented using QGraphicItems, which can be placed on top of QCharts. It's very unfancy, but works for now. If there are too many items, not all are shown. Currently, the legend is configured to fill at most half of the width and half of the height of the chart. This might need some optimization. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01statistics: add color-related functionsGravatar Dirk Hohndel
Add a source file and a header file, which implement the color scheme used by the statistics module. Besides a few color constants, the centerpiece is a function that returns the color representing a bin and an appropriate label color. It picks a roughly equi-distant set of colors out of an already balanced set of 50 candidate colors. And it also picks white as text color when adding a label to a segment with a dark color. The color list was created using a tool by Gregor Aisch that is available on GitHub as https://github.com/gka/palettes to create multi-hued, multi-stop color scales that are safe for color blind people. This commit contains code from three authors. Dirk (main author): adaptive color scheme. Willem: Colors of single-bin charts and lines. Berthold: Infrastructure. Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-01statistics: add statistic variablesGravatar Berthold Stoeger
The StatisticVariable class hierarchy encapsulates the concept of a dive-variable, which can be plotted in charts either as dependend or independend variable. There are three types of these variables: 1) discrete: For example dive buddies or suit type. 2) continuous: Has a notion of linear metric - can be used as histogram or scatter plot axis. 3) numeric: Like continuous, but allows for operations such as calculating the mean or the sum over numerous dives. All variables support binning. The bins are defined per variable. Continuous variables can be converted into an arbitrary double value, which is used to be plotted on a continuous axis. Moreover, numeric variables support a number of operations, which depend on the variable. Since binning is based on different types, the code is rather template-heavy. Of course, this could be solved with unions/variants and runtime-polymorphism, but using templates was just much quicker. Notably, this uses the CRTP (curiously recurring template pattern) where a subclass passes itself as argument to the baseclass. This is a weird kind of "reverse inheritance". The StatsTranslations class is a dummy class which will be used to collect all translations of the statistics module. This includes changes by Dirk to fix compilation of the downloader. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>