Add statistics

Update README
Update TODO
This commit is contained in:
Grégory Soutadé 2010-08-18 21:28:40 +02:00
parent 74c401c8c7
commit 5da154cd48
9 changed files with 251 additions and 124 deletions

2
README
View File

@ -2,7 +2,7 @@ KissCount is personnal account software delivered under GPL v3 licence terms.
Current version is 0.1 beta (trunk version)
wxWidgets 2.8 is needed
wxWidgets 2.8 and sqlite3 is needed
A modified version of wxFreeChart is used : warning during recompilation, don't overwrite autotools files with ./configure

View File

@ -2,7 +2,7 @@ KissCount est un logiciel de gestion de comptes personnels délivré sous licenc
La version actuelle est 0.1 bêta (version du tronc)
wxWidgets 2.8 est nécessaire
wxWidgets 2.8 et sqlite3 sont nécessaire
Une version modifiée de wxFreeChart est utilisée : attention à lors de la recompilation à ne pas écraser les fichiers des autotools (pas de ./configure)

2
TODO
View File

@ -1,6 +1,6 @@
Version 0.1
Statistics
Statistics (need to update libraries and add months/years label on graph)
Copy and paste
Import/Export module
Using tabulation to navigate throw interface (Search Panel)

Binary file not shown.

View File

@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-08-14 22:00+0200\n"
"POT-Creation-Date: 2010-08-18 20:59+0200\n"
"PO-Revision-Date: \n"
"Last-Translator: Soutadé <soutade@gmail.com>\n"
"Language-Team: \n"
@ -19,6 +19,7 @@ msgstr ""
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#: src/view/PreferencesPanel.cpp:574
#: src/view/StatsPanel.cpp:288
msgid " - "
msgstr " - "
@ -39,7 +40,7 @@ msgstr " entrées trouvées"
msgid " not found, aborting"
msgstr " non trouvé, arrêt"
#: src/view/AccountPanel.cpp:936
#: src/view/AccountPanel.cpp:924
msgid " operations ?"
msgstr " opérations ?"
@ -51,7 +52,7 @@ msgstr " profil ?"
msgid "1 entry found"
msgstr "1 entrée trouvée"
#: src/view/ButtonPanel.cpp:51
#: src/view/ButtonPanel.cpp:52
msgid "About"
msgstr "A propos"
@ -65,15 +66,16 @@ msgstr "Compte"
msgid "Account "
msgstr "Le compte "
#: src/view/AccountPanel.cpp:113
#: src/view/AccountPanel.cpp:101
msgid "Account name"
msgstr "Nom du compte"
#: src/view/AccountPanel.cpp:112
#: src/view/AccountPanel.cpp:100
msgid "Account number"
msgstr "Numéro de compte"
#: src/view/PreferencesPanel.cpp:55
#: src/view/StatsPanel.cpp:256
msgid "Accounts"
msgstr "Comptes"
@ -87,12 +89,12 @@ msgstr "Montant max"
#: src/view/PreferencesPanel.cpp:340
#: src/view/PreferencesPanel.cpp:581
#: src/view/AccountPanel.cpp:931
#: src/view/AccountPanel.cpp:919
msgid "Are you sure want to delete "
msgstr "Etes vous sûr de vouloir supprimer "
#: src/view/PreferencesPanel.cpp:449
#: src/view/AccountPanel.cpp:633
#: src/view/AccountPanel.cpp:621
#: src/view/SearchPanel.cpp:345
msgid "Are you sure want to delete : \n"
msgstr "Etes vous sûr de vouloir supprimer : \n"
@ -133,7 +135,7 @@ msgstr "Changer le mot de passe"
msgid "Change password"
msgstr "Changer le mot de passe"
#: src/view/ButtonPanel.cpp:50
#: src/view/ButtonPanel.cpp:51
msgid "Change user"
msgstr "Changer d'utilisateur"
@ -145,7 +147,8 @@ msgstr "Couleur"
msgid "Confirm password "
msgstr "Confirmer le mot de passe"
#: src/view/AccountPanel.cpp:123
#: src/view/StatsPanel.cpp:130
#: src/view/AccountPanel.cpp:111
msgid "Cost repartition"
msgstr "Répartition des coûts"
@ -153,15 +156,15 @@ msgstr "Répartition des coûts"
msgid "Credit"
msgstr "Crédit"
#: src/view/AccountPanel.cpp:193
#: src/view/AccountPanel.cpp:181
msgid "Cur Credit"
msgstr "Cur Crédit"
#: src/view/AccountPanel.cpp:194
#: src/view/AccountPanel.cpp:182
msgid "Cur Debit"
msgstr "Cur Débit"
#: src/view/AccountPanel.cpp:115
#: src/view/AccountPanel.cpp:103
msgid "Current value"
msgstr "Valeur courante"
@ -187,7 +190,7 @@ msgstr "Défaut"
#: src/view/PreferencesPanel.cpp:159
#: src/view/PreferencesPanel.cpp:209
#: src/view/AccountPanel.cpp:790
#: src/view/AccountPanel.cpp:778
msgid "Delete"
msgstr "Supprimer"
@ -211,7 +214,7 @@ msgstr "Description"
#: src/view/PreferencesPanel.cpp:487
#: src/view/PreferencesPanel.cpp:526
#: src/view/PreferencesPanel.cpp:532
#: src/view/AccountPanel.cpp:927
#: src/view/AccountPanel.cpp:915
#: src/view/UsersDialog.cpp:86
#: src/view/UsersDialog.cpp:114
#: src/view/SearchPanel.cpp:134
@ -225,7 +228,7 @@ msgstr "Erreur"
msgid "Error creating original database"
msgstr "Erreur durant la création de la base de données initiale"
#: src/view/AccountPanel.cpp:116
#: src/view/AccountPanel.cpp:104
msgid "Final value"
msgstr "Valeur finale"
@ -239,12 +242,16 @@ msgstr "Fixe"
msgid "Font"
msgstr "Police"
#: src/view/StatsPanel.cpp:62
msgid "From"
msgstr "De"
#: src/view/GenerateDialog.cpp:45
msgid "From "
msgstr "De"
#: src/view/GenerateDialog.cpp:31
#: src/view/AccountPanel.cpp:787
#: src/view/AccountPanel.cpp:775
msgid "Generate month"
msgstr "Générer mois"
@ -256,7 +263,7 @@ msgstr "Courses"
msgid "Hobbies"
msgstr "Loisirs"
#: src/view/AccountPanel.cpp:114
#: src/view/AccountPanel.cpp:102
msgid "Initial value"
msgstr "Valeur initiale"
@ -274,7 +281,7 @@ msgstr "Montant max invalide"
#: src/view/SearchPanel.cpp:134
msgid "Invalid date range"
msgstr "Intervalle des dates invalide"
msgstr "Intervalle de temps invalide"
#: src/view/PreferencesPanel.cpp:526
msgid "Invalid name"
@ -288,11 +295,15 @@ msgstr "Ancien mot de passe invalide"
msgid "Invalid password"
msgstr "Mot de passe invalide"
#: src/view/StatsPanel.cpp:303
msgid "Invalide date range"
msgstr "Intervalle de temps invalide"
#: src/view/PreferencesPanel.cpp:336
msgid "It must be at least one account !"
msgstr "Il doit y avoir au moins un compte !"
#: src/view/AccountPanel.cpp:927
#: src/view/AccountPanel.cpp:915
msgid "It must be at least one month !"
msgstr "Il doit rester au mois un mois"
@ -302,6 +313,7 @@ msgstr "Kill me"
#: src/view/PreferencesPanel.cpp:566
#: src/view/PreferencesPanel.cpp:569
#: src/view/StatsPanel.cpp:303
msgid "KissCount"
msgstr "KissCount"
@ -366,7 +378,7 @@ msgstr "Frais de fonctionnement"
msgid "Operation order"
msgstr "Ordre des opérations"
#: src/view/ButtonPanel.cpp:46
#: src/view/ButtonPanel.cpp:47
msgid "Operations"
msgstr "Opérations"
@ -382,7 +394,7 @@ msgstr "Mot de passe"
msgid "Password changed"
msgstr "Mot de passe changé"
#: src/view/ButtonPanel.cpp:96
#: src/view/ButtonPanel.cpp:102
msgid ""
"Personal accounting software\n"
"\n"
@ -398,29 +410,30 @@ msgstr "Re entrez le mot de passe"
#: src/view/PreferencesPanel.cpp:540
#: src/view/PreferencesPanel.cpp:574
#: src/view/ButtonPanel.cpp:49
#: src/view/ButtonPanel.cpp:50
msgid "Preferences"
msgstr "Préférences"
#: src/view/ButtonPanel.cpp:52
#: src/view/ButtonPanel.cpp:53
msgid "Quit"
msgstr "Quitter"
#: src/view/ButtonPanel.cpp:103
#: src/view/ButtonPanel.cpp:109
msgid "Quit KissCount ?"
msgstr "Quitter KissCount ?"
#: src/view/AccountPanel.cpp:195
#: src/view/AccountPanel.cpp:183
msgid "Remains"
msgstr "Restant"
#: src/view/SearchPanel.cpp:78
#: src/view/SearchPanel.cpp:239
#: src/view/ButtonPanel.cpp:48
#: src/view/ButtonPanel.cpp:49
msgid "Search"
msgstr "Chercher"
#: src/view/AccountPanel.cpp:97
#: src/view/StatsPanel.cpp:122
#: src/view/AccountPanel.cpp:85
msgid "Serie 1"
msgstr "Série 1"
@ -428,19 +441,24 @@ msgstr "Série 1"
msgid "Shared"
msgstr "Partagé"
#: src/view/ButtonPanel.cpp:47
#: src/view/StatsPanel.cpp:288
#: src/view/ButtonPanel.cpp:48
msgid "Statistics"
msgstr "Statistiques"
#: src/view/StatsPanel.cpp:69
msgid "To"
msgstr "A"
#: src/view/GenerateDialog.cpp:52
msgid "To "
msgstr "A"
#: src/view/AccountPanel.cpp:177
#: src/view/AccountPanel.cpp:165
msgid "Total Credit"
msgstr "Total Crédit"
#: src/view/AccountPanel.cpp:178
#: src/view/AccountPanel.cpp:166
msgid "Total Debit"
msgstr "Total Débit"
@ -468,51 +486,51 @@ msgstr "Utilisateur"
msgid "Users"
msgstr "Utilisateurs"
#: src/view/wxUI.cpp:97
#: src/view/wxUI.cpp:110
msgid "april"
msgstr "avril"
#: src/view/wxUI.cpp:101
#: src/view/wxUI.cpp:114
msgid "august"
msgstr "août"
#: src/view/wxUI.cpp:105
#: src/view/wxUI.cpp:118
msgid "december"
msgstr "décembre"
#: src/view/wxUI.cpp:95
#: src/view/wxUI.cpp:108
msgid "february"
msgstr "février"
#: src/view/wxUI.cpp:94
#: src/view/wxUI.cpp:107
msgid "january"
msgstr "janvier"
#: src/view/wxUI.cpp:100
#: src/view/wxUI.cpp:113
msgid "july"
msgstr "juillet"
#: src/view/wxUI.cpp:99
#: src/view/wxUI.cpp:112
msgid "june"
msgstr "juin"
#: src/view/wxUI.cpp:96
#: src/view/wxUI.cpp:109
msgid "march"
msgstr "mars"
#: src/view/wxUI.cpp:98
#: src/view/wxUI.cpp:111
msgid "may"
msgstr "mai"
#: src/view/wxUI.cpp:104
#: src/view/wxUI.cpp:117
msgid "november"
msgstr "novembre"
#: src/view/wxUI.cpp:103
#: src/view/wxUI.cpp:116
msgid "october"
msgstr "octobre"
#: src/view/wxUI.cpp:102
#: src/view/wxUI.cpp:115
msgid "september"
msgstr "septembre"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-08-14 22:00+0200\n"
"POT-Creation-Date: 2010-08-18 20:59+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -16,7 +16,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/view/PreferencesPanel.cpp:574
#: src/view/PreferencesPanel.cpp:574 src/view/StatsPanel.cpp:288
msgid " - "
msgstr ""
@ -34,7 +34,7 @@ msgstr ""
msgid " not found, aborting"
msgstr ""
#: src/view/AccountPanel.cpp:936
#: src/view/AccountPanel.cpp:924
msgid " operations ?"
msgstr ""
@ -46,7 +46,7 @@ msgstr ""
msgid "1 entry found"
msgstr ""
#: src/view/ButtonPanel.cpp:51
#: src/view/ButtonPanel.cpp:52
msgid "About"
msgstr ""
@ -58,15 +58,15 @@ msgstr ""
msgid "Account "
msgstr ""
#: src/view/AccountPanel.cpp:113
#: src/view/AccountPanel.cpp:101
msgid "Account name"
msgstr ""
#: src/view/AccountPanel.cpp:112
#: src/view/AccountPanel.cpp:100
msgid "Account number"
msgstr ""
#: src/view/PreferencesPanel.cpp:55
#: src/view/PreferencesPanel.cpp:55 src/view/StatsPanel.cpp:256
msgid "Accounts"
msgstr ""
@ -79,11 +79,11 @@ msgid "Amount to"
msgstr ""
#: src/view/PreferencesPanel.cpp:340 src/view/PreferencesPanel.cpp:581
#: src/view/AccountPanel.cpp:931
#: src/view/AccountPanel.cpp:919
msgid "Are you sure want to delete "
msgstr ""
#: src/view/PreferencesPanel.cpp:449 src/view/AccountPanel.cpp:633
#: src/view/PreferencesPanel.cpp:449 src/view/AccountPanel.cpp:621
#: src/view/SearchPanel.cpp:345
msgid "Are you sure want to delete : \n"
msgstr ""
@ -121,7 +121,7 @@ msgstr ""
msgid "Change password"
msgstr ""
#: src/view/ButtonPanel.cpp:50
#: src/view/ButtonPanel.cpp:51
msgid "Change user"
msgstr ""
@ -133,7 +133,7 @@ msgstr ""
msgid "Confirm password "
msgstr ""
#: src/view/AccountPanel.cpp:123
#: src/view/StatsPanel.cpp:130 src/view/AccountPanel.cpp:111
msgid "Cost repartition"
msgstr ""
@ -141,15 +141,15 @@ msgstr ""
msgid "Credit"
msgstr ""
#: src/view/AccountPanel.cpp:193
#: src/view/AccountPanel.cpp:181
msgid "Cur Credit"
msgstr ""
#: src/view/AccountPanel.cpp:194
#: src/view/AccountPanel.cpp:182
msgid "Cur Debit"
msgstr ""
#: src/view/AccountPanel.cpp:115
#: src/view/AccountPanel.cpp:103
msgid "Current value"
msgstr ""
@ -174,7 +174,7 @@ msgid "Default"
msgstr ""
#: src/view/PreferencesPanel.cpp:159 src/view/PreferencesPanel.cpp:209
#: src/view/AccountPanel.cpp:790
#: src/view/AccountPanel.cpp:778
msgid "Delete"
msgstr ""
@ -191,7 +191,7 @@ msgstr ""
#: src/view/PreferencesPanel.cpp:336 src/view/PreferencesPanel.cpp:359
#: src/view/PreferencesPanel.cpp:378 src/view/PreferencesPanel.cpp:468
#: src/view/PreferencesPanel.cpp:487 src/view/PreferencesPanel.cpp:526
#: src/view/PreferencesPanel.cpp:532 src/view/AccountPanel.cpp:927
#: src/view/PreferencesPanel.cpp:532 src/view/AccountPanel.cpp:915
#: src/view/UsersDialog.cpp:86 src/view/UsersDialog.cpp:114
#: src/view/SearchPanel.cpp:134 src/view/SearchPanel.cpp:144
#: src/view/SearchPanel.cpp:158 src/view/SearchPanel.cpp:169
@ -202,7 +202,7 @@ msgstr ""
msgid "Error creating original database"
msgstr ""
#: src/view/AccountPanel.cpp:116
#: src/view/AccountPanel.cpp:104
msgid "Final value"
msgstr ""
@ -215,11 +215,15 @@ msgstr ""
msgid "Font"
msgstr ""
#: src/view/StatsPanel.cpp:62
msgid "From"
msgstr ""
#: src/view/GenerateDialog.cpp:45
msgid "From "
msgstr ""
#: src/view/GenerateDialog.cpp:31 src/view/AccountPanel.cpp:787
#: src/view/GenerateDialog.cpp:31 src/view/AccountPanel.cpp:775
msgid "Generate month"
msgstr ""
@ -231,7 +235,7 @@ msgstr ""
msgid "Hobbies"
msgstr ""
#: src/view/AccountPanel.cpp:114
#: src/view/AccountPanel.cpp:102
msgid "Initial value"
msgstr ""
@ -263,11 +267,15 @@ msgstr ""
msgid "Invalid password"
msgstr ""
#: src/view/StatsPanel.cpp:303
msgid "Invalide date range"
msgstr ""
#: src/view/PreferencesPanel.cpp:336
msgid "It must be at least one account !"
msgstr ""
#: src/view/AccountPanel.cpp:927
#: src/view/AccountPanel.cpp:915
msgid "It must be at least one month !"
msgstr ""
@ -276,6 +284,7 @@ msgid "Kill me"
msgstr ""
#: src/view/PreferencesPanel.cpp:566 src/view/PreferencesPanel.cpp:569
#: src/view/StatsPanel.cpp:303
msgid "KissCount"
msgstr ""
@ -337,7 +346,7 @@ msgstr ""
msgid "Operation order"
msgstr ""
#: src/view/ButtonPanel.cpp:46
#: src/view/ButtonPanel.cpp:47
msgid "Operations"
msgstr ""
@ -353,7 +362,7 @@ msgstr ""
msgid "Password changed"
msgstr ""
#: src/view/ButtonPanel.cpp:96
#: src/view/ButtonPanel.cpp:102
msgid ""
"Personal accounting software\n"
"\n"
@ -365,28 +374,28 @@ msgid "Please retype new password"
msgstr ""
#: src/view/PreferencesPanel.cpp:540 src/view/PreferencesPanel.cpp:574
#: src/view/ButtonPanel.cpp:49
#: src/view/ButtonPanel.cpp:50
msgid "Preferences"
msgstr ""
#: src/view/ButtonPanel.cpp:52
#: src/view/ButtonPanel.cpp:53
msgid "Quit"
msgstr ""
#: src/view/ButtonPanel.cpp:103
#: src/view/ButtonPanel.cpp:109
msgid "Quit KissCount ?"
msgstr ""
#: src/view/AccountPanel.cpp:195
#: src/view/AccountPanel.cpp:183
msgid "Remains"
msgstr ""
#: src/view/SearchPanel.cpp:78 src/view/SearchPanel.cpp:239
#: src/view/ButtonPanel.cpp:48
#: src/view/ButtonPanel.cpp:49
msgid "Search"
msgstr ""
#: src/view/AccountPanel.cpp:97
#: src/view/StatsPanel.cpp:122 src/view/AccountPanel.cpp:85
msgid "Serie 1"
msgstr ""
@ -394,19 +403,23 @@ msgstr ""
msgid "Shared"
msgstr ""
#: src/view/ButtonPanel.cpp:47
#: src/view/StatsPanel.cpp:288 src/view/ButtonPanel.cpp:48
msgid "Statistics"
msgstr ""
#: src/view/StatsPanel.cpp:69
msgid "To"
msgstr ""
#: src/view/GenerateDialog.cpp:52
msgid "To "
msgstr ""
#: src/view/AccountPanel.cpp:177
#: src/view/AccountPanel.cpp:165
msgid "Total Credit"
msgstr ""
#: src/view/AccountPanel.cpp:178
#: src/view/AccountPanel.cpp:166
msgid "Total Debit"
msgstr ""
@ -431,50 +444,50 @@ msgstr ""
msgid "Users"
msgstr ""
#: src/view/wxUI.cpp:97
#: src/view/wxUI.cpp:110
msgid "april"
msgstr ""
#: src/view/wxUI.cpp:101
#: src/view/wxUI.cpp:114
msgid "august"
msgstr ""
#: src/view/wxUI.cpp:105
#: src/view/wxUI.cpp:118
msgid "december"
msgstr ""
#: src/view/wxUI.cpp:95
#: src/view/wxUI.cpp:108
msgid "february"
msgstr ""
#: src/view/wxUI.cpp:94
#: src/view/wxUI.cpp:107
msgid "january"
msgstr ""
#: src/view/wxUI.cpp:100
#: src/view/wxUI.cpp:113
msgid "july"
msgstr ""
#: src/view/wxUI.cpp:99
#: src/view/wxUI.cpp:112
msgid "june"
msgstr ""
#: src/view/wxUI.cpp:96
#: src/view/wxUI.cpp:109
msgid "march"
msgstr ""
#: src/view/wxUI.cpp:98
#: src/view/wxUI.cpp:111
msgid "may"
msgstr ""
#: src/view/wxUI.cpp:104
#: src/view/wxUI.cpp:117
msgid "november"
msgstr ""
#: src/view/wxUI.cpp:103
#: src/view/wxUI.cpp:116
msgid "october"
msgstr ""
#: src/view/wxUI.cpp:102
#: src/view/wxUI.cpp:115
msgid "september"
msgstr ""

View File

@ -1071,6 +1071,8 @@ void Database::GetStats(User* user, const wxString& monthFrom, const wxString& y
for (accountIt = user->_accounts.begin(); accountIt != user->_accounts.end(); accountIt++)
{
req = wxT("SELECT month, year, amount FROM account_amount WHERE account ='") + accountIt->id + wxT("'");
req += wxT(" AND (year > '") + yearFrom + wxT("' OR (year == '") + yearFrom + wxT("' AND month >= '") + monthFrom + wxT("'))");
req += wxT(" AND (year < '") + yearTo + wxT("' OR (year == '") + yearTo + wxT("' AND month <= '") + monthTo + wxT("'))");
EXECUTE_SQL_QUERY(req, set, );
@ -1095,7 +1097,6 @@ void Database::GetStats(User* user, const wxString& monthFrom, const wxString& y
req += wxT(" OR user='") + user->_id + wxT("')");
req += wxT(" AND (year > '") + yearFrom + wxT("' OR (year == '") + yearFrom + wxT("' AND month >= '") + monthFrom + wxT("'))");
req += wxT(" AND (year < '") + yearTo + wxT("' OR (year == '") + yearTo + wxT("' AND month <= '") + monthTo + wxT("'))");
req += wxT(" AND amount < 0");

View File

@ -19,24 +19,65 @@ along with KissCount. If not, see <http://www.gnu.org/licenses/>.
#include "StatsPanel.h"
StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent)
enum {RANGE_ID=1, ACCOUNTS_ID};
BEGIN_EVENT_TABLE(StatsPanel, wxPanel)
EVT_CHOICE(RANGE_ID, StatsPanel::OnRangeChange)
EVT_CHECKLISTBOX(ACCOUNTS_ID, StatsPanel::OnAccountsChange)
END_EVENT_TABLE()
StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent), _plot(NULL), _chart(NULL)
{
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *hbox2 = new wxBoxSizer(wxHORIZONTAL);
_hbox2 = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *vbox2 = new wxBoxSizer(wxVERTICAL);
_vbox2 = new wxBoxSizer(wxVERTICAL);
int i;
User* user = _kiss->GetUser();
std::vector<Account>::iterator accountIt;
std::vector<Category>::iterator categoryIt;
std::map<int, std::vector<int> > operations;
std::map<int, std::vector<int> >::iterator it;
SetSizer(vbox);
_monthFrom = new wxChoice (this, -1, wxDefaultPosition, wxDefaultSize, 12, months);
_monthTo = new wxChoice (this, -1, wxDefaultPosition, wxDefaultSize, 12, months);
_monthFrom = new wxChoice (this, RANGE_ID, wxDefaultPosition, wxDefaultSize, 12, months);
_yearFrom = new wxChoice (this, RANGE_ID);
_monthTo = new wxChoice (this, RANGE_ID, wxDefaultPosition, wxDefaultSize, 12, months);
_yearTo = new wxChoice (this, RANGE_ID);
operations = _kiss->GetAllOperations();
for(i=0, it = operations.begin(); it != operations.end(); it++, i++)
{
_yearFrom->Append(wxString::Format(wxT("%d"), it->first));
_yearTo->Append(wxString::Format(wxT("%d"), it->first));
}
_monthFrom->Select(0);
_monthTo->Select(11);
_yearFrom->Select(i);
_yearTo->Select(i);
wxStaticText* label = new wxStaticText(this, wxID_ANY, _("From"));
hbox->Add(label);
hbox->Add(-1, 10);
hbox->Add(_monthFrom);
hbox->Add(_yearFrom);
hbox->Add(-1, 30);
label = new wxStaticText(this, wxID_ANY, _("To"));
hbox->Add(label);
hbox->Add(-1, 10);
hbox->Add(_monthTo);
hbox->Add(_yearTo);
_account = new wxCheckListBox(this, ACCOUNTS_ID);
for(i=0, accountIt = user->_accounts.begin(); accountIt != user->_accounts.end(); accountIt++, i++)
{
_account->Append(accountIt->name);
_account->Check(i);
}
_categories = new wxString[user->GetCategoriesNumber()] ;
for(i=0, categoryIt = user->_categories.begin();
@ -65,7 +106,9 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _ki
_statsGrid->SetCellAlignment(i, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
}
vbox2->Add(_statsGrid);
_vbox2->Add(_account);
_vbox2->Add(-1, 10);
_vbox2->Add(_statsGrid);
_pie = new PiePlot();
@ -90,20 +133,21 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _ki
chart->SetMinSize(// chart->GetSize()
wxSize(200,250));
UpdateStats(hbox2);
wxCommandEvent event ;
OnRangeChange(event);
vbox2->Add(chart);
_vbox2->Add(-1, 10);
_vbox2->Add(chart);
hbox2->Add(vbox2);
vbox->Add(hbox);
vbox->Add(hbox2);
vbox->Add(_hbox2);
Fit();
Hide();
}
void StatsPanel::UpdateStats(wxBoxSizer *hbox2)
void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearTo)
{
std::map<wxString, std::map<int, std::map<int, double> > > accountAmounts;
std::map<wxString, double> categories;
@ -111,12 +155,19 @@ void StatsPanel::UpdateStats(wxBoxSizer *hbox2)
std::map<wxString, std::map<int, std::map<int, double> > >::iterator accountIdIt;
std::map<int, std::map<int, double> >::iterator accountYearIt;
double total;
int size, i, a, b, percents;
int size, i, a, b, percents, account;
double *amounts;
User* user = _kiss->GetUser();
wxString value;
User* user = _kiss->GetUser();
_kiss->GetStats(0, 2010, 11, 2010, &accountAmounts, &categories);
if (_chart)
{
_hbox2->Detach(_chart);
_hbox2->Detach(_vbox2);
delete _chart;
}
_kiss->GetStats(monthFrom, yearFrom, monthTo, yearTo, &accountAmounts, &categories);
// first step: create plot
_plot = new XYPlot();
@ -124,9 +175,30 @@ void StatsPanel::UpdateStats(wxBoxSizer *hbox2)
// create dataset
XYSimpleDataset *dataset = new XYSimpleDataset();
// add two series
for (i = 0, accountIdIt = accountAmounts.begin(); accountIdIt != accountAmounts.end(); accountIdIt++, i++)
// Line on 0 all over the years
size = ((yearTo - yearFrom) + 1) * 12;
amounts = new double[size*2];
for (a=0; a<(size/12); a++)
{
for(b=0; b<12; b++)
{
amounts[a*12*2+b*2+0] = a*12+b;
amounts[a*12*2+b*2+1] = 0;
}
}
dataset->AddSerie((double *) amounts, size);
delete[] amounts;
for (account = 0, i = 0, accountIdIt = accountAmounts.begin(); accountIdIt != accountAmounts.end();
accountIdIt++, i++, account++)
{
if (!((wxCheckListBox*)_account)->IsChecked(account))
{
i-- ;
continue;
}
size = accountAmounts[accountIdIt->first].size();
amounts = new double[size*12*2];
size = 0;
@ -145,12 +217,12 @@ void StatsPanel::UpdateStats(wxBoxSizer *hbox2)
}
dataset->AddSerie((double *) amounts, size);
// set serie names to be displayed on legend
dataset->SetSerieName(i, user->GetAccountName(accountIdIt->first));
dataset->SetSerieName(i+1, user->GetAccountName(accountIdIt->first));
delete[] amounts;
}
// create line renderer and set it to dataset
XYLineRenderer *renderer = new XYLineRenderer();
XYLineRenderer *renderer = new XYLineRenderer(true, true);
dataset->SetRenderer(renderer);
// add our dataset to plot
@ -168,26 +240,17 @@ void StatsPanel::UpdateStats(wxBoxSizer *hbox2)
_plot->LinkDataVerticalAxis(0, 0);
_plot->LinkDataHorizontalAxis(0, 0);
// create line marker
LineMarker *lineMarker = new LineMarker(wxColour(255, 0, 0), 2);
// set value to be marked, in our case horizontal value 15
lineMarker->SetHorizontalLine(25);
// and add marker to dataset
dataset->AddMarker(lineMarker);
// set legend
_plot->SetLegend(new Legend(wxCENTER, wxRIGHT));
wxChartPanel* chart = new wxChartPanel(this);
chart->SetChart(new Chart(_plot, _("Accounts")));
chart->Fit();
chart->Layout();
chart->SetMinSize(// chart->GetSize()
_chart = new wxChartPanel(this);
_chart->SetChart(new Chart(_plot, _("Accounts")));
_chart->Fit();
_chart->Layout();
_chart->SetMinSize(// chart->GetSize()
wxSize(750,550));
hbox2->Add(chart);
_hbox2->Add(_chart);
total = 0.0;
for(categoriesIt = categories.begin(); categoriesIt != categories.end(); categoriesIt++)
@ -205,6 +268,10 @@ void StatsPanel::UpdateStats(wxBoxSizer *hbox2)
_statsGrid->AutoSizeColumn(1, true);
_pie->DatasetChanged(_dataset);
_hbox2->Add(_vbox2);
Layout();
}
void StatsPanel::OnShow(wxShowEvent& event)
@ -212,3 +279,26 @@ void StatsPanel::OnShow(wxShowEvent& event)
_wxUI->SetTitle(_kiss->GetUser()->_name + _(" - ") + _("Statistics"));
}
void StatsPanel::OnRangeChange(wxCommandEvent& event)
{
int monthFrom, monthTo, yearFrom, yearTo;
monthFrom = _monthFrom->GetCurrentSelection();
_yearFrom->GetStringSelection().ToLong((long*)&yearFrom);
monthTo = _monthTo->GetCurrentSelection();
_yearTo->GetStringSelection().ToLong((long*)&yearTo);
if (yearTo > yearFrom ||
(yearFrom == yearTo && monthFrom >= monthTo))
{
wxMessageBox(_("Invalide date range"), _("KissCount"), wxICON_ERROR | wxOK);
return;
}
UpdateStats(monthFrom, yearFrom, monthTo, yearTo);
}
void StatsPanel::OnAccountsChange(wxCommandEvent& event)
{
OnRangeChange(event);
}

View File

@ -61,11 +61,16 @@ class StatsPanel: public wxPanel //public wxScrolledWindow
XYPlot *_plot ;
wxString* _categories;
std::map<wxString, int> _categoriesIndexes;
wxBoxSizer *_hbox2, *_vbox2;
wxChartPanel* _chart;
wxCheckListBox* _account;
void UpdateStats(wxBoxSizer *);
void UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearTo);
//DECLARE_EVENT_TABLE();
void OnRangeChange(wxCommandEvent& event);
void OnAccountsChange(wxCommandEvent& event);
DECLARE_EVENT_TABLE();
};
#endif