kchart

KDChartVectorSeries.cpp
1/*
2 KDChart - a multi-platform charting engine
3 */
4
5/****************************************************************************
6 ** Copyright (C) 2001-2003 Klarälvdalens Datakonsult AB. All rights reserved.
7 **
8 ** This file is part of the KDChart library.
9 **
10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file.
14 **
15 ** Licensees holding valid commercial KDChart licenses may use this file in
16 ** accordance with the KDChart Commercial License Agreement provided with
17 ** the Software.
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
22 ** See http://www.klaralvdalens-datakonsult.se/?page=products for
23 ** information about KDChart Commercial License Agreements.
24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you.
27 **
28 **********************************************************************/
29
30#include "KDChartVectorSeries.h"
31#include "KDChartSeriesCollection.h"
32
33
34KDChartVectorSeries::~KDChartVectorSeries()
35{
36}
37
38
39
40uint KDChartVectorSeries::rows() const
41{
42 return size();
43}
44
45const KDChartData& KDChartVectorSeries::cell( uint row ) const
46{
47 Q_ASSERT( row < size() );
48 // make it compile on windows using qt232
49 return this->at(row);
50}
51
52void KDChartVectorSeries::setCell( uint row, const KDChartData& element)
53{
54 Q_ASSERT( row < size() );
55 // make it compile on windows using qt232
56 this->at(row) = element;
57}
58
59void KDChartVectorSeries::expand( uint rows )
60{
61 resize(rows);
62}
63
64
65// we return !ok if its on the infinite axis
66double KDChartVectorSeries::maxValue( int coordinate, bool &ok ) const
67{
68 double maxValue = 0.0;
69 bool bStart = true;
70
71 KDChartVectorSeries::const_iterator i;
72 for ( i = begin(); i != end(); i ++ )
73 {
74 const KDChartData& d = *i;
75 if ( d.isDouble( coordinate ) )
76 {
77 if ( bStart )
78 {
79 maxValue = d.doubleValue( coordinate );
80 bStart = false;
81 }
82 else
83 maxValue = TQMAX( maxValue, d.doubleValue( coordinate ) );
84 }
85 }
86
87 ok = !bStart;
88 return maxValue;
89}
90
91
92
93double KDChartVectorSeries::minValue( int coordinate, bool &ok ) const
94{
95 double minValue = 0.0;
96 bool bStart = true;
97
98 KDChartVectorSeries::const_iterator i;
99 for ( i = begin(); i != end(); i ++ )
100 {
101 const KDChartData& d = *i;
102 if ( d.isDouble( coordinate ) )
103 {
104 if ( bStart )
105 {
106 minValue = d.doubleValue( coordinate );
107 bStart = false;
108 }
109 else
110 minValue = TQMIN( minValue, d.doubleValue( coordinate ) );
111 }
112 }
113
114 ok = !bStart;
115 return minValue;
116}
Encapsulates one data cell in a chart.
double doubleValue(int valNo=1) const
Returns the double value represented by this object, or DBL_MIN if this object does not represent a d...
bool isDouble(int valNo=1) const
Returns true if the object represents a double value and false otherwise.