diff --git a/src/view/StatsPanel.cpp b/src/view/StatsPanel.cpp index 3c55154..3f65c7b 100644 --- a/src/view/StatsPanel.cpp +++ b/src/view/StatsPanel.cpp @@ -31,6 +31,7 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), QVBoxLayout *vbox = new QVBoxLayout(); _hbox2 = new QHBoxLayout(); _vbox2 = new QVBoxLayout(); + _vbox3 = new QVBoxLayout(); int i; User* user = _kiss->GetUser(); std::vector::iterator accountIt; @@ -131,14 +132,11 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _statsGrid->setItem(1, 1, new QTableWidgetItem("")); _statsGrid->item(1, 1)->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); - _vbox2->addWidget(_account); - _vbox2->addWidget(_statsGrid); + _vbox3->addWidget(_account); + _vbox3->addWidget(_statsGrid); nbCategories = (user->GetCategoriesNumber() <= wxUI::MAX_CATEGORY) ? user->GetCategoriesNumber() : wxUI::MAX_CATEGORY; - // _dataset = new CategorySimpleDataset(_categories, nbCategories); - // ColorScheme* colorScheme = new ColorScheme(wxUI::categoryColors, WXSIZEOF(wxUI::categoryColors)); - _categoriesValues = new double[user->GetCategoriesNumber()]; for(i=0; iGetCategoriesNumber(); i++) _categoriesValues[i] = 0.0; @@ -178,7 +176,8 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), legendTextAttr.setAutoShrink(true); legend->setTitleTextAttributes(legendTextAttr); - vbox->addLayout(hbox); + _vbox2->addLayout(hbox); + _hbox2->addLayout(_vbox2); vbox->addLayout(_hbox2); OnRangeChange(0); @@ -227,8 +226,9 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT if (_plot) { - _hbox2->removeItem(_vbox2); - //_hbox2->removeItem(_pie); + _vbox2->removeWidget(_plot); + _hbox2->removeItem(_vbox3); + _hbox2->removeWidget(_pie); delete _plot; } @@ -274,7 +274,7 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT for(b=0; b<12; b++) { vec << 0.0; - if (b == 0 || b == 5 || (b == 11 && a == ((nbDays/12)-1))) + if (b == 0 || b == 5 || (b == 11 /*&& a == ((nbDays/12)-1))*/)) xlabels << wxUI::months[b] + " " + QString::number(yearFrom+a); else xlabels << "" ; @@ -293,16 +293,12 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT } vec.clear(); - // size = accountAmounts[accountIt->id].size(); - // amounts = new double[size*13*2]; - // size = 0; for(a = 0, accountYearIt = accountAmounts[accountIt->id].begin(); accountYearIt != accountAmounts[accountIt->id].end(); accountYearIt++, a++) { for(b = 0; b<=12; b++) { - // amounts[size*2+0] = a*12+b; if (!accountAmounts[accountIt->id][accountYearIt->first].count(b)) { /* @@ -327,10 +323,6 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT } } _plot->setDataset(i+1, vec, user->GetAccountName(accountIt->id)); - // dataset->AddSerie((double *) amounts, size); - // set serie names to be displayed on legend - // dataset->SetSerieName(i+1, user->GetAccountName(accountIt->id)); - // delete[] amounts; } } @@ -342,7 +334,12 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT yAxis->setTitleText (_("Amount")); xAxis->setLabels(xlabels); - + xAxis->setShortLabels(xlabels); + + KDChart::TextAttributes axisTextAttr(xAxis->textAttributes()); + axisTextAttr.setRotation(-60); + xAxis->setTextAttributes(axisTextAttr); + _plot->lineDiagram()->addAxis(xAxis); _plot->lineDiagram()->addAxis(yAxis); @@ -361,36 +358,8 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT legend->setText(i++, accountIt->name); } } - // // create line renderer and set it to dataset - // XYLineRenderer *renderer = new XYLineRenderer(true, true); - // dataset->SetRenderer(renderer); - // // add our dataset to plot - // _plot->AddDataset(dataset); - - // // create left and bottom number axes - // NumberAxis *leftAxis = new NumberAxis(AXIS_LEFT); - // NumberAxis *bottomAxis = new NumberAxis(AXIS_BOTTOM); - - // // add axes to plot - // _plot->AddAxis(leftAxis); - // _plot->AddAxis(bottomAxis); - - // // link axes and dataset - // _plot->LinkDataVerticalAxis(0, 0); - // _plot->LinkDataHorizontalAxis(0, 0); - - // // set legend - // _plot->SetLegend(new Legend(wxCENTER, wxRIGHT)); - - // _chart = new wxChartPanel(this); - // _chart->SetChart(new Chart(_plot, _("Accounts"))); - // _chart->Fit(); - // _chart->Layout(); - // _chart->SetMinSize(// chart->GetSize() - // wxSize(750,550)); - - _hbox2->addWidget(_plot); + _vbox2->addWidget(_plot); total = 0.0; for(categoriesIt = categories.begin(); categoriesIt != categories.end(); categoriesIt++) @@ -430,7 +399,7 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT _statsGrid->resizeColumnsToContents(); - _hbox2->addLayout(_vbox2); + _hbox2->addLayout(_vbox3); _hbox2->addWidget(_pie); layout(); diff --git a/src/view/StatsPanel.hpp b/src/view/StatsPanel.hpp index 49c3d09..b278e1b 100644 --- a/src/view/StatsPanel.hpp +++ b/src/view/StatsPanel.hpp @@ -52,7 +52,7 @@ private: KDChart::Widget *_plot ; QString* _categories; std::map _categoriesIndexes; - QBoxLayout *_hbox2, *_vbox2; + QBoxLayout *_hbox2, *_vbox2, *_vbox3; QListWidget* _account; void UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearTo);