Commit Graph

61 Commits

Author SHA1 Message Date
Mark Liversedge
70ed4e36e0 Voronoi diagram on chart
.. The diagram now displays on a chart, but there are a few issues.
   Will work through them as more testing done.
2021-09-30 19:00:35 +01:00
Mark Liversedge
4f005d4491 DataFilter - annotate(voronoi, centers)
.. added a new variant for annotations to plot a voronoi diagram
   via a datafilter.

   the centers are as returned by the kmeans() function so the
   x and y values follow each other (i.e. x1 x2 x3 y1 y2 y3)

.. it is ingrated into the userchart and down to the genericplot
   for the series it arrives in.

.. next commit will add the drawing code to generic plot.
2021-09-30 12:31:40 +01:00
Mark Liversedge
73d28661fa User Chart support Stacked Percent Style
.. we now support percent stack bar charts, which are useful (and
   popular) for time spent in zone style charts.
2021-08-25 08:38:25 +01:00
Mark Liversedge
ba3c0bf34e UserChart Bar/Stacked show Category on legend
.. when hovering over a bar chart its sometimes useful to see the
   category name (x-axis) on the legend.
2021-08-18 20:05:05 +01:00
Mark Liversedge
e10aac4de4 UserChart support stacked bar chart
.. initial support, relatively basic but seems to work ok.

Fixes #4012
2021-08-18 16:15:26 +01:00
Mark Liversedge
cc0bb2e6d6 UserChart Smoothing and GroupBy
.. axis settings updated to enable users to smooth and group by
   for data series on the axis.

.. since group by needs to aggregate the series also have a new
   config term to define the aggregation method (Average, Total,
   Peak et al).

.. grouping and smoothing is applied in UserChart not the Generic
   chart or plot, so this functionality will not be available from
   Python and R charts (mostly because axis management and config
   is done differently).

Fixes #3999.
2021-08-10 18:47:39 +01:00
Mark Liversedge
01e0d14757 Renaming classes
.. Tab becomes AthleteTab - since Tab is almost meaningless
   TabView becomes AbstractView - since its the base for all the views

   there are no functional changes or fixes in this commit.
2021-08-08 13:05:06 +01:00
Mark Liversedge
171760097d GenericPlot scale labels
.. the scale factor was not being applied to data labels on
   a user chart.
2021-08-06 11:46:26 +01:00
Mark Liversedge
98e49c3228 Fixup UserChart mouse interaction on a Chartspace
.. when a user chart is placed on an overview we filter mouse
   events from the chartspace and not the widget due to
   events being discarded.

   See this issue for more details:
   https://github.com/GoldenCheetah/GoldenCheetah/issues/3992
2021-08-03 22:38:15 +01:00
Mark Liversedge
72f91c31a8 Fix user chart axis color
.. when using named colors the axis was always black because
   the color was not being translated via the RGBColor macro.
2021-08-03 15:51:36 +01:00
Mark Liversedge
155273232f User Chart on Overview - Part 2 of 3
.. User charts can be scaled (lines, texts, markers, legend)

.. Plot area background color honours overview card color
   when we're on an overview.

.. when adding a user chart to an overview make it span a couple
   of columns and 3 times deeper than a metric tile.

NOTE:

   There are two bugs that need to be squashed individually
   and are related to user charts on overview:

   1. Mouse event handling seems to be broken for user
      charts in Overview.

   2. User chart axis colors are always black when the series
      are configured to use named colors.
2021-08-03 14:36:35 +01:00
Mark Liversedge
df1d83c357 User Charts and the Configured Colors - Part 1 of 2
.. When creating user charts we can now select a standard color as
   configured in appearances.

.. This means users can select e.g. the "Power color" when plotting a
   power series.

.. The second part of this commit will update the themes to ensure that
   the standard color settings are appropriate for the background (as
   they are inappropriate currently. e.g. Critical power is always
   yellow, even on a light background).
2021-05-22 12:49:55 +01:00
Mark Liversedge
9a0b6e0bc7 qSort is deprecated, use std::sort
.. mostly straight replacement as qt5 containers are templated
   and qSort semantics are the same as std::sort

.. prepping for Qt6.2 which is due late 2021.

Signed-off-by: Mark Liversedge <liversedge@gmail.com>
2021-05-21 11:30:46 +01:00
Mark Liversedge
fbd095a2d4 Split Global and Athlete configuration
.. Global settings (themes, metadata etc) are now maintained
   in the config dialog as in the past, whilst athlete settings
   (such as zones, measures etc) are now maintained in a new
   config dialog accessible from the athlete view (gear icon).

.. Config changes are communicated via two signals;
   * Context::configChanged(qint32)
   * GlobalContext::configChanged(qint32)

   Crucially, all global context signals are cascaded through
   the athlete contexts-- so athlete specific widgets only
   need to connect to the athlete context signal (and will get
   athlete and global config change notifications).

   Whilst global widgets such as the sidebar and mainwindow
   need only connect to the globalcontext signal since they
   are not interested in athlete specific details.

[publish binaries]
2020-08-22 11:36:24 +01:00
Mark Liversedge
1d9f570ed8 Introduce a Global Context
.. GlobalContext::context() provides a global context that is not
   tied to an athlete or MainWindow.

.. At present it just offers signals for config changes but will
   likely see more context move across as the application preferences
   and athlete configuration are separated as we enhance support
   for multiple athletes.
2020-08-11 22:16:13 +01:00
Mark Liversedge
c52a861a9a User Chart refresh on filter changes
.. quite a few of the standard signals are ignored. this one fixes
   up refresh when the home filters are changed.
2020-07-29 21:38:38 +01:00
Mark Liversedge
947393914f Generic Chart Click-thru 2a of 2b
.. Scatter chart click thru from trends.

.. Need to decide how click thru will work from a line chart as the UX
   doesn't quite work as the auto hover points are elusive (they move
   when you go to click on them). Will review and fixup shortly.
2020-07-17 17:59:53 +01:00
Mark Liversedge
3bf2f13764 Generic Chart Click-thru 1 of 2
.. Enable click through from the data points on a generic chart
   when on trends view.

.. This commit includes the 'addCurve' bindings to pass the
   activity filenames from R, Python and the User Chart.

.. It also includes a new DataFilter function 'filename' to
   get a vector of strings that are the filenames for the
   activities in the selected date range (or the filename
   for the currently selected activity).

.. The second commit will include the interaction code for
   GenericPlot to click-thru a selection.
2020-07-17 13:37:06 +01:00
Mark Liversedge
b9039e7767 Generic Chart Nits
.. legends can have spaces in them (painting error) and you can now
   hover over a slide to see its value.
2020-07-14 19:57:50 +01:00
Mark Liversedge
2874bf6bfa DataFilter vectors - metadata()
.. metadata("name") returns the value for the metadata field on analysis
   view or a vector of values if on trends view.

.. also fixed a few nits when working with category data on the user
   chart; sort/multisort had bugs, blank labels and pie chart legend.
2020-07-13 22:45:32 +01:00
Mark Liversedge
4b93632b42 User Chart Pie and Bar charts now work
.. since we can now set category data using string vectors we can
   support bar and pie charts in the user chart.

.. there were a few issues switching between bar and pie charts
   related to the way axes were being configured that have been
   resolved in this commit.
2020-07-13 20:56:24 +01:00
Mark Liversedge
df2d436a02 User, R and Python Chart fill curves
.. add ability to plot filled curves.
2020-06-10 19:59:21 +01:00
Mark Liversedge
9bd6cff3e3 Fix scatter plot hover <25 points
.. the generic plot didn't register quadtrees if it thought they didn't
   contain any nodes, but didn't take into account the fact the root
   node could contain up to 25 points.
2020-05-08 21:33:15 +01:00
Mark Liversedge
fc02b8a38b GenericChart Data Labels
.. allow data labels for points on the chart, added to User, R and
   Python chart addCurve() etc.

.. NOTE: opengl painting ignores this setting so should be disabled
         for data series that want labels. We do not do this
         automatically, but might consider that later.
2020-03-20 08:06:56 +00:00
Mark Liversedge
2a08c4c2b2 Nits from last commit
.. windows builds bork as bool function doesn't return anything

.. left in a couple of debug messages.
2020-03-19 19:43:01 +00:00
Mark Liversedge
e2e9fe63cf Generic Chart Label Annotation - Part 1 of 2
.. add annotation labels from within  a datafilter, ultimately
   gets shown alongside the legend in generic plot.

.. this only works from a user chart, so need to add an equivalent
   API to call from Python and R.
2020-03-19 17:30:52 +00:00
Mark Liversedge
d7603b7fa6 GenericPlot fixup hover/hide with decorations
.. when adding symbols to lines or lines to a scatter we
   need to show/hide the decoration with the main series.

.. in addition if the decoration is the only thing visible
   e.g. symbols for line (with no line style) then still
   need to show the hover on the symbols.
2020-03-17 19:28:21 +00:00
Mark Liversedge
95eca909c1 Lines can have symbols, scatters can have lines
.. honour both the symbol and line style settigns for curves. This
   means you can have a series on a line chart that is dots and a
   series on a scatter that is a line.

.. need to think about best way to manage hover, but suspect it should
   only apply when a line chart has a series with no line but has
   symbols -- we should hover on them. Currently they are ignored.
2020-03-16 16:30:36 +00:00
Mark Liversedge
3f9774b2c2 Generic Chart Series - show on legend
.. you can now configure if a series is shown on the legend, this is
   for lines or curves that are there for illustration but do not
   need to be displayed in the legend / hovered.
2020-03-15 18:43:11 +00:00
Mark Liversedge
87d1af5b13 Generic Plot Time Axis support
.. support for axes that are time based, assuming the user has
   supplied in seconds starting from 0 (which is true for an
   activity).

.. since QT charts requires times to be in MS since Epoch
   and we don't know if we need to convert from seconds
   until the axis is configured the series data is updated
   just before charts are created in GenericChart.

   This means that anyone using generic plot directly will
   need to do this conversion. For this reason all integration
   across the GC codebase should be via GenericChart.

   R, Python and now User charts integrate via Generic Chart
   so this should not really be an issue.
2020-03-13 10:11:50 +00:00
Mark Liversedge
694be2d111 Generic Plot DateTime Axis support
.. when plotting on trends view the x-axis is a date based range.

.. still need to update for time based axis when looking at activities.
2020-03-12 19:26:51 +00:00
Mark Liversedge
c0869f5caf GenericPlot auto axis min/max
.. set the axis min max from the series data if not set explicitly
   by the user. Especially useful for date ranges.
2020-03-12 15:48:43 +00:00
Mark Liversedge
9e7f843d43 Generic Plot log axes
.. add log axes support.
2020-03-09 11:06:54 +00:00
Mark Liversedge
b8a6fd40e3 Fix generic plot missing top label on axis
.. when working out the hover area. this is because the first label
   is sometimes aligned above the plot area. so we look a little higher.
2020-03-09 08:35:11 +00:00
Mark Liversedge
0f1224bb35 User Chart (Part 1 of 2)
.. basic user chart only on analysis view. Users can specify
   a data filter script to prepare data for the x and y axes.
   It uses the generic chart to visualise so one step closer
   to a UX where all charts have the same behaviour.

.. will need to update to place on trends view, including
   updating the way userdata works and possibly adding a
   few new functions to support working with models and mmp
   data amongst a few other things.

.. likely contains quite a few nits as most of the code
   is related to configuration and is a bit thorny.
2020-03-08 16:29:42 +00:00
Mark Liversedge
876ce83c96 Add QChart to Python Chart (4c of 5)
Fixup stack view a) minimum height for plots, b) added a
scroll area to manage more plots than fit on the screen
and will layout horizontally or vertically.
2020-03-02 20:11:56 +00:00
Mark Liversedge
85cbbc3840 Add QChart to Python Chart (4b of 5)
Stack charts now when set as an option, in which case all
data series are given their own plot.

Or alternatively, where data series have different x-axis
names, they get a plot for each x-axis.

Need to fixup a) minimum height as can get squashed and
b) scroll area needed as well as c) layout direction.
2020-03-02 18:59:07 +00:00
Mark Liversedge
e83c9e8bb3 GenericPlot legend placement and line styles
.. updated to support different linestyles and also legend can
   now be placed above, below, left or right of the chart and
   orientated to list series vertically or horizontally.

.. the vertical legend is a bit ugly as nothing lines up, will
   fix up separately.
2020-03-01 17:37:07 +00:00
Mark Liversedge
6ce905509f Add QChart to Python Chart (3i of 5)
Isolate curves by hovering on axis for scatter and line
charts. Also added horizontal guide line and click to
add horizontal annotations (but not added yet).

Annotations will come later, but added as was the right
part of the code.

Also tidied up a bit of the paint code in selection tool
since it was a bit messy.
2020-03-01 10:03:47 +00:00
Mark Liversedge
ec24536f65 Blank texts break axes login in GenericPlot
.. for some reason in earlier version of Qt Charts there are errant
   items in the same area as the axes that are blank, these break
   the code that derives the axes rectangles in Qt Charts <= 5.10
2020-02-29 16:47:50 +00:00
Mark Liversedge
c81576e311 Fix axis paint of cursor values in GenericPlot
.. now we have the axis rectangle (previous commit) we can paint
   the cursor values in the axis rather than on the canvas. Lots
   of work to fix a cosmetic issue, but damn, it was worth it.
2020-02-29 14:01:23 +00:00
Mark Liversedge
73be187b15 QAbstractAxis get rect
.. amongst a few other nits when a plot is resized or the chart is
   being finalised we get the scene rectangle for each of the axes.

   This is so we can trap when the mouse hovers over an axis and
   also so we can paint the current mouse coordinates on the y-axis
   in the scatter plot (they are painted on the canvas at present
   and paint over each other causing a nasty artefact).

   Will fixup y-value cursor tracking shortly.
2020-02-29 11:50:06 +00:00
Mark Liversedge
40195ab0ce Fixup GenericPlot legend hover for pie and bar charts
.. the legend is mostly static for pie and bar charts
   but should be shown nonetheless.
2020-02-28 18:56:21 +00:00
Mark Liversedge
0ecfa0e67e Add QChart to Python Chart (3h of 5)
Use legend to select which series are plotted by clicking to
show hide a series. Hover just shows a hover background and
does not temporarily isolate the series, this may be something
to consider for later.

Applies to scatter and line charts.
2020-02-28 14:31:50 +00:00
Mark Liversedge
cee6f0329a GenericPlot refactor source files
.. created separate source files for the legend and selection tool
   classes and removed some of the interdependency.

.. partly because GenericPlot.h and GenericPlot.cpp were becoming
   unwieldy and partly to support using the generic legend in
   other charts (notably CP, LTM and AllPlot).
2020-02-24 20:20:57 +00:00
Mark Liversedge
37ebd06564 Generic Plot tidy up state transitions
.. fix a few nits when moving between states for the selection tool
   and updating the display.
2020-02-24 19:00:00 +00:00
Mark Liversedge
5ad1f1624d Fix GenericPlot performance when select active
The scene was being updated unneccessarily when it was active but
not changing (i.e. selection rectangle was stationary etc).

Added a state variable rectchanged to the selection tool to notify
the updateScene() method that nothing has changed since the last
event. So do nothing.
2020-02-24 17:48:57 +00:00
Mark Liversedge
bbc0a1f0ea Add QChart to Python Chart (3g of 5)
Added selection on line chart, uses a range selector and
works in pretty much the same way as the scatter rectangle
selector.

I've removed a lot of the calculated values from the plot
since it gets very busy very quickly.

I also noticed there is a significant performance problem
when selections are active- suspect there are a large
number of unneccessary scene updates. Will investigate.
2020-02-24 17:16:25 +00:00
Mark Liversedge
0da3142f6b Fix line chart legend when series missing
.. when no value present was miscalculating the nearest point to the
   cursor on the x-axis because distance was calculated as a large
   negative by using a series point value of 0 (when no value was
   available). Fixed by just ignoring zero values.
2020-02-24 11:49:46 +00:00
Mark Liversedge
16a5cb0c6f X-Axis in Generic Plot Legend
.. to show the current x-axis value, missed off when concentrating
   on showing y-axis values for the data series.
2020-02-24 11:08:09 +00:00