[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/office/skrooge
From: Stephane Mankowski <stephane () mankowski ! fr>
Date: 2011-02-27 18:31:34
Message-ID: 20110227183134.0CB56AC8C0 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1222963 by smankowski:
feature: New "stacked area" graph type
M +1 -0 CHANGELOG
AM skgbasegui/hi128-actions-skg-chart-area-stacked.png
AM skgbasegui/hi16-actions-skg-chart-area-stacked.png
AM skgbasegui/hi22-actions-skg-chart-area-stacked.png
AM skgbasegui/hi32-actions-skg-chart-area-stacked.png
AM skgbasegui/hi48-actions-skg-chart-area-stacked.png
AM skgbasegui/hi64-actions-skg-chart-area-stacked.png
AM skgbasegui/hisc-actions-skg-chart-area-stacked.svgz
M +79 -7 skgbasegui/skgtablewithgraph.cpp
M +2 -1 skgbasegui/skgtablewithgraph.h
M +45 -37 skrooge_report/skgreportpluginwidget_base.ui
--- trunk/extragear/office/skrooge/CHANGELOG #1222962:1222963
@@ -43,6 +43,7 @@
*New feature: Timeline in reports
*New feature: Some fields are directly editable in view
*New feature: Completion for all fields with operators (=upper and =lower for the \
moment) + *New feature: New "stacked area" graph type
-- maintainer Stephane MANKOWSKI <stephane@mankowski.fr> xxx
--- trunk/extragear/office/skrooge/skgbasegui/skgtablewithgraph.cpp #1222962:1222963
@@ -90,6 +90,7 @@
ui.kDisplayMode->addItem(KIcon("skg-chart-ring"), i18nc("Noun, a type of graph \
that looks like concentric slices of a pie (a la filelight)", \
"Concentric pie"));
ui.kDisplayMode->addItem(KIcon("skg-chart-scatter"), i18nc("Noun, a type of \
graph with only points", "Point"));
ui.kDisplayMode->addItem(KIcon("skg-chart-line"), i18nc("Noun, a type of graph \
with only lines", "Line")); + \
ui.kDisplayMode->addItem(KIcon("skg-chart-area-stacked"), i18nc("Noun, a type of \
graph, with lines stacked upon each other", "Stacked area"));
ui.kShow->addItem("table", i18n("Table"), "view-list-details", "", \
"", "text", "graph");
ui.kShow->addItem("graph", i18n("Graph"), "skg-chart-pie", "", "", \
"text", "table"); @@ -1054,7 +1055,7 @@
//Get graphic mode
GraphType mode = (GraphType) ui.kDisplayMode->currentIndex();
bool inPositive = false;
- if(mode == STACK || mode == HISTOGRAM || mode == POINT || mode == LINE) {
+ if(mode == STACK || mode == HISTOGRAM || mode == POINT || mode == LINE || \
mode == STACKAREA) { ui.kAllPositive->show();
inPositive = (ui.kAllPositive->checkState() == Qt::Checked);
} else ui.kAllPositive->hide();
@@ -1082,7 +1083,7 @@
QVariant valQ = tableItem->data(DATA_VALUE);
if(valQ.type() == QVariant::Double) {
double val = valQ.toDouble();
- if(inPositive || val > 0) {
+ if(inPositive || val >= 0) {
sumPositive += fabs(val);
} else {
sumNegative += val;
@@ -1095,6 +1096,31 @@
maxLimit = qMax(maxLimit, sumPositive);
}
}
+ } else if(mode == STACKAREA) {
+ //STACKAREA
+ for(int y = 0; y < nbColumns; ++y) {
+ double sumPositive = 0;
+ double sumNegative = 0;
+ for(int x = 0; x < nbRows; ++x) {
+ if(!m_sumRows[x+1]) {
+ QTableWidgetItem* tableItem = ui.kTable->item(x, y);
+ if(tableItem) {
+ QVariant valQ = tableItem->data(DATA_VALUE);
+ if(valQ.type() == QVariant::Double) {
+ double val = valQ.toDouble();
+ if(inPositive || val >= 0) {
+ sumPositive += fabs(val);
+ } else {
+ sumNegative += val;
+ }
+ }
+ }
+ }
+
+ }
+ minLimit = qMin(minLimit, sumNegative);
+ maxLimit = qMax(maxLimit, sumPositive);
+ }
} else if(mode == HISTOGRAM || mode == POINT || mode == LINE) {
//HISTOGRAM or POINTS or LINES
for(int x = 0; x < nbRows; ++x) {
@@ -1142,7 +1168,7 @@
width = width * ((double) vSize.width()) / ((double) \
vSize.height()); margin = (maxLimit - minLimit) * 0.5;
maxX = width * nbRealRows + margin;
- } else if(mode == HISTOGRAM || mode == POINT || mode == LINE) {
+ } else if(mode == HISTOGRAM || mode == POINT || mode == LINE || mode == \
STACKAREA) {
width = (maxLimit - minLimit) / (nbRealRows * (nbColumns - 1));
width = width * ((double) vSize.width()) / ((double) \
vSize.height()); margin = (maxLimit - minLimit) * 0.3;
@@ -1191,10 +1217,12 @@
//Redraw scene
double x0 = 0;
double x1 = 0;
- double ymin = (m_zeroVisible || mode == STACK ? 0 : 9999999);
- double ymax = (m_zeroVisible || mode == STACK ? 0 : -9999999);
+ double ymin = (m_zeroVisible || mode == STACK || mode == STACKAREA ? 0 : \
9999999); + double ymax = (m_zeroVisible || mode == STACK || mode == STACKAREA \
? 0 : -9999999); int x = 0;
int nbRowsDrawed = 0;
+ QMap<int, double> previousStackedPlus;
+ QMap<int, double> previousStackedMoins;
for(int xx = 0; xx < nbRows; ++xx) {
SKGColorButton* colorButton = \
qobject_cast<SKGColorButton*>(ui.kTable->cellWidget(xx, 0)); if(colorButton) {
@@ -1203,6 +1231,7 @@
double yPlus = 0;
double yMoins = 0;
int jprevious = -1;
+
++nbRowsDrawed;
for(int j = 1; j < nbColumns; ++j) {
//Get column name
@@ -1239,7 +1268,7 @@
QGraphicsItem* graphItem = NULL;
if(mode == STACK) {
//STACK
- if(val > 0 || inPositive) {
+ if(val >= 0 || inPositive) {
graphItem = m_scene->addRect(width * x, -yPlus - \
fabs(val), width, fabs(val), QPen(), brush); yPlus += fabs(val);
if(yPlus > ymax) ymax = yPlus;
@@ -1248,6 +1277,49 @@
yMoins += val;
if(yMoins < ymin) ymin = yMoins;
}
+ } if(mode == STACKAREA) {
+ //STACKAREA
+ //Empty cells are ignored
+ if(j == 1) x0 = width * (j - 1) * (nbRealRows + 1);
+ if(j == nbColumns - m_nbVirtualColumns - 1) x1 = \
width * (j - 1) * (nbRealRows + 1); +
+ if(!valstring.isEmpty()) {
+ if(jprevious == -1) jprevious = j;
+ QTableWidgetItem* tableItem2 = \
ui.kTable->item(xx, jprevious); + if(tableItem2) {
+ QString val2string = tableItem->text();
+ if(!val2string.isEmpty()) {
+ double val2 = \
tableItem2->data(DATA_VALUE).toDouble(); +
+ if(val >= 0 || inPositive) {
+ double xp = width * (jprevious - 1) \
* (nbRealRows + 1) - (jprevious == j ? width / 20 : 0); + \
double xn = width * (j - 1) * (nbRealRows + 1); + \
double yp = (previousStackedPlus.contains(jprevious) ? previousStackedPlus[jprevious] \
: -fabs(val2)); + double yn = \
previousStackedPlus[j] - fabs(val); +
+ QPolygonF polygon;
+ polygon << QPointF(xp, yp + \
fabs(val2)) << QPointF(xp, yp) + \
<< QPointF(xn, yn) << QPointF(xn, previousStackedPlus[j]); + \
graphItem = m_scene->addPolygon(polygon, QPen(), brush); + \
previousStackedPlus[j] = yn; + if(-yn \
> ymax) ymax = -yn; + } else {
+ double xp = width * (jprevious - 1) \
* (nbRealRows + 1) - (jprevious == j ? width / 20 : 0); + \
double xn = width * (j - 1) * (nbRealRows + 1); + \
double yp = (previousStackedMoins.contains(jprevious) ? \
previousStackedMoins[jprevious] : -val2); + \
double yn = previousStackedMoins[j] - val; +
+ QPolygonF polygon;
+ polygon << QPointF(xp, yp + val2) << \
QPointF(xp, yp) + << \
QPointF(xn, yn) << QPointF(xn, previousStackedMoins[j]); + \
graphItem = m_scene->addPolygon(polygon, QPen(), brush); + \
previousStackedMoins[j] = yn; + if(-yn \
< ymin) ymin = -yn; + }
+ jprevious = j;
+ }
+ }
+ }
} else if(mode == HISTOGRAM) {
//HISTOGRAM
if(j == 1) x0 = width * ((j - 1) * (nbRealRows + 1) \
+ x) + width; @@ -1474,7 +1546,7 @@
}
}
- if(mode == HISTOGRAM || mode == POINT || mode == LINE) {
+ if(mode == HISTOGRAM || mode == POINT || mode == LINE || mode == \
STACKAREA) { //Line y
double xstep = width * (nbRealRows + 1);
int jstep = qMax(computeStepSize(nbColumns, 20), double(1.0));
--- trunk/extragear/office/skrooge/skgbasegui/skgtablewithgraph.h #1222962:1222963
@@ -49,7 +49,8 @@
PIE,
CONCENTRICPIE,
POINT,
- LINE
+ LINE,
+ STACKAREA,
};
/**
* Additionel information to display
--- trunk/extragear/office/skrooge/skrooge_report/skgreportpluginwidget_base.ui \
#1222962:1222963 @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>750</width>
- <height>497</height>
+ <height>435</height>
</rect>
</property>
<property name="sizePolicy">
@@ -454,26 +454,14 @@
</item>
<item>
<widget class="QWidget" name="kDateSelect" native="true">
- <layout class="QFormLayout" name="formLayout">
- <property name="horizontalSpacing">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <property name="spacing">
<number>2</number>
</property>
- <property name="verticalSpacing">
- <number>2</number>
- </property>
- <property name="leftMargin">
+ <property name="margin">
<number>0</number>
</property>
- <property name="topMargin">
- <number>4</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item row="0" column="0">
+ <item>
<widget class="QLabel" name="kDateBeginLabel">
<property name="enabled">
<bool>true</bool>
@@ -495,7 +483,7 @@
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item>
<widget class="SKGDateEdit" name="kDateBegin">
<property name="enabled">
<bool>true</bool>
@@ -520,7 +508,7 @@
</property>
</widget>
</item>
- <item row="1" column="0">
+ <item>
<widget class="QLabel" name="kDateEndLabel">
<property name="enabled">
<bool>true</bool>
@@ -539,7 +527,7 @@
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item>
<widget class="SKGDateEdit" name="kDateEnd">
<property name="enabled">
<bool>true</bool>
@@ -564,6 +552,19 @@
</property>
</widget>
</item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
</item>
@@ -573,6 +574,9 @@
<property name="spacing">
<number>2</number>
</property>
+ <property name="margin">
+ <number>0</number>
+ </property>
<item>
<widget class="QLabel" name="label">
<property name="text">
@@ -581,6 +585,9 @@
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
+ <property name="buddy">
+ <cstring>kForecastCmb</cstring>
+ </property>
</widget>
</item>
<item>
@@ -786,6 +793,7 @@
<tabstop>kPeriod</tabstop>
<tabstop>kNbIntervals</tabstop>
<tabstop>kInterval</tabstop>
+ <tabstop>kTimeline</tabstop>
<tabstop>kDateBegin</tabstop>
<tabstop>kDateEnd</tabstop>
<tabstop>kForecastCmb</tabstop>
@@ -808,7 +816,7 @@
<y>176</y>
</hint>
<hint type="destinationlabel">
- <x>750</x>
+ <x>749</x>
<y>16</y>
</hint>
</hints>
@@ -820,8 +828,8 @@
<slot>onBtnModeClicked()</slot>
<hints>
<hint type="sourcelabel">
- <x>94</x>
- <y>449</y>
+ <x>100</x>
+ <y>428</y>
</hint>
<hint type="destinationlabel">
<x>139</x>
@@ -836,8 +844,8 @@
<slot>onOneLevelLess()</slot>
<hints>
<hint type="sourcelabel">
- <x>353</x>
- <y>344</y>
+ <x>233</x>
+ <y>338</y>
</hint>
<hint type="destinationlabel">
<x>330</x>
@@ -852,8 +860,8 @@
<slot>onOneLevelMore()</slot>
<hints>
<hint type="sourcelabel">
- <x>377</x>
- <y>344</y>
+ <x>257</x>
+ <y>338</y>
</hint>
<hint type="destinationlabel">
<x>446</x>
@@ -868,8 +876,8 @@
<slot>onOneLevelLess()</slot>
<hints>
<hint type="sourcelabel">
- <x>353</x>
- <y>384</y>
+ <x>233</x>
+ <y>365</y>
</hint>
<hint type="destinationlabel">
<x>574</x>
@@ -884,8 +892,8 @@
<slot>onOneLevelMore()</slot>
<hints>
<hint type="sourcelabel">
- <x>377</x>
- <y>384</y>
+ <x>257</x>
+ <y>365</y>
</hint>
<hint type="destinationlabel">
<x>696</x>
@@ -900,12 +908,12 @@
<slot>onAddLine()</slot>
<hints>
<hint type="sourcelabel">
- <x>329</x>
- <y>344</y>
+ <x>209</x>
+ <y>338</y>
</hint>
<hint type="destinationlabel">
<x>327</x>
- <y>470</y>
+ <y>434</y>
</hint>
</hints>
</connection>
@@ -916,12 +924,12 @@
<slot>onRemoveLine()</slot>
<hints>
<hint type="sourcelabel">
- <x>305</x>
- <y>344</y>
+ <x>185</x>
+ <y>338</y>
</hint>
<hint type="destinationlabel">
<x>362</x>
- <y>467</y>
+ <y>434</y>
</hint>
</hints>
</connection>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic