KChart

KChartDataValueAttributes.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3 *
4 * This file is part of the KD Chart library.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef KCHARTDATAVALUEATTRIBUTES_H
10#define KCHARTDATAVALUEATTRIBUTES_H
11
12#include <Qt>
13#include <QMetaType>
14#include "KChartGlobal.h"
15#include "KChartEnums.h"
16#include "KChartRelativePosition.h"
17
18/** \file KChartDataValueAttributes.h
19 * \brief Declaring the class KChart::DataValueAttributes.
20 *
21 *
22 */
23
24
25namespace KChart {
26
27 class TextAttributes;
29 class FrameAttributes;
30 class MarkerAttributes;
31
32 /**
33 * \class DataValueAttributes KChartDataValueAttributes.h KChartDataValueAttributes
34 * \brief Diagram attributes dealing with data value labels.
35 *
36 * The DataValueAttributes group all properties that can be set
37 * wrt data value labels and if and how they are displayed. This
38 * includes things like the text attributes (font, color), what
39 * markers are used, how many decimal digits are displayed, etc.
40 */
41class KCHART_EXPORT DataValueAttributes
42{
43public:
44 DataValueAttributes();
45 DataValueAttributes( const DataValueAttributes& );
46 DataValueAttributes &operator= ( const DataValueAttributes& );
47 bool operator==( const DataValueAttributes& ) const;
48 inline bool operator!=( const DataValueAttributes& other ) const { return !operator==(other); }
49
50 ~DataValueAttributes();
51
52 static const DataValueAttributes& defaultAttributes();
53 static const QVariant& defaultAttributesAsVariant();
54
55 /** Set whether data value labels should be displayed.
56 * \param visible Whether data value labels should be displayed.
57 */
58 void setVisible( bool visible );
59
60 /**
61 * @return Whether data value labels should be displayed.
62 */
63 bool isVisible() const;
64
65 /**
66 * Set the text attributes to use for the data value labels.
67 * \param a The text attributes to set.
68 * \see TextAttributes
69 */
70 void setTextAttributes( const TextAttributes &a );
71
72 /**
73 * \return The text attributes used for painting data value labels.
74 */
76
77 /**
78 * If true, rotation of negative value labels is negated, so that negative
79 * values are rotated in opposite direction of textAttributes().rotation(),
80 * and in this sense appear "mirrored" to positive value labels, though the
81 * text itself is *not* mirrored, only its rotation.
82 */
84
85 /**
86 * \see mirrorNegativeValueTextRotation()
87 */
88 void setMirrorNegativeValueTextRotation( bool enable );
89
90 /**
91 * Set the frame attributes to use for the data value labels area.
92 * \param a The frame attributes to set.
93 * \see FrameAttributes
94 */
95 void setFrameAttributes( const FrameAttributes &a );
96
97 /**
98 * \return The frame attributes used for painting the data
99 * value labels area.
100 * \see FrameAttributes
101 */
103
104 /**
105 * Set the background attributes to use for the data value labels area.
106 * \param a The background attributes to set.
107 * \see BackgroundAttributes
108 */
110
111 /**
112 * \return The background attributes used for painting the data
113 * value labels area.
114 * \see BackgroundAttributes
115 */
117
118 /**
119 * Set the marker attributes to use for the data values. This includes
120 * the marker type.
121 * \param a The marker attributes to set.
122 * \see MarkerAttributes
123 */
124 void setMarkerAttributes( const MarkerAttributes &a );
125
126 /**
127 * \return The marker attributes used for decorating the data
128 * values.
129 * \see MarkerAttributes
130 */
132
133 /**
134 * Specify whether to use percentages instead of actual data point values when no
135 * specific label is set. In a bar or cartesian diagram, this means that the value
136 * will be shown in % in relation to the sum of all values in the same category, in
137 * a polar diagram in relation to the sum of all values in a data set.
138 *
139 * When this is turned on, the value will \b not automatically have the '%' postfix.
140 * \param enable Whether to enable percentage values
141 */
142 void setUsePercentage( bool enable );
143
144 /**
145 * \return Whether to use percentage values
146 * \see setUsePercentage
147 */
148 bool usePercentage() const;
149
150 /**
151 * Set how many decimal digits to display when rendering the data value
152 * labels. If there are no decimal digits it will not be displayed.
153 * \param digits The number of decimal digits to use.
154 */
155 void setDecimalDigits( int digits );
156
157 /**
158 * \return The number of decimal digits displayed.
159 */
160 int decimalDigits() const;
161
162 /**
163 * \brief Prepend a prefix string to the data value label
164 * \sa prefix
165 */
166 void setPrefix( const QString prefix );
167
168 /**
169 * \brief Returns the string used as a prefix to the data value text.
170 * \sa setPrefix
171 */
172 QString prefix() const;
173
174 /**
175 * \brief Append a suffix string to the data value label
176 * \sa suffix
177 */
178 void setSuffix( const QString suffix );
179
180 /**
181 * \brief Returns the string used as a suffix to the data value text.
182 * \sa setSuffix
183 */
184 QString suffix() const;
185
186 /**
187 * \brief display a string label instead of the original data value label
188 * Supports HTML code.
189 * \sa dataLabel
190 */
191 void setDataLabel( const QString label );
192
193 /**
194 * \brief Returns the string displayed instead of the data value label
195 * \sa setDataLabel
196 */
197 QString dataLabel() const;
198
199 /**
200 * \return Whether data values not different from their predecessors are drawn.
201 */
202 bool showRepetitiveDataLabels() const;
203
204 /**
205 *
206 * Set whether data value labels not different from their predecessors should be drawn.
207 * \param showRepetitiveDataLabels Whether data value not different from their predecessors are drawn.
208 */
210
211 /**
212 * \return Whether data value texts overlapping other data value texts of the same diagram are drawn.
213 */
214 bool showOverlappingDataLabels() const;
215
216 /**
217 *
218 * Set whether data value texts overlapping other data value texts of the same diagram should be drawn.
219 * \param showOverlappingDataLabels Whether data texts overlapping other data value texts of the same diagram are drawn.
220 */
222
223 /**
224 * \cond PLANNED_FOR_FUTURE
225 *
226 * These method are planned for future versions of KD Chart,
227 * so they are not part of the documented API yet.
228 *
229 */
230 void setPowerOfTenDivisor( int powerOfTenDivisor );
231 int powerOfTenDivisor() const;
232 /**
233 * \endcond
234 */
235
236
237 /**
238 * \cond PLANNED_FOR_FUTURE
239 *
240 * These method are planned for future versions of KD Chart,
241 * so they are not part of the documented API yet.
242 */
243 void setShowInfinite( bool infinite );
244 bool showInfinite() const;
245 /**
246 * \endcond
247 */
248
249 /**
250 * \brief Defines the relative positioning of the data value labels for negative values.
251 *
252 * The position is specified in relation to the respective data value point, or in
253 * relation to the respective data representation area, that's one area segment in
254 * a LineDiagram showing areas, or one bar in a BarDiagram, one pie slice ...
255 *
256 * See detailed description of \a KChart::Position for an illustration of the
257 * different possible reference positions.
258 *
259 * \sa negativePosition
260 */
261 void setNegativePosition( const RelativePosition& relPosition );
262
263 /**
264 * \brief Return the relative positioning of the data value labels
265 * \sa setNegativePosition
266 */
268
269 /**
270 * \brief Defines the relative position of the data value labels for positive values.
271 *
272 * The position is specified in relation to the respective data value point, or in
273 * relation to the respective data representation area, that's one area segment in
274 * a LineDiagram showing areas, or one bar in a BarDiagram, one pie slice ...
275 *
276 * See detailed description of \a KChart::Position for an illustration of the
277 * different possible reference positions.
278 *
279 * \sa positivePosition
280 */
281 void setPositivePosition( const RelativePosition& relPosition );
282
283 /**
284 * \brief Return the relative positioning of the data value labels
285 * \sa setPositivePosition
286 */
288
289 const RelativePosition position( bool positive ) const
290 {
291 return positive ? positivePosition() : negativePosition();
292 }
293
294private:
295 KCHART_DECLARE_PRIVATE_BASE_VALUE( DataValueAttributes )
296
297}; // End of class DataValueAttributes
298
299}
300
301#if !defined(QT_NO_DEBUG_STREAM)
302KCHART_EXPORT QDebug operator<<(QDebug, const KChart::DataValueAttributes& );
303#endif /* QT_NO_DEBUG_STREAM */
304
305KCHART_DECLARE_SWAP_SPECIALISATION( KChart::DataValueAttributes )
306
307QT_BEGIN_NAMESPACE
308Q_DECLARE_TYPEINFO( KChart::DataValueAttributes, Q_MOVABLE_TYPE );
309QT_END_NAMESPACE
310
311Q_DECLARE_METATYPE( KChart::DataValueAttributes )
312
313#endif // KCHARTDATAVALUEATTRIBUTES_H
Definition of global enums.
Contains KChart macros.
Set of attributes usable for background pixmaps.
Diagram attributes dealing with data value labels.
void setFrameAttributes(const FrameAttributes &a)
Set the frame attributes to use for the data value labels area.
void setDataLabel(const QString label)
display a string label instead of the original data value label Supports HTML code.
const RelativePosition positivePosition() const
Return the relative positioning of the data value labels.
void setDecimalDigits(int digits)
Set how many decimal digits to display when rendering the data value labels.
void setMarkerAttributes(const MarkerAttributes &a)
Set the marker attributes to use for the data values.
void setPositivePosition(const RelativePosition &relPosition)
Defines the relative position of the data value labels for positive values.
void setUsePercentage(bool enable)
Specify whether to use percentages instead of actual data point values when no specific label is set.
MarkerAttributes markerAttributes() const
const RelativePosition negativePosition() const
Return the relative positioning of the data value labels.
BackgroundAttributes backgroundAttributes() const
void setBackgroundAttributes(const BackgroundAttributes &a)
Set the background attributes to use for the data value labels area.
bool mirrorNegativeValueTextRotation() const
If true, rotation of negative value labels is negated, so that negative values are rotated in opposit...
QString prefix() const
Returns the string used as a prefix to the data value text.
void setShowOverlappingDataLabels(bool showOverlappingDataLabels)
Set whether data value texts overlapping other data value texts of the same diagram should be drawn.
void setTextAttributes(const TextAttributes &a)
Set the text attributes to use for the data value labels.
void setNegativePosition(const RelativePosition &relPosition)
Defines the relative positioning of the data value labels for negative values.
void setVisible(bool visible)
Set whether data value labels should be displayed.
QString suffix() const
Returns the string used as a suffix to the data value text.
QString dataLabel() const
Returns the string displayed instead of the data value label.
void setPrefix(const QString prefix)
Prepend a prefix string to the data value label.
void setShowRepetitiveDataLabels(bool showRepetitiveDataLabels)
Set whether data value labels not different from their predecessors should be drawn.
void setSuffix(const QString suffix)
Append a suffix string to the data value label.
A set of attributes for frames around items.
A set of attributes controlling the appearance of data set markers.
Defines relative position information: reference area, position in this area (reference position),...
A set of text attributes.
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:56:24 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.