##// END OF EJS Templates
More examples on QChartView qdoc
More examples on QChartView qdoc

File last commit:

r288:5f68000bea7a
r321:13ac9d78995f
Show More
stackedbarpresenter.cpp
111 lines | 3.2 KiB | text/x-c | CppLexer
/ src / barchart / stackedbarpresenter.cpp
sauimone
Common naming convention for barcharts
r216 #include "stackedbarpresenter.h"
sauimone
renamed bar.h to bar_p.h
r118 #include "bar_p.h"
sauimone
added labels to barcharts
r114 #include "barlabel_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
added missing example files :)
r96 #include <QDebug>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
moved tooltip to presenter
r288 StackedBarPresenter::StackedBarPresenter(QBarChartSeries *series, QGraphicsItem *parent) :
BarPresenterBase(series,parent)
sauimone
added missing example files :)
r96 {
}
sauimone
Common naming convention for barcharts
r216 void StackedBarPresenter::layoutChanged()
sauimone
added missing example files :)
r96 {
// Scale bars to new layout
// Layout for bars:
sauimone
moved tooltip to presenter
r288 if (mSeries->countSets() <= 0) {
sauimone
fixed bug in category implementation. model now owns the category and sets
r173 qDebug() << "No sets in model!";
sauimone
added missing example files :)
r96 // Nothing to do.
return;
}
sauimone
moved tooltip to presenter
r288 if (mSeries->countCategories() == 0) {
sauimone
fixed bug in category implementation. model now owns the category and sets
r173 qDebug() << "No categories in model!";
sauimone
prototyping separators with stacked bars
r119 // 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: StackedBarPresenter::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
added missing example files :)
r96 // TODO: better way to auto-layout
sauimone
bar chart layout fixing
r99 // Use reals for accurancy (we might get some compiler warnings... :)
sauimone
brush support for bargroups
r183 // TODO: use temp variable for category count...
sauimone
moved tooltip to presenter
r288 qreal maxSum = mSeries->maxCategorySum();
sauimone
fixed naming mixup with percent and stacked groups
r105 qreal h = mHeight;
qreal scale = (h / maxSum);
sauimone
added missing example files :)
r96 int itemIndex(0);
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 int labelIndex(0);
sauimone
fixing layout bug on stacked bar chart
r98 qreal tW = mWidth;
sauimone
moved tooltip to presenter
r288 qreal tC = mSeries->countCategories() + 1;
sauimone
fixing layout bug on stacked bar chart
r98 qreal xStep = (tW/tC);
sauimone
theme interface to barcharts. some minor fixes
r113 qreal xPos = ((tW/tC) - mBarDefaultWidth / 2);
sauimone
fixing layout bug on stacked bar chart
r98
sauimone
moved tooltip to presenter
r288 for (int category = 0; category < mSeries->countCategories(); category++) {
sauimone
fixing layout bug on stacked bar chart
r98 qreal yPos = h;
sauimone
moved tooltip to presenter
r288 for (int set=0; set < mSeries->countSets(); set++) {
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
added missing example files :)
r96
bar->resize(mBarDefaultWidth, barHeight);
sauimone
moved tooltip to presenter
r288 bar->setBrush(mSeries->setAt(set)->brush());
sauimone
theme interface to barcharts. some minor fixes
r113 bar->setPos(xPos, yPos-barHeight);
sauimone
added missing example files :)
r96 itemIndex++;
sauimone
Some fixes to bar charts. Now bars draw almost correctly
r97 yPos -= barHeight;
sauimone
added missing example files :)
r96 }
sauimone
added labels to barcharts
r114
// TODO: Layout for labels, remove magic number
sauimone
Bug fix for bar presenters. It appears that order of childItems may change. Relying on order caused crash
r256 BarLabel* label = mLabels.at(labelIndex);
sauimone
added labels to barcharts
r114 label->setPos(xPos, mHeight + 20);
labelIndex++;
sauimone
fixing layout bug on stacked bar chart
r98 xPos += xStep;
sauimone
added missing example files :)
r96 }
sauimone
added labels to barcharts
r114
sauimone
prototyping separators with stacked bars
r119 // 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
moved tooltip to presenter
r288 for (int s=0; s < mSeries->countCategories() - 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));
sauimone
prototyping separators with stacked bars
r119 xPos += xStep;
sauimone
Floating values to bar charts
r263 }
// Position floating values
itemIndex = 0;
xPos = ((tW/tC) - mBarDefaultWidth / 2);
sauimone
moved tooltip to presenter
r288 for (int category=0; category < mSeries->countCategories(); category++) {
sauimone
Floating values to bar charts
r263 qreal yPos = h;
sauimone
moved tooltip to presenter
r288 for (int set=0; set < mSeries->countSets(); set++) {
qreal barHeight = mSeries->valueAt(set,category) * scale;
sauimone
Floating values to bar charts
r263 BarValue* value = mFloatingValues.at(itemIndex);
// TODO: remove hard coding, apply layout
value->resize(100,50);
sauimone
updated barchart examples. minor fixes
r276 value->setPos(xPos, yPos-barHeight/2);
sauimone
Floating values to bar charts
r263 value->setPen(QPen(QColor(255,255,255,255)));
sauimone
moved tooltip to presenter
r288 if (mSeries->valueAt(set,category) != 0) {
value->setValueString(QString::number(mSeries->valueAt(set,category)));
sauimone
updated barchart examples. minor fixes
r276 } else {
value->setValueString(QString(""));
}
sauimone
Floating values to bar charts
r263
itemIndex++;
yPos -= barHeight;
}
xPos += xStep;
sauimone
prototyping separators with stacked bars
r119 }
sauimone
model delegate for bar series. updated examples
r161
sauimone
added missing example files :)
r96 mLayoutDirty = true;
}
sauimone
moved tooltip to presenter
r288 #include "moc_stackedbarpresenter.cpp"
sauimone
added missing example files :)
r96 QTCOMMERCIALCHART_END_NAMESPACE