1
/****************************************************************************
2
** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
4
** This file is part of the KD Chart library.
6
** Licensees holding valid commercial KD Chart licenses may use this file in
7
** accordance with the KD Chart Commercial License Agreement provided with
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 and version 3 as published by the
13
** Free Software Foundation and appearing in the file LICENSE.GPL included.
15
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18
** Contact info@kdab.com if any conditions of this licensing are not
21
**********************************************************************/
23
#ifndef KDCHARTDATAVALUEATTRIBUTES_H
24
#define KDCHARTDATAVALUEATTRIBUTES_H
28
#include "KDChartGlobal.h"
29
#include "KDChartEnums.h"
30
#include "KDChartRelativePosition.h"
32
/** \file KDChartDataValueAttributes.h
33
* \brief Declaring the class KDChart::DataValueAttributes.
42
class BackgroundAttributes;
43
class FrameAttributes;
44
class MarkerAttributes;
47
* \class DataValueAttributes KDChartDataValueAttributes.h KDChartDataValueAttributes
48
* \brief Diagram attributes dealing with data value labels.
50
* The DataValueAttributes group all properties that can be set
51
* wrt data value labels and if and how they are displayed. This
52
* includes things like the text attributes (font, color), what
53
* markers are used, howmany decimal digits are displayed, etc.
55
class KDCHART_EXPORT DataValueAttributes
58
DataValueAttributes();
59
DataValueAttributes( const DataValueAttributes& );
60
DataValueAttributes &operator= ( const DataValueAttributes& );
61
bool operator==( const DataValueAttributes& ) const;
62
inline bool operator!=( const DataValueAttributes& other ) const { return !operator==(other); }
64
~DataValueAttributes();
66
static const DataValueAttributes& defaultAttributes();
67
static const QVariant& defaultAttributesAsVariant();
69
/** Set whether data value labels should be displayed.
70
* \param visible Whether data value labels should be displayed.
72
void setVisible( bool visible );
75
* @return Whether data value labels should be displayed.
77
bool isVisible() const;
80
* Set the text attributes to use for the data value labels.
81
* \param a The text attributes to set.
84
void setTextAttributes( const TextAttributes &a );
87
* \return The text attributes used for painting data value labels.
89
TextAttributes textAttributes() const;
92
* Set the frame attributes to use for the data value labels area.
93
* \param a The frame attributes to set.
94
* \see FrameAttributes
96
void setFrameAttributes( const FrameAttributes &a );
99
* \return The frame attributes used for painting the data
101
* \see FrameAttributes
103
FrameAttributes frameAttributes() const;
106
* Set the background attributes to use for the data value labels area.
107
* \param a The background attributes to set.
108
* \see BackgroundAttributes
110
void setBackgroundAttributes( const BackgroundAttributes &a );
113
* \return The background attributes used for painting the data
115
* \see BackgroundAttributes
117
BackgroundAttributes backgroundAttributes() const;
120
* Set the marker attributes to use for the data values. This includes
122
* \param a The marker attributes to set.
123
* \see MarkerAttributes
125
void setMarkerAttributes( const MarkerAttributes &a );
128
* \return The marker attributes used for decorating the data
130
* \see MarkerAttributes
132
MarkerAttributes markerAttributes() const;
135
* Specify whether to use percentages instead of actual data point values when no
136
* specific label is set. In a bar or cartesian diagram, this means that the value
137
* will be shown in % in relation to the sum of all values in the same category, in
138
* a polar diagram in relation to the sum of all values in a data set.
140
* When this is turned on, the value will \b not automatically have the '%' postfix.
141
* \param enable Whether to enable percentage values
143
void setUsePercentage( bool enable );
146
* \return Whether to use percentage values
147
* \see setUsePercentage
149
bool usePercentage() const;
152
* Set how many decimal digits to display when rendering the data value
153
* labels. If there are no decimal digits it will not be displayed.
154
* \param digits The number of decimal digits to use.
156
void setDecimalDigits( int digits );
159
* \return The number of decimal digits displayed.
161
int decimalDigits() const;
164
* \brief Prepend a prefix string to the data value label
167
void setPrefix( const QString prefix );
170
* \brief Returns the string used as a prefix to the data value text.
173
QString prefix() const;
176
* \brief Append a suffix string to the data value label
179
void setSuffix( const QString suffix );
182
* \brief Returns the string used as a suffix to the data value text.
185
QString suffix() const;
188
* \brief display a string label instead of the original data value label
189
* Supports HTML code.
192
void setDataLabel( const QString label );
195
* \brief Returns the string displayed instead of the data value label
198
QString dataLabel() const;
201
* \return Whether data values not different from their predecessors are drawn.
203
bool showRepetitiveDataLabels() const;
207
* Set whether data value labels not different from their predecessors should be drawn.
208
* \param showRepetitiveDataLabels Whether data value not different from their predecessors are drawn.
210
void setShowRepetitiveDataLabels( bool showRepetitiveDataLabels );
213
* \return Whether data value texts overlapping other data value texts of the same diagram are drawn.
215
bool showOverlappingDataLabels() const;
219
* Set whether data value texts overlapping other data value texts of the same diagram should be drawn.
220
* \param showOverlappingDataLabels Whether data texts overlapping other data value texts of the same diagram are drawn.
222
void setShowOverlappingDataLabels( bool showOverlappingDataLabels );
225
* \cond PLANNED_FOR_FUTURE
227
* These method are planned for future versions of KD Chart,
228
* so they are not part of the documented API yet.
231
void setPowerOfTenDivisor( int powerOfTenDivisor );
232
int powerOfTenDivisor() const;
239
* \cond PLANNED_FOR_FUTURE
241
* These method are planned for future versions of KD Chart,
242
* so they are not part of the documented API yet.
244
void setShowInfinite( bool infinite );
245
bool showInfinite() const;
251
* \brief Defines the relative positioning of the data value labels for negative values.
253
* The position is specified in relation to the respective data value point, or in
254
* releation to the respective data representation area, that's one area segment in
255
* a LineDiagram showing areas, or one bar in a BarDiagram, one pie slice ...
257
* \sa negativePosition
259
void setNegativePosition( const RelativePosition& relPosition );
262
* \brief Return the relative positioning of the data value labels
263
* \sa setNegativePosition
265
const RelativePosition negativePosition() const;
268
* \brief Defines the relative position of the data value labels for positive values.
270
* The position is specified in relation to the respective data value point, or in
271
* releation to the respective data representation area, that's one area segment in
272
* a LineDiagram showing areas, or one bar in a BarDiagram, one pie slice ...
274
* \sa positivePosition
276
void setPositivePosition( const RelativePosition& relPosition );
279
* \brief Return the relative positioning of the data value labels
280
* \sa setPositivePosition
282
const RelativePosition positivePosition() const;
284
const RelativePosition position( bool positive ) const
286
return positive ? positivePosition() : negativePosition();
290
KDCHART_DECLARE_PRIVATE_BASE_VALUE( DataValueAttributes )
292
}; // End of class DataValueAttributes
296
#if !defined(QT_NO_DEBUG_STREAM)
297
KDCHART_EXPORT QDebug operator<<(QDebug, const KDChart::DataValueAttributes& );
298
#endif /* QT_NO_DEBUG_STREAM */
300
Q_DECLARE_METATYPE( KDChart::DataValueAttributes )
301
Q_DECLARE_TYPEINFO( KDChart::DataValueAttributes, Q_MOVABLE_TYPE );
302
KDCHART_DECLARE_SWAP_SPECIALISATION( KDChart::DataValueAttributes )
304
#endif // KDCHARTDATAVALUEATTRIBUTES_H