YATiSh
Yet Another TIme SHeet
yatishPlot.h
Go to the documentation of this file.
1 /********************************************************************
2  * Name: yatishPlot.h
3  * Purpose: Declares the (virtual) class for yatish data plots
4  * Author: Nicolas PĂ©renne (nicolas.perenne@eif-services.eu)
5  * Created: 2023-07-05
6  * Copyright: EIF-services (https://www.eif-services.eu/yatish)
7  * License: GPLv3
8  ********************************************************************/
9 
10 #ifndef YATISHPLOT_H
11 #define YATISHPLOT_H
12 
13 #include "yatishDBsqlite.h"
14 #include "yatishTypes.h"
15 
34 class yatishPlot {
35  public:
37  virtual ~yatishPlot () {}
38  void SetFirstDay (const wxDateTime& dt) { firstDay = dt; }
39  void SetLastDay (const wxDateTime& dt) { lastDay = dt; }
52  virtual void PlotData (ClusterType, AggregateType) = 0;
53  virtual wxString TotalFormatted () {return wxEmptyString;}
54  protected:
56  static string legends [3];
57  static vector<double> vector_X,
59  vector_Y [3];
61  wxDateTime firstDay, lastDay;
63  void GetWeekRange (unsigned int &, unsigned int &);
64  void ComputePie (ClusterType);
65  wxString TotalFormattedFromPie ();
67  virtual void SetRangeX () {}
68  virtual void ClearCurves () {}
69  private:
70  static bool data_loaded;
71  static RawData big_data;
72  void Aggregates ();
73  void NoMoreThan4 ();
75 };
76 
80 class yatishMathPlot: public yatishPlot, public mpWindow {
81  public:
82  yatishMathPlot (wxWindow *, yatishDBsqlite *);
84  private:
85  mpFXYVector * vector1 [3], * vector2 [3];
86  mpScaleX * Xaxis;
87  mpScaleY * Yaxis;
88  mpInfoLegend * legend;
89  void SetRangeX ();
90  void ClearCurves ();
91 };
92 
97 class yatishFreeSerie: public yatishPlot, public wxChartPanel {
98  public:
99  yatishFreeSerie (wxWindow *, yatishDBsqlite *);
101  private:
102  XYSimpleDataset * dataset;
103  XYSerie * series [3];
104  XYLineRenderer * renderer;
105  XYPlot * plot;
106  NumberAxis * leftAxis, * bottomAxis;
107  Legend * legend;
108  Chart * chart;
109  void SetRangeX ();
110  void ClearCurves ();
111 };
112 
116 class yatishFreePie: public yatishPlot, public wxChartPanel {
117  public:
118  yatishFreePie (wxWindow *, yatishDBsqlite *);
120  wxString TotalFormatted () {return TotalFormattedFromPie();}
121  private:
122  wxString categories [4];
123  double data [4];
124  CategorySimpleDataset * dataset;
125  ColorScheme * colorScheme;
126  CategoryRenderer * renderer;
127  PiePlot * plot;
128  Legend * legend;
129  Chart * chart;
130 };
131 
138 class yatishChartSerie: public yatishPlot, public wxPanel {
139  public:
140  yatishChartSerie (wxWindow *, yatishDBsqlite *);
142  private:
143  wxBoxSizer * panelSizer;
144  wxVector<wxString> labels;
145  wxVector<wxDouble> points [3];
146  wxChartsCategoricalData::ptr chartData;
147  wxChartsDoubleDataset * data [3];
148  wxChartsDoubleDataset::ptr dataset [3];
149  wxLineChartCtrl * lineChartCtrl;
150  wxChartsLegendCtrl * legendCtrl;
153  void ResetChart ();
154  void CreateChart ();
155  void SetRangeX ();
156 };
157 
160 class yatishChartPie: public yatishPlot, public wxPanel {
161  public:
162  yatishChartPie (wxWindow *, yatishDBsqlite *);
164  wxString TotalFormatted () {return TotalFormattedFromPie();}
165  private:
166  wxBoxSizer * panelSizer;
167  wxPieChartData::ptr chartData;
168  wxVector <wxChartSliceData> slices;
169  wxPieChartCtrl * pieChartCtrl;
170  wxChartsLegendCtrl * legendCtrl;
172  void ResetChart ();
173 };
174 #endif // YATISHPLOT_H
Pie chart for panel #3 using wxCharts.
Definition: yatishPlot.h:160
void PlotData(ClusterType, AggregateType)
Plotting interface for yatishFrame:
Definition: yatishPlot.cpp:626
yatishChartPie(wxWindow *, yatishDBsqlite *)
Definition: yatishPlot.cpp:618
wxPieChartData::ptr chartData
Definition: yatishPlot.h:167
wxVector< wxChartSliceData > slices
Definition: yatishPlot.h:168
wxString TotalFormatted()
Definition: yatishPlot.h:164
wxPieChartCtrl * pieChartCtrl
Definition: yatishPlot.h:169
wxChartsLegendCtrl * legendCtrl
Definition: yatishPlot.h:170
wxBoxSizer * panelSizer
Definition: yatishPlot.h:166
Time series for panel #3 using wxCharts.
Definition: yatishPlot.h:138
wxChartsDoubleDataset * data[3]
Definition: yatishPlot.h:147
wxChartsLegendCtrl * legendCtrl
Definition: yatishPlot.h:150
wxChartsCategoricalData::ptr chartData
Definition: yatishPlot.h:146
wxBoxSizer * panelSizer
Definition: yatishPlot.h:143
yatishChartSerie(wxWindow *, yatishDBsqlite *)
Definition: yatishPlot.cpp:533
wxLineChartCtrl * lineChartCtrl
Definition: yatishPlot.h:149
wxVector< wxString > labels
Definition: yatishPlot.h:144
wxChartsDoubleDataset::ptr dataset[3]
Definition: yatishPlot.h:148
void PlotData(ClusterType, AggregateType)
Plotting interface for yatishFrame:
Definition: yatishPlot.cpp:541
wxVector< wxDouble > points[3]
Definition: yatishPlot.h:145
ClusterType currentClusters
Definition: yatishPlot.h:152
Interacts with yatish tables in a SQLite database.
Pie chart for panel #3 using wxFreeChart.
Definition: yatishPlot.h:116
CategoryRenderer * renderer
Definition: yatishPlot.h:126
ColorScheme * colorScheme
Definition: yatishPlot.h:125
double data[4]
Definition: yatishPlot.h:123
wxString categories[4]
Definition: yatishPlot.h:122
CategorySimpleDataset * dataset
Definition: yatishPlot.h:124
Legend * legend
Definition: yatishPlot.h:128
void PlotData(ClusterType, AggregateType)
Plotting interface for yatishFrame:
Definition: yatishPlot.cpp:510
wxString TotalFormatted()
Definition: yatishPlot.h:120
yatishFreePie(wxWindow *, yatishDBsqlite *)
Definition: yatishPlot.cpp:490
Chart * chart
Definition: yatishPlot.h:129
PiePlot * plot
Definition: yatishPlot.h:127
Time series for panel #3 using wxFreeChart.
Definition: yatishPlot.h:97
void PlotData(ClusterType, AggregateType)
Plotting interface for yatishFrame:
Definition: yatishPlot.cpp:450
NumberAxis * bottomAxis
Definition: yatishPlot.h:106
XYSimpleDataset * dataset
Definition: yatishPlot.h:102
XYPlot * plot
Definition: yatishPlot.h:105
yatishFreeSerie(wxWindow *, yatishDBsqlite *)
Definition: yatishPlot.cpp:412
XYSerie * series[3]
Definition: yatishPlot.h:103
Legend * legend
Definition: yatishPlot.h:107
XYLineRenderer * renderer
Definition: yatishPlot.h:104
NumberAxis * leftAxis
Definition: yatishPlot.h:106
Time series for panel #3 using wxMathPlot.
Definition: yatishPlot.h:80
mpFXYVector * vector2[3]
Definition: yatishPlot.h:85
mpInfoLegend * legend
Definition: yatishPlot.h:88
yatishMathPlot(wxWindow *, yatishDBsqlite *)
Definition: yatishPlot.cpp:333
mpScaleY * Yaxis
Definition: yatishPlot.h:87
void ClearCurves()
Definition: yatishPlot.cpp:401
mpScaleX * Xaxis
Definition: yatishPlot.h:86
void PlotData(ClusterType, AggregateType)
Plotting interface for yatishFrame:
Definition: yatishPlot.cpp:362
mpFXYVector * vector1[3]
Definition: yatishPlot.h:85
Abstract Base class for the plots of panel #3.
Definition: yatishPlot.h:34
virtual void ClearCurves()
Definition: yatishPlot.h:68
wxString TotalFormattedFromPie()
Creates a wxString with the total hours in the current pie chart.
Definition: yatishPlot.cpp:225
yatishPlot(yatishDBsqlite *)
The constructor of yatishPlot:
Definition: yatishPlot.cpp:36
static vector< double > vector_Y[3]
user selected data
Definition: yatishPlot.h:59
static RawData big_data
all timeslot records from the database
Definition: yatishPlot.h:71
virtual void SetRangeX()
Definition: yatishPlot.h:67
void Aggregates()
Builds all the weekly time series (non-clustered aggregates).
Definition: yatishPlot.cpp:90
wxDateTime lastDay
Definition: yatishPlot.h:61
void NoMoreThan4()
Modifies member pieData so that there is no more than four record.
Definition: yatishPlot.cpp:194
wxDateTime firstDay
Definition: yatishPlot.h:61
static vector< double > vector_X2
week number, counted from the first year in the time series
Definition: yatishPlot.h:58
virtual void PlotData(ClusterType, AggregateType)=0
Plotting interface for yatishFrame:
void SetLastDay(const wxDateTime &dt)
Definition: yatishPlot.h:39
static vector< double > vector_X
epoch time
Definition: yatishPlot.h:57
Map4pie pieData
total durations (between firstDay and lastDay), in minutes
Definition: yatishPlot.h:60
bool SelectData(ClusterType, AggregateType)
Updates vector_Y[3] if need be (for the plotting libraries).
Definition: yatishPlot.cpp:283
AggregateType formerAggregate
Definition: yatishPlot.h:62
static bool data_loaded
Definition: yatishPlot.h:70
virtual ~yatishPlot()
Definition: yatishPlot.h:37
virtual wxString TotalFormatted()
Definition: yatishPlot.h:53
void ComputePie(ClusterType)
Fills member pieData with data for a pie chart with 4 sectors.
Definition: yatishPlot.cpp:152
void SetFirstDay(const wxDateTime &dt)
Definition: yatishPlot.h:38
void ClusteredSeries(ClusterType)
Updates the clustered time series.
Definition: yatishPlot.cpp:238
void GetWeekRange(unsigned int &, unsigned int &)
Computes the week numbers corresponding to members firstDay and lastDay.
Definition: yatishPlot.cpp:64
static ProcessedData data
weekly times series: various aggregates and clustered sums
Definition: yatishPlot.h:55
static string legends[3]
names of the 3 weekly clustered sums, for the current clustering scheme
Definition: yatishPlot.h:56
ClusterType
Same order as yatishFrame::choiceCluster.
Definition: yatishTypes.h:58
vector< RawRecord > RawData
Definition: yatishTypes.h:25
vector< ProcessedRecord > ProcessedData
Definition: yatishTypes.h:38
map< string, unsigned long > Map4pie
Definition: yatishTypes.h:18
AggregateType
Same order as yatishFrame::choiceAggregate (except invalid of course).
Definition: yatishTypes.h:47