##// END OF EJS Templates
Revert "Fixes line uder grid issue"...
Revert "Fixes line uder grid issue" This reverts commit 3ea3ba4a33950ea7420e16913d228ed53fe566c3.

File last commit:

r183:45734e367adb
r191:0b54368f72bb
Show More
percentbargroup.cpp
81 lines | 2.6 KiB | text/x-c | CppLexer
/ src / barchart / percentbargroup.cpp
sauimone
percent bar chart
r101 #include "percentbargroup.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
refactored barcharts. layout to derived classess other funtionality to base class
r126 #include "separator_p.h"
sauimone
percent bar chart
r101 #include <QDebug>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
removed barchartseriesbase. functionality is now in model
r172 PercentBarGroup::PercentBarGroup(BarChartModel& model, QGraphicsItem *parent) :
BarGroupBase(model, parent)
sauimone
percent bar chart
r101 {
}
sauimone
fixed naming mixup with percent and stacked groups
r105 void PercentBarGroup::layoutChanged()
sauimone
percent bar chart
r101 {
sauimone
fixed bug in category implementation. model now owns the category and sets
r173 // qDebug() << "PercentBarGroup::layoutChanged";
sauimone
percent bar chart
r101 // Scale bars to new layout
// Layout for bars:
sauimone
Barset and barcategory implememtation. Updated test application
r171 if (mModel.countSets() <= 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) {
qDebug() << "WARNING: PercentBarGroup::layoutChanged called before graphics items are created!";
return;
}
sauimone
percent bar chart
r101 // TODO: better way to auto-layout
// Use reals for accurancy (we might get some compiler warnings... :)
sauimone
Barset and barcategory implememtation. Updated test application
r171 int count = mModel.countCategories();
sauimone
percent bar chart
r101 int itemIndex(0);
qreal tW = mWidth;
qreal tC = count+1;
qreal xStep = (tW/tC);
sauimone
added labels to barcharts
r114 qreal xPos = ((tW/tC) - mBarDefaultWidth / 2);
sauimone
Barset and barcategory implememtation. Updated test application
r171 int labelIndex = mModel.countCategories() * mModel.countSets();
sauimone
percent bar chart
r101
sauimone
brush support for bargroups
r183 for (int category = 0; category < mModel.countCategories(); category++) {
qreal colSum = mModel.categorySum(category);
sauimone
fixed naming mixup with percent and stacked groups
r105 qreal h = mHeight;
qreal scale = (h / colSum);
sauimone
percent bar chart
r101 qreal yPos = h;
sauimone
brush support for bargroups
r183 for (int set=0; set < mModel.countSets(); set++) {
qreal barHeight = mModel.valueAt(set, category) * scale;
sauimone
percent bar chart
r101 Bar* bar = reinterpret_cast<Bar*> (childItems().at(itemIndex));
// TODO: width settable per bar?
bar->resize(mBarDefaultWidth, barHeight);
sauimone
brush support for bargroups
r183 bar->setBrush(mBrushes.at(set));
// bar->setBrush(mBrush);
// bar->setColor(mColors.at(set));
sauimone
theme interface to barcharts. some minor fixes
r113 bar->setPos(xPos, yPos-barHeight);
sauimone
percent bar chart
r101 itemIndex++;
yPos -= barHeight;
}
sauimone
added labels to barcharts
r114
// TODO: Layout for labels, remove magic number
BarLabel* label = reinterpret_cast<BarLabel*> (childItems().at(labelIndex));
label->setPos(xPos, mHeight + 20);
labelIndex++;
sauimone
percent bar chart
r101 xPos += xStep;
}
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126
// Position separators
int separatorIndex = labelIndex; // Separators are after labels in childItems(). TODO: better way to store these?
xPos = xStep + xStep/2; // Initial position is between first and second group. ie one and half steps from left.
sauimone
Barset and barcategory implememtation. Updated test application
r171 for (int s=0; s < mModel.countCategories() - 1; s++) {
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 Separator* sep = reinterpret_cast<Separator*> (childItems().at(separatorIndex));
sep->setPos(xPos,0);
sep->setSize(QSizeF(1,mHeight));
xPos += xStep;
separatorIndex++;
}
sauimone
model delegate for bar series. updated examples
r161
sauimone
percent bar chart
r101 mLayoutDirty = true;
}
QTCOMMERCIALCHART_END_NAMESPACE