KD Chart API Documentation 3.1
Loading...
Searching...
No Matches
KDChartDataValueAttributes.cpp
Go to the documentation of this file.
1/****************************************************************************
2**
3** This file is part of the KD Chart library.
4**
5** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: MIT
8**
9****************************************************************************/
10
12
13#include "KDChartPosition.h"
19#include <QDebug>
20#include <QVariant>
21
22#include <KDABLibFakes>
23
24// FIXME till
25#define KDCHART_DATA_VALUE_AUTO_DIGITS 4
26
27#define d d_func()
28
29using namespace KDChart;
30
31class DataValueAttributes::Private
32{
33 friend class DataValueAttributes;
34
35public:
36 Private();
37
38private:
39 TextAttributes textAttributes;
40 FrameAttributes frameAttributes;
41 BackgroundAttributes backgroundAttributes;
42 MarkerAttributes markerAttributes;
43 QString prefix;
44 QString suffix;
45 QString dataLabel;
46 RelativePosition negativeRelPos;
47 RelativePosition positiveRelPos;
48 qint16 decimalDigits = KDCHART_DATA_VALUE_AUTO_DIGITS;
49 qint16 powerOfTenDivisor = 0;
50 bool visible : 1;
51 bool showInfinite : 1;
52 bool showRepetitiveDataLabels : 1;
53 bool showOverlappingDataLabels : 1;
54 bool usePercentage : 1;
55 bool mirrorNegativeValueTextRotation : 1;
56};
57
58DataValueAttributes::Private::Private()
59 : visible(false)
60 , showInfinite(true)
61{
64 me.setValue(8.0);
68
69 // we set the Position to unknown: so the diagrams can take their own decisions
70 positiveRelPos.setReferencePosition(Position::Unknown);
71 negativeRelPos.setReferencePosition(Position::Unknown);
72
73 positiveRelPos.setAlignment(Qt::AlignTop | Qt::AlignRight);
74 negativeRelPos.setAlignment(Qt::AlignBottom | Qt::AlignRight);
75
78
79 usePercentage = false;
81}
82
84 : _d(new Private())
85{
86}
87
89 : _d(new Private(*r.d))
90{
91}
92
94{
95 if (this == &r)
96 return *this;
97
98 *d = *r.d;
99
100 return *this;
101}
102
104{
105 delete _d;
106 _d = nullptr;
107}
108
113
114/*static*/
116{
117 static const DataValueAttributes theDefaultDataValueAttributes;
118 return theDefaultDataValueAttributes;
119}
120
121/*static*/
123{
124 static const QVariant theDefaultDataValueAttributesVariant = QVariant::fromValue(defaultAttributes());
125 return theDefaultDataValueAttributesVariant;
126}
127
129{
130 d->visible = visible;
131}
132
134{
135 return d->visible;
136}
137
139{
140 d->textAttributes = a;
141}
142
144{
145 return d->textAttributes;
146}
147
149{
150 d->frameAttributes = a;
151}
152
154{
155 return d->frameAttributes;
156}
157
159{
160 d->backgroundAttributes = a;
161}
162
164{
165 return d->backgroundAttributes;
166}
167
169{
170 d->markerAttributes = a;
171}
172
174{
175 return d->markerAttributes;
176}
177
179{
180 d->mirrorNegativeValueTextRotation = enable;
181}
182
184{
185 return d->mirrorNegativeValueTextRotation;
186}
187
189{
190 d->usePercentage = enable;
191}
192
194{
195 return d->usePercentage;
196}
197
199{
200 d->decimalDigits = digits;
201}
202
204{
205 return d->decimalDigits;
206}
207
209{
210 d->prefix = prefixString;
211}
212
214{
215 return d->prefix;
216}
217
219{
220 d->suffix = suffixString;
221}
222
224{
225 return d->suffix;
226}
227
229{
230 d->dataLabel = label;
231}
232
234{
235 return d->dataLabel;
236}
237
239{
240 return d->showRepetitiveDataLabels;
241}
242
243void DataValueAttributes::setShowRepetitiveDataLabels(bool showRepetitiveDataLabels)
244{
245 d->showRepetitiveDataLabels = showRepetitiveDataLabels;
246}
247
249{
250 return d->showOverlappingDataLabels;
251}
252
253void DataValueAttributes::setShowOverlappingDataLabels(bool showOverlappingDataLabels)
254{
255 d->showOverlappingDataLabels = showOverlappingDataLabels;
256}
257
258void DataValueAttributes::setPowerOfTenDivisor(int powerOfTenDivisor)
259{
260 d->powerOfTenDivisor = powerOfTenDivisor;
261}
262
263int DataValueAttributes::powerOfTenDivisor() const
264{
265 return d->powerOfTenDivisor;
266}
267
268void DataValueAttributes::setShowInfinite(bool infinite)
269{
270 d->showInfinite = infinite;
271}
272
273bool DataValueAttributes::showInfinite() const
274{
275 return d->showInfinite;
276}
277
279{
280 d->negativeRelPos = relPosition;
281}
282
284{
285 return d->negativeRelPos;
286}
287
289{
290 d->positiveRelPos = relPosition;
291}
292
294{
295 return d->positiveRelPos;
296}
297
298#if !defined(QT_NO_DEBUG_STREAM)
300{
301 dbg << "RelativePosition DataValueAttributes("
302 << "visible=" << val.isVisible()
303 << "textattributes=" << val.textAttributes()
304 << "frameattributes=" << val.frameAttributes()
305 << "backgroundattributes=" << val.backgroundAttributes()
306 << "decimaldigits=" << val.decimalDigits()
307 << "poweroftendivisor=" << val.powerOfTenDivisor()
308 << "showinfinite=" << val.showInfinite()
309 << "negativerelativeposition=" << val.negativePosition()
310 << "positiverelativeposition=" << val.positivePosition()
311 << "showRepetitiveDataLabels=" << val.showRepetitiveDataLabels()
312 << "showOverlappingDataLabels=" << val.showOverlappingDataLabels()
313 << ")";
314 return dbg;
315}
316#endif /* QT_NO_DEBUG_STREAM */
#define KDCHART_DATA_VALUE_AUTO_DIGITS
Declaring the class KDChart::DataValueAttributes.
@ MeasureCalculationModeAbsolute
@ MeasureCalculationModeAuto
Diagram attributes dealing with data value labels.
void setPrefix(const QString &prefix)
Prepend a prefix string to the data value label.
void setFrameAttributes(const FrameAttributes &a)
const RelativePosition positivePosition() const
Return the relative positioning of the data value labels.
bool operator==(const DataValueAttributes &) const
void setMarkerAttributes(const MarkerAttributes &a)
void setPositivePosition(const RelativePosition &relPosition)
Defines the relative position of the data value labels for positive values.
DataValueAttributes & operator=(const DataValueAttributes &)
const RelativePosition negativePosition() const
Return the relative positioning of the data value labels.
void setSuffix(const QString &suffix)
Append a suffix string to the data value label.
BackgroundAttributes backgroundAttributes() const
void setBackgroundAttributes(const BackgroundAttributes &a)
static const QVariant & defaultAttributesAsVariant()
void setDataLabel(const QString &label)
display a string label instead of the original data value label Supports HTML code.
QString prefix() const
Returns the string used as a prefix to the data value text.
void setShowOverlappingDataLabels(bool showOverlappingDataLabels)
void setTextAttributes(const TextAttributes &a)
void setNegativePosition(const RelativePosition &relPosition)
Defines the relative positioning of the data value labels for negative values.
static const DataValueAttributes & defaultAttributes()
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 setShowRepetitiveDataLabels(bool showRepetitiveDataLabels)
A set of attributes for frames around items.
A set of attributes controlling the appearance of data set markers.
Measure is used to specify relative and absolute sizes in KDChart, e.g. font sizes.
static const Position & Unknown
Defines relative position information: reference area, position in this area (reference position),...
A set of text attributes.
void setFontSize(const Measure &measure)
void setMinimalFontSize(const Measure &measure)
QDebug operator<<(QDebug stream, const DataDimension &r)
AlignTop
QVariant fromValue(const T &value)

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated on Fri Apr 26 2024 00:04:57 for KD Chart API Documentation by doxygen 1.9.8