##// END OF EJS Templates
Adds default gemoetry change call in case of new series
Adds default gemoetry change call in case of new series

File last commit:

r126:2dc5911e790e
r148:38a3d03baaf6
Show More
bargroup.cpp
65 lines | 1.9 KiB | text/x-c | CppLexer
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 #include "bargroup.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
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 #include <QDebug>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
Added bar chart example
r78 BarGroup::BarGroup(BarChartSeries& series, QGraphicsItem *parent) :
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 BarGroupBase(series,parent)
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 {
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126 mBarDefaultWidth = 10;
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 }
void BarGroup::layoutChanged()
{
// Scale bars to new layout
// Layout for bars:
sauimone
bar chart layout fixing
r99 if (mSeries.countRows() <= 0) {
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 // Nothing to do.
return;
}
sauimone
percent bar chart
r101 // TODO: better way to auto-layout?
sauimone
bar chart layout fixing
r99 // Use reals for accurancy (we might get some compiler warnings... :)
int columnCount = mSeries.countColumns();
int rowCount = mSeries.countRows();
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56
sauimone
bar chart layout fixing
r99 qreal tW = mWidth;
qreal tH = mHeight;
qreal tM = mMax;
qreal scale = (tH/tM);
qreal tC = columnCount+1;
qreal xStepPerSeries = (tW/tC);
sauimone
correct drawing for barchart
r82 // Scaling.
sauimone
Improved bar chart series
r71 int itemIndex(0);
sauimone
added labels to barcharts
r114 int labelIndex = mSeries.countColumns() * mSeries.countRows();
sauimone
bar chart layout fixing
r99 for (int column=0; column < columnCount; column++) {
qreal xPos = xStepPerSeries * column + ((tW + mBarDefaultWidth*rowCount)/(columnCount*2));
sauimone
theme interface to barcharts. some minor fixes
r113 qreal yPos = mHeight;
sauimone
bar chart layout fixing
r99 for (int row = 0; row < rowCount; row++) {
qreal barHeight = mSeries.valueAt(row, column) * scale;
Bar* bar = reinterpret_cast<Bar*> (childItems().at(itemIndex));
// TODO: width settable per bar?
bar->resize(mBarDefaultWidth, barHeight);
bar->setColor(mColors.at(row));
sauimone
theme interface to barcharts. some minor fixes
r113 bar->setPos(xPos, yPos-barHeight); // item*posStep+startPos + series * mBarDefaultWidth, mHeight);
sauimone
bar chart layout fixing
r99 itemIndex++;
xPos += mBarDefaultWidth;
}
sauimone
added labels to barcharts
r114
// TODO: Layout for labels, remove magic number
xPos = xStepPerSeries * column + ((tW + mBarDefaultWidth*rowCount)/(columnCount*2));
BarLabel* label = reinterpret_cast<BarLabel*> (childItems().at(labelIndex));
label->setPos(xPos, mHeight + 20);
labelIndex++;
sauimone
bar chart layout fixing
r99 }
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 mLayoutDirty = true;
}
QTCOMMERCIALCHART_END_NAMESPACE