##// END OF EJS Templates
Fixed regression in declarative impl
Fixed regression in declarative impl

File last commit:

r167:023d2c8150a8
r168:23b5a494bf5a
Show More
stackedbargroup.cpp
83 lines | 2.5 KiB | text/x-c | CppLexer
/ src / barchart / stackedbargroup.cpp
sauimone
fixed naming mixup with percent and stacked groups
r105 #include "stackedbargroup.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
added missing example files :)
r96 #include <QDebug>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
fixed naming mixup with percent and stacked groups
r105 StackedBarGroup::StackedBarGroup(StackedBarChartSeries& series, QGraphicsItem *parent) :
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 BarGroupBase(series,parent)
sauimone
added missing example files :)
r96 {
}
sauimone
fixed naming mixup with percent and stacked groups
r105 void StackedBarGroup::layoutChanged()
sauimone
added missing example files :)
r96 {
sauimone
integrating bar charts to test app.. crashes for now
r164 qDebug() << "StackedBarGroup::layoutChanged";
sauimone
added missing example files :)
r96 // Scale bars to new layout
// Layout for bars:
sauimone
model delegate for bar series. updated examples
r161 if (mModel.countRows() <= 0) {
sauimone
added missing example files :)
r96 // Nothing to do.
return;
}
sauimone
model delegate for bar series. updated examples
r161 if (mModel.countColumns() == 0) {
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) {
qDebug() << "WARNING: StackedBarGroup::layoutChanged called before graphics items are created!";
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
prototyping separators with stacked bars
r119 // TODO: use temp variable for column count...
sauimone
model delegate for bar series. updated examples
r161 qreal maxSum = mModel.maxColumnSum();
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
fixing layout bug on stacked bar chart
r98 qreal tW = mWidth;
sauimone
model delegate for bar series. updated examples
r161 qreal tC = mModel.countColumns() + 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
model delegate for bar series. updated examples
r161 int labelIndex = mModel.countRows() * mModel.countColumns();
sauimone
fixing layout bug on stacked bar chart
r98
sauimone
model delegate for bar series. updated examples
r161 for (int column = 0; column < mModel.countColumns(); column++) {
sauimone
fixing layout bug on stacked bar chart
r98 qreal yPos = h;
sauimone
model delegate for bar series. updated examples
r161 for (int row=0; row < mModel.countRows(); row++) {
qreal barHeight = mModel.valueAt(row, column) * scale;
sauimone
added missing example files :)
r96 Bar* bar = reinterpret_cast<Bar*> (childItems().at(itemIndex));
bar->resize(mBarDefaultWidth, barHeight);
bar->setColor(mColors.at(row));
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
BarLabel* label = reinterpret_cast<BarLabel*> (childItems().at(labelIndex));
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
refactored barcharts. layout to derived classess other funtionality to base class
r126
sauimone
prototyping separators with stacked bars
r119 // Position separators
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 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
model delegate for bar series. updated examples
r161 for (int s=0; s < mModel.countColumns() - 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));
sauimone
prototyping separators with stacked bars
r119 xPos += xStep;
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 separatorIndex++;
sauimone
prototyping separators with stacked bars
r119 }
sauimone
model delegate for bar series. updated examples
r161
sauimone
added missing example files :)
r96 mLayoutDirty = true;
}
QTCOMMERCIALCHART_END_NAMESPACE