barchartseries.cpp
55 lines
| 1020 B
| text/x-c
|
CppLexer
sauimone
|
r56 | #include "barchartseries.h" | ||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
sauimone
|
r62 | BarChartSeries::BarChartSeries(QObject *parent) | ||
sauimone
|
r56 | : QChartSeries(parent) | ||
{ | ||||
} | ||||
sauimone
|
r62 | bool BarChartSeries::setData(QList<int> data) | ||
{ | ||||
mData = data; | ||||
return true; | ||||
} | ||||
sauimone
|
r56 | int BarChartSeries::min() | ||
{ | ||||
sauimone
|
r62 | Q_ASSERT(mData.count() > 0); | ||
sauimone
|
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. | ||||
int min = mData.at(0); | ||||
for (int i=0; i <mData.count(); i++) { | ||||
if (mData.at(i) < min) { | ||||
min = mData.at(i); | ||||
} | ||||
} | ||||
return min; | ||||
} | ||||
int BarChartSeries::max() | ||||
{ | ||||
sauimone
|
r62 | Q_ASSERT(mData.count() > 0); | ||
sauimone
|
r56 | int max = mData.at(0); | ||
for (int i=0; i <mData.count(); i++) { | ||||
if (mData.at(i) > max) { | ||||
max = mData.at(i); | ||||
} | ||||
} | ||||
return max; | ||||
} | ||||
int BarChartSeries::count() | ||||
{ | ||||
return mData.count(); | ||||
} | ||||
int BarChartSeries::valueAt(int i) | ||||
{ | ||||
return mData.at(i); | ||||
} | ||||
QTCOMMERCIALCHART_END_NAMESPACE | ||||