summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/graphinfo.cpp
authordrw <drw>2002-11-02 21:45:56 (UTC)
committer drw <drw>2002-11-02 21:45:56 (UTC)
commit2dc81c48428222533e5479947d9ad318e464bafa (patch) (side-by-side diff)
tree2e3570d18f3574c49ffc8aaf287bac4822ff3a11 /noncore/apps/checkbook/graphinfo.cpp
parent5e1893923a9ddf1e2bd3e8f9c0dd264d86b8d98d (diff)
downloadopie-2dc81c48428222533e5479947d9ad318e464bafa.zip
opie-2dc81c48428222533e5479947d9ad318e464bafa.tar.gz
opie-2dc81c48428222533e5479947d9ad318e464bafa.tar.bz2
Implementing charting...
Diffstat (limited to 'noncore/apps/checkbook/graphinfo.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/checkbook/graphinfo.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/noncore/apps/checkbook/graphinfo.cpp b/noncore/apps/checkbook/graphinfo.cpp
index 7b06bdb..ec6a465 100644
--- a/noncore/apps/checkbook/graphinfo.cpp
+++ b/noncore/apps/checkbook/graphinfo.cpp
@@ -35,12 +35,23 @@ GraphInfo::GraphInfo( GraphType type, DataPointList *data, const QString &title,
d = data;
gt = title;
xt = xtitle;
yt = ytitle;
}
+GraphInfo::~GraphInfo()
+{
+ if ( d )
+ {
+ for ( DataPointInfo *data = d->first(); data; data = d->next() )
+ {
+ delete data;
+ }
+ }
+}
+
GraphInfo::GraphType GraphInfo::graphType()
{
return t;
}
void GraphInfo::setGraphType( GraphType type )
@@ -55,20 +66,48 @@ DataPointList *GraphInfo::dataPoints()
void GraphInfo::setDataPoints( DataPointList *data )
{
d = data;
}
-float GraphInfo::maxValue()
+DataPointInfo *GraphInfo::firstDataPoint()
{
- float max;
+ return( d->first() );
+}
+DataPointInfo *GraphInfo::nextDataPoint()
+{
+ return( d->next() );
}
-float GraphInfo::minValue()
+int GraphInfo::numberDataPoints()
{
+ return( d->count() );
+}
+
+float GraphInfo::maxValue()
+{
+ float max = 0.0;
+ for ( DataPointInfo *data = d->first(); data; data = d->next() )
+ {
+ if ( data->value() > max )
+ {
+ max = data->value();
+ }
+ }
+ return max;
+}
+
+float GraphInfo::totalValue()
+{
+ float sum = 0.0;
+ for ( DataPointInfo *data = d->first(); data; data = d->next() )
+ {
+ sum += data->value();
+ }
+ return sum;
}
void GraphInfo::setGraphTitle( const QString &title )
{
gt = title;
}