##// END OF EJS Templates
correct drawing for barchart
correct drawing for barchart

File last commit:

r82:144fd3c1acc4
r82:144fd3c1acc4
Show More
barchartseries.cpp
91 lines | 2.2 KiB | text/x-c | CppLexer
/ src / barchart / barchartseries.cpp
sauimone
Improved bar chart series
r71 #include <QDebug>
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 #include "barchartseries.h"
sauimone
BarGroup and Bar as ChartItems instead of GraphicItems
r74 #include "bargroup.h"
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
Refactored series creation.
r62 BarChartSeries::BarChartSeries(QObject *parent)
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 : QChartSeries(parent)
{
}
sauimone
Improved bar chart series
r71 bool BarChartSeries::setData(QAbstractItemModel* model)
sauimone
Refactored series creation.
r62 {
sauimone
Improved bar chart series
r71 mModel = model;
sauimone
Refactored series creation.
r62 }
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 int BarChartSeries::min()
{
sauimone
Improved bar chart series
r71 Q_ASSERT(mModel->rowCount() > 0);
Q_ASSERT(mModel->columnCount() > 0);
sauimone
Refactored series creation.
r62
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 // TODO: make min and max members and update them when data changes.
// This is slower since they are checked every time, even if data is same since previous call.
sauimone
Improved bar chart series
r71 QModelIndex modelIndex = mModel->index(0,0);
int min = mModel->data(modelIndex).toInt();
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56
sauimone
Improved bar chart series
r71 for (int i=0; i <mModel->rowCount(); i++) {
for(int j=0; j<mModel->columnCount(); j++) {
modelIndex = mModel->index(i,j);
int temp = mModel->data(modelIndex).toInt();
if (temp < min) {
min = temp;
}
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 }
}
return min;
}
int BarChartSeries::max()
{
sauimone
Improved bar chart series
r71 Q_ASSERT(mModel->rowCount() > 0);
Q_ASSERT(mModel->columnCount() > 0);
sauimone
Refactored series creation.
r62
sauimone
Improved bar chart series
r71 // TODO: make min and max members and update them when data changes.
// This is slower since they are checked every time, even if data is same since previous call.
QModelIndex modelIndex = mModel->index(0,0);
int max = mModel->data(modelIndex).toInt();
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56
sauimone
Improved bar chart series
r71 for (int i=0; i <mModel->rowCount(); i++) {
for(int j=0; j<mModel->columnCount(); j++) {
modelIndex = mModel->index(i,j);
int temp = mModel->data(modelIndex).toInt();
if (temp > max) {
max = temp;
}
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 }
}
return max;
}
sauimone
Improved bar chart series
r71
int BarChartSeries::countSeries()
{
return mModel->rowCount();
}
int BarChartSeries::countItemsInSeries()
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 {
sauimone
Improved bar chart series
r71 return mModel->columnCount();
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 }
sauimone
Improved bar chart series
r71 int BarChartSeries::countTotalItems()
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 {
sauimone
Improved bar chart series
r71 return mModel->rowCount() * mModel->columnCount();
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 }
sauimone
Improved bar chart series
r71 int BarChartSeries::valueAt(int series, int item)
{
QModelIndex index = mModel->index(series,item);
return mModel->data(index).toInt();
}
sauimone
correct drawing for barchart
r82 /*
sauimone
Improved bar chart series
r71 void BarChartSeries::chartSizeChanged(QRectF rect)
{
qDebug() << "barchart size changed:" << rect;
sauimone
BarGroup and Bar as ChartItems instead of GraphicItems
r74 // mBarGroup->resize(rect.toRect().width(), rect.toRect().height());
sauimone
Improved bar chart series
r71 }
sauimone
correct drawing for barchart
r82 */
sauimone
Improved bar chart series
r71 #include "moc_barchartseries.cpp"
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 QTCOMMERCIALCHART_END_NAMESPACE