##// END OF EJS Templates
Refcator scrol() to scrollLeft,Right,Up,Down
Refcator scrol() to scrollLeft,Right,Up,Down

File last commit:

r592:56a808b04750
r600:db004721a4d5
Show More
percentbarpresenter.cpp
103 lines | 3.1 KiB | text/x-c | CppLexer
/ src / barchart / percentbarpresenter.cpp
sauimone
added _p to private class headers
r381 #include "percentbarpresenter_p.h"
sauimone
renamed bar.h to bar_p.h
r118 #include "bar_p.h"
sauimone
Floating values to bar charts
r263 #include "barvalue_p.h"
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 #include "separator_p.h"
sauimone
Added pen & brush to QBarSet
r214 #include "qbarset.h"
sauimone
percent bar chart
r101 #include <QDebug>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
Labels for barchart to axis
r487 PercentBarPresenter::PercentBarPresenter(QBarSeries *series, QChart *parent) :
sauimone
moved tooltip to presenter
r288 BarPresenterBase(series, parent)
sauimone
percent bar chart
r101 {
}
sauimone
Common naming convention for barcharts
r216 void PercentBarPresenter::layoutChanged()
sauimone
percent bar chart
r101 {
// Scale bars to new layout
// Layout for bars:
sauimone
review fixes. countCategories() -> categoryCount(). countSets -> barsetCount()
r366 if (mSeries->barsetCount() <= 0) {
sauimone
fixed bug in category implementation. model now owns the category and sets
r173 qDebug() << "No sets in model!";
sauimone
percent bar chart
r101 // Nothing to do.
return;
}
sauimone
bug fix in bar charts. Crashed, if layout was set before data. Also integrated to test app.
r165 if (childItems().count() == 0) {
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 qDebug() << "WARNING: PercentBarPresenter::layoutChanged called before graphics items are created!";
sauimone
bug fix in bar charts. Crashed, if layout was set before data. Also integrated to test app.
r165 return;
}
sauimone
Fixed layout for barcharts
r473 // Use temporary qreals for accurancy (we might get some compiler warnings... :)
sauimone
percent bar chart
r101 qreal tW = mWidth;
sauimone
Fixed layout for barcharts
r473 qreal tC = mSeries->categoryCount() + 1;
qreal cC = mSeries->categoryCount() * 2 + 1;
mBarWidth = tW / cC;
sauimone
percent bar chart
r101 qreal xStep = (tW/tC);
sauimone
Fixed layout for barcharts
r473 qreal xPos = ((tW/tC) - mBarWidth / 2);
sauimone
Floating values to bar charts
r263 qreal h = mHeight;
sauimone
percent bar chart
r101
sauimone
Fixed layout for barcharts
r473 int itemIndex(0);
sauimone
review fixes. countCategories() -> categoryCount(). countSets -> barsetCount()
r366 for (int category = 0; category < mSeries->categoryCount(); category++) {
sauimone
moved tooltip to presenter
r288 qreal colSum = mSeries->categorySum(category);
sauimone
fixed naming mixup with percent and stacked groups
r105 qreal scale = (h / colSum);
sauimone
percent bar chart
r101 qreal yPos = h;
sauimone
review fixes. countCategories() -> categoryCount(). countSets -> barsetCount()
r366 for (int set=0; set < mSeries->barsetCount(); set++) {
sauimone
moved tooltip to presenter
r288 qreal barHeight = mSeries->valueAt(set, category) * scale;
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 Bar* bar = mBars.at(itemIndex);
sauimone
percent bar chart
r101
// TODO: width settable per bar?
sauimone
Fixed layout for barcharts
r473 bar->resize(mBarWidth, barHeight);
sauimone
review fix: Removed iterator from barseries. Remove const from brush and pen. Renamed setters for tooltip, floating values and separators
r357 bar->setBrush(mSeries->barsetAt(set)->brush());
sauimone
theme interface to barcharts. some minor fixes
r113 bar->setPos(xPos, yPos-barHeight);
sauimone
percent bar chart
r101 itemIndex++;
yPos -= barHeight;
}
xPos += xStep;
}
sauimone
commented out separatos. feature, we dont need?
r592 /*
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 // Position separators
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 xPos = xStep + xStep/2;
sauimone
review fixes. countCategories() -> categoryCount(). countSets -> barsetCount()
r366 for (int s=0; s < mSeries->categoryCount() - 1; s++) {
sauimone
Floating values to bar charts
r263 Separator* sep = mSeparators.at(s);
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 sep->setPos(xPos,0);
sep->setSize(QSizeF(1,mHeight));
xPos += xStep;
sauimone
Floating values to bar charts
r263 }
sauimone
commented out separatos. feature, we dont need?
r592 */
sauimone
Floating values to bar charts
r263 // Position floating values
itemIndex = 0;
sauimone
floating value layout fix for barchart
r474 xPos = (tW/tC);
sauimone
review fixes. countCategories() -> categoryCount(). countSets -> barsetCount()
r366 for (int category=0; category < mSeries->categoryCount(); category++) {
sauimone
Floating values to bar charts
r263 qreal yPos = h;
sauimone
moved tooltip to presenter
r288 qreal colSum = mSeries->categorySum(category);
sauimone
Floating values to bar charts
r263 qreal scale = (h / colSum);
sauimone
review fixes. countCategories() -> categoryCount(). countSets -> barsetCount()
r366 for (int set=0; set < mSeries->barsetCount(); set++) {
sauimone
moved tooltip to presenter
r288 qreal barHeight = mSeries->valueAt(set,category) * scale;
sauimone
Floating values to bar charts
r263 BarValue* value = mFloatingValues.at(itemIndex);
sauimone
better use of gradients in barcharts
r512 QBarSet* barSet = mSeries->barsetAt(set);
value->resize(100,50); // TODO: proper layout for this.
sauimone
updated barchart examples. minor fixes
r276 value->setPos(xPos, yPos-barHeight/2);
sauimone
better use of gradients in barcharts
r512 value->setPen(barSet->floatingValuePen());
sauimone
Floating values to bar charts
r263
sauimone
moved tooltip to presenter
r288 if (mSeries->valueAt(set,category) != 0) {
int p = mSeries->percentageAt(set,category) * 100;
sauimone
barcharts: added legend to model. added signals for hover events (for tooltip). updated examples
r280 QString vString(QString::number(p));
vString.truncate(3);
sauimone
updated barchart examples. minor fixes
r276 vString.append("%");
value->setValueString(vString);
} else {
value->setValueString(QString(""));
}
sauimone
Floating values to bar charts
r263
itemIndex++;
yPos -= barHeight;
}
xPos += xStep;
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 }
sauimone
percent bar chart
r101 }
sauimone
added _p to private class headers
r381 #include "moc_percentbarpresenter_p.cpp"
sauimone
moved tooltip to presenter
r288
sauimone
percent bar chart
r101 QTCOMMERCIALCHART_END_NAMESPACE