##// END OF EJS Templates
Added QChart::localizeNumbers...
Miikka Heikkinen -
r2707:ef2ab40bd1b9
parent child
Show More
@@ -175,6 +175,15 QTCOMMERCIALCHART_BEGIN_NAMESPACE
175 175 */
176 176
177 177 /*!
178 \qmlproperty bool ChartView::localizeNumbers
179 \since QtCharts 2.0
180 When \c{true}, all generated numbers appearing in various series and axis labels will be
181 localized using the default QLocale of the application, which defaults to the system locale.
182 When \c{false}, the "C" locale is always used.
183 Defaults to \c{false}.
184 */
185
186 /*!
178 187 \qmlmethod AbstractSeries ChartView::series(int index)
179 188 Returns the series with \a index on the chart. This allows you to loop through the series of a chart together with
180 189 the count property of the chart.
@@ -710,6 +719,19 QColor QtCommercialChart::DeclarativeChart::plotAreaColor()
710 719 return m_chart->plotAreaBackgroundBrush().color();
711 720 }
712 721
722 void DeclarativeChart::setLocalizeNumbers(bool localize)
723 {
724 if (m_chart->localizeNumbers() != localize) {
725 m_chart->setLocalizeNumbers(localize);
726 emit localizeNumbersChanged();
727 }
728 }
729
730 bool DeclarativeChart::localizeNumbers() const
731 {
732 return m_chart->localizeNumbers();
733 }
734
713 735 int DeclarativeChart::count()
714 736 {
715 737 return m_chart->series().count();
@@ -67,6 +67,7 class DeclarativeChart : public QDECLARATIVE_PAINTED_ITEM
67 67 #else
68 68 Q_PROPERTY(QDeclarativeListProperty<QAbstractAxis> axes READ axes REVISION 2)
69 69 #endif
70 Q_PROPERTY(bool localizeNumbers READ localizeNumbers WRITE setLocalizeNumbers NOTIFY localizeNumbersChanged REVISION 4)
70 71 Q_ENUMS(Animation)
71 72 Q_ENUMS(Theme)
72 73 Q_ENUMS(SeriesType)
@@ -142,6 +143,9 public:
142 143 QColor backgroundColor();
143 144 Q_REVISION(3) void setPlotAreaColor(QColor color);
144 145 Q_REVISION(3) QColor plotAreaColor();
146 Q_REVISION(4) void setLocalizeNumbers(bool localize);
147 Q_REVISION(4) bool localizeNumbers() const;
148
145 149 int count();
146 150 void setDropShadowEnabled(bool enabled);
147 151 bool dropShadowEnabled();
@@ -196,6 +200,7 Q_SIGNALS:
196 200 void seriesRemoved(QAbstractSeries *series);
197 201 Q_REVISION(3) void plotAreaColorChanged();
198 202 Q_REVISION(3) void backgroundRoundnessChanged(qreal diameter);
203 Q_REVISION(4) bool localizeNumbersChanged();
199 204
200 205 private Q_SLOTS:
201 206 void changeMinimumMargins(int top, int bottom, int left, int right);
@@ -258,6 +258,7 public:
258 258 qmlRegisterType<QVBoxPlotModelMapper>(uri, 2, 0, "VBoxPlotModelMapper");
259 259 qmlRegisterUncreatableType<QBoxPlotModelMapper>(uri, 2, 0, "BoxPlotModelMapper",
260 260 QLatin1String("Trying to create uncreatable: BoxPlotModelMapper."));
261 qmlRegisterType<DeclarativeChart, 4>(uri, 2, 0, "ChartView");
261 262 }
262 263 };
263 264
@@ -201,8 +201,10 void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
201 201
202 202 if (m_series->upperSeries()) {
203 203 for (int i(0); i < m_series->upperSeries()->count(); i++) {
204 pointLabel.replace(xPointTag, QString::number(m_series->upperSeries()->at(i).x()));
205 pointLabel.replace(yPointTag, QString::number(m_series->upperSeries()->at(i).y()));
204 pointLabel.replace(xPointTag,
205 presenter()->numberToString(m_series->upperSeries()->at(i).x()));
206 pointLabel.replace(yPointTag,
207 presenter()->numberToString(m_series->upperSeries()->at(i).y()));
206 208
207 209 // Position text in relation to the point
208 210 int pointLabelWidth = fm.width(pointLabel);
@@ -216,8 +218,10 void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
216 218
217 219 if (m_series->lowerSeries()) {
218 220 for (int i(0); i < m_series->lowerSeries()->count(); i++) {
219 pointLabel.replace(xPointTag, QString::number(m_series->lowerSeries()->at(i).x()));
220 pointLabel.replace(yPointTag, QString::number(m_series->lowerSeries()->at(i).y()));
221 pointLabel.replace(xPointTag,
222 presenter()->numberToString(m_series->lowerSeries()->at(i).x()));
223 pointLabel.replace(yPointTag,
224 presenter()->numberToString(m_series->lowerSeries()->at(i).y()));
221 225
222 226 // Position text in relation to the point
223 227 int pointLabelWidth = fm.width(pointLabel);
@@ -29,12 +29,17
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 static const char *labelFormatMatchString = "%[\\-\\+#\\s\\d\\.lhjztL]*([dicuoxfegXFEG])";
32 static const char *labelFormatMatchLocalizedString = "^([^%]*)%\\.?(\\d)*([defgEG])(.*)$";
32 33 static QRegExp *labelFormatMatcher = 0;
34 static QRegExp *labelFormatMatcherLocalized = 0;
33 35 class StaticLabelFormatMatcherDeleter
34 36 {
35 37 public:
36 38 StaticLabelFormatMatcherDeleter() {}
37 ~StaticLabelFormatMatcherDeleter() { delete labelFormatMatcher; }
39 ~StaticLabelFormatMatcherDeleter() {
40 delete labelFormatMatcher;
41 delete labelFormatMatcherLocalized;
42 }
38 43 };
39 44 static StaticLabelFormatMatcherDeleter staticLabelFormatMatcherDeleter;
40 45
@@ -233,75 +238,96 qreal ChartAxisElement::max() const
233 238 return m_axis->d_ptr->max();
234 239 }
235 240
236 static void appendFormattedLabel(const QString &capStr, const QByteArray &array,
237 QStringList &labels, qreal value)
241 QString ChartAxisElement::formatLabel(const QString &formatSpec, const QByteArray &array,
242 qreal value, int precision, const QString &preStr,
243 const QString &postStr) const
238 244 {
239 if (capStr.isEmpty()) {
240 labels << QString();
241 } else if (capStr.at(0) == QLatin1Char('d')
242 || capStr.at(0) == QLatin1Char('i')
243 || capStr.at(0) == QLatin1Char('c')) {
244 labels << QString().sprintf(array, (qint64)value);
245 } else if (capStr.at(0) == QLatin1Char('u')
246 || capStr.at(0) == QLatin1Char('o')
247 || capStr.at(0) == QLatin1Char('x')
248 || capStr.at(0) == QLatin1Char('X')) {
249 labels << QString().sprintf(array, (quint64)value);
250 } else if (capStr.at(0) == QLatin1Char('f')
251 || capStr.at(0) == QLatin1Char('F')
252 || capStr.at(0) == QLatin1Char('e')
253 || capStr.at(0) == QLatin1Char('E')
254 || capStr.at(0) == QLatin1Char('g')
255 || capStr.at(0) == QLatin1Char('G')) {
256 labels << QString().sprintf(array, value);
245 QString retVal;
246 if (!formatSpec.isEmpty()) {
247 if (formatSpec.at(0) == QLatin1Char('d')
248 || formatSpec.at(0) == QLatin1Char('i')
249 || formatSpec.at(0) == QLatin1Char('c')) {
250 if (presenter()->localizeNumbers())
251 retVal = preStr + presenter()->locale().toString(qint64(value)) + postStr;
252 else
253 retVal = QString().sprintf(array, qint64(value));
254 } else if (formatSpec.at(0) == QLatin1Char('u')
255 || formatSpec.at(0) == QLatin1Char('o')
256 || formatSpec.at(0) == QLatin1Char('x')
257 || formatSpec.at(0) == QLatin1Char('X')) {
258 // These formats are not supported by localized numbers
259 retVal = QString().sprintf(array, quint64(value));
260 } else if (formatSpec.at(0) == QLatin1Char('f')
261 || formatSpec.at(0) == QLatin1Char('F')
262 || formatSpec.at(0) == QLatin1Char('e')
263 || formatSpec.at(0) == QLatin1Char('E')
264 || formatSpec.at(0) == QLatin1Char('g')
265 || formatSpec.at(0) == QLatin1Char('G')) {
266 if (presenter()->localizeNumbers()) {
267 retVal = preStr
268 + presenter()->locale().toString(value, formatSpec.at(0).toLatin1(),
269 precision)
270 + postStr;
257 271 } else {
258 labels << QString();
272 retVal = QString().sprintf(array, value);
273 }
259 274 }
260 275 }
276 return retVal;
277 }
261 278
262 QStringList ChartAxisElement::createValueLabels(qreal min, qreal max, int ticks, const QString &format)
279 QStringList ChartAxisElement::createValueLabels(qreal min, qreal max, int ticks,
280 const QString &format) const
263 281 {
264 282 QStringList labels;
265 283
266 284 if (max <= min || ticks < 1)
267 285 return labels;
268 286
269 int n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0);
270 n++;
271
272 287 if (format.isNull()) {
288 int n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0) + 1;
273 289 for (int i = 0; i < ticks; i++) {
274 290 qreal value = min + (i * (max - min) / (ticks - 1));
275 labels << QString::number(value, 'f', n);
291 labels << presenter()->numberToString(value, 'f', n);
276 292 }
277 293 } else {
278 294 QByteArray array = format.toLatin1();
279 QString capStr;
295 QString formatSpec;
296 QString preStr;
297 QString postStr;
298 int precision = 0;
299 if (presenter()->localizeNumbers()) {
300 if (!labelFormatMatcherLocalized)
301 labelFormatMatcherLocalized = new QRegExp(labelFormatMatchLocalizedString);
302 if (labelFormatMatcherLocalized->indexIn(format, 0) != -1) {
303 preStr = labelFormatMatcherLocalized->cap(1);
304 precision = labelFormatMatcherLocalized->cap(2).toInt();
305 formatSpec = labelFormatMatcherLocalized->cap(3);
306 postStr = labelFormatMatcherLocalized->cap(4);
307 }
308 } else {
280 309 if (!labelFormatMatcher)
281 310 labelFormatMatcher = new QRegExp(labelFormatMatchString);
282 311 if (labelFormatMatcher->indexIn(format, 0) != -1)
283 capStr = labelFormatMatcher->cap(1);
312 formatSpec = labelFormatMatcher->cap(1);
313 }
284 314 for (int i = 0; i < ticks; i++) {
285 315 qreal value = min + (i * (max - min) / (ticks - 1));
286 appendFormattedLabel(capStr, array, labels, value);
316 labels << formatLabel(formatSpec, array, value, precision, preStr, postStr);
287 317 }
288 318 }
289 319
290 320 return labels;
291 321 }
292 322
293 QStringList ChartAxisElement::createLogValueLabels(qreal min, qreal max, qreal base, int ticks, const QString &format)
323 QStringList ChartAxisElement::createLogValueLabels(qreal min, qreal max, qreal base, int ticks,
324 const QString &format) const
294 325 {
295 326 QStringList labels;
296 327
297 328 if (max <= min || ticks < 1)
298 329 return labels;
299 330
300 int n = 0;
301 if (ticks > 1)
302 n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0);
303 n++;
304
305 331 int firstTick;
306 332 if (base > 1)
307 333 firstTick = ceil(log10(min) / log10(base));
@@ -309,27 +335,46 QStringList ChartAxisElement::createLogValueLabels(qreal min, qreal max, qreal b
309 335 firstTick = ceil(log10(max) / log10(base));
310 336
311 337 if (format.isNull()) {
338 int n = 0;
339 if (ticks > 1)
340 n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0);
341 n++;
312 342 for (int i = firstTick; i < ticks + firstTick; i++) {
313 343 qreal value = qPow(base, i);
314 labels << QString::number(value, 'f', n);
344 labels << presenter()->numberToString(value, 'f', n);
315 345 }
316 346 } else {
317 347 QByteArray array = format.toLatin1();
318 QString capStr;
348 QString formatSpec;
349 QString preStr;
350 QString postStr;
351 int precision = 0;
352 if (presenter()->localizeNumbers()) {
353 if (!labelFormatMatcherLocalized)
354 labelFormatMatcherLocalized = new QRegExp(labelFormatMatchLocalizedString);
355 if (labelFormatMatcherLocalized->indexIn(format, 0) != -1) {
356 preStr = labelFormatMatcherLocalized->cap(1);
357 precision = labelFormatMatcherLocalized->cap(2).toInt();
358 formatSpec = labelFormatMatcherLocalized->cap(3);
359 postStr = labelFormatMatcherLocalized->cap(4);
360 }
361 } else {
319 362 if (!labelFormatMatcher)
320 363 labelFormatMatcher = new QRegExp(labelFormatMatchString);
321 364 if (labelFormatMatcher->indexIn(format, 0) != -1)
322 capStr = labelFormatMatcher->cap(1);
365 formatSpec = labelFormatMatcher->cap(1);
366 }
323 367 for (int i = firstTick; i < ticks + firstTick; i++) {
324 368 qreal value = qPow(base, i);
325 appendFormattedLabel(capStr, array, labels, value);
369 labels << formatLabel(formatSpec, array, value, precision, preStr, postStr);
326 370 }
327 371 }
328 372
329 373 return labels;
330 374 }
331 375
332 QStringList ChartAxisElement::createDateTimeLabels(qreal min, qreal max,int ticks,const QString &format)
376 QStringList ChartAxisElement::createDateTimeLabels(qreal min, qreal max,int ticks,
377 const QString &format) const
333 378 {
334 379 QStringList labels;
335 380
@@ -77,9 +77,10 public:
77 77 //this flag indicates that axis is used to show intervals it means labels are in between ticks
78 78 bool intervalAxis() const { return m_intervalAxis; }
79 79
80 static QStringList createValueLabels(qreal max, qreal min, int ticks, const QString &format);
81 static QStringList createLogValueLabels(qreal min, qreal max, qreal base, int ticks, const QString &format);
82 static QStringList createDateTimeLabels(qreal max, qreal min, int ticks, const QString &format);
80 QStringList createValueLabels(qreal max, qreal min, int ticks, const QString &format) const;
81 QStringList createLogValueLabels(qreal min, qreal max, qreal base, int ticks,
82 const QString &format) const;
83 QStringList createDateTimeLabels(qreal max, qreal min, int ticks, const QString &format) const;
83 84
84 85 // from QGraphicsLayoutItem
85 86 QRectF boundingRect() const
@@ -132,6 +133,9 Q_SIGNALS:
132 133
133 134 private:
134 135 void connectSlots();
136 QString formatLabel(const QString &formatSpec, const QByteArray &array,
137 qreal value, int precision, const QString &preStr,
138 const QString &postStr) const;
135 139
136 140 QAbstractAxis *m_axis;
137 141 AxisAnimation *m_animation;
@@ -106,14 +106,22 QTCOMMERCIALCHART_BEGIN_NAMESPACE
106 106 /*!
107 107 \property QValueAxis::labelFormat
108 108 Defines the label format of the axis.
109 Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, c
109 Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, and c.
110 110 See QString::sprintf() for additional details.
111
112 If the QChart::localizeNumbers is \c{true}, the supported specifiers are limited to: d, e, E, f,
113 g, and G. Also, only the precision modifier is supported. The rest of the formatting comes from
114 the default QLocale of the application.
111 115 */
112 116 /*!
113 117 \qmlproperty real ValueAxis::labelFormat
114 118 Defines the label format of the axis.
115 Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, c
119 Supported specifiers are: d, i, o, x, X, f, F, e, E, g, G, and c.
116 120 See QString::sprintf() for additional details.
121
122 If the ChartView::localizeNumbers is \c{true}, the supported specifiers are limited to: d, e, E, f,
123 g, and G. Also, only the precision modifier is supported. The rest of the formatting comes from
124 the default QLocale of the application.
117 125 */
118 126
119 127 /*!
@@ -217,11 +217,14 void AbstractBarChartItem::handleUpdatedBars()
217 217
218 218 QGraphicsTextItem *label = m_labels.at(itemIndex);
219 219 QString valueLabel;
220 if (presenter()) { // At startup presenter is not yet set, yet somehow update comes
220 221 if (m_series->labelsFormat().isEmpty()) {
221 valueLabel = QString("%1").arg(barSet->value(category));
222 valueLabel = presenter()->numberToString(barSet->value(category));
222 223 } else {
223 224 valueLabel = m_series->labelsFormat();
224 valueLabel.replace(valueTag, QString::number(barSet->value(category)));
225 valueLabel.replace(valueTag,
226 presenter()->numberToString(barSet->value(category)));
227 }
225 228 }
226 229 label->setHtml(valueLabel);
227 230 label->setFont(barSet->m_labelFont);
@@ -115,16 +115,15 void HorizontalPercentBarChartItem::handleUpdatedBars()
115 115 bar->update();
116 116
117 117 QGraphicsTextItem *label = m_labels.at(itemIndex);
118 int p = m_series->d_func()->percentageAt(set, category) * 100;
119 QString vString(QString::number(p));
120 vString.truncate(3);
121 vString.append("%");
118 qreal p = m_series->d_func()->percentageAt(set, category) * 100.0;
119 QString vString(presenter()->numberToString(p, 'f', 0));
122 120 QString valueLabel;
123 121 if (m_series->labelsFormat().isEmpty()) {
122 vString.append("%");
124 123 valueLabel = vString;
125 124 } else {
126 125 valueLabel = m_series->labelsFormat();
127 valueLabel.replace(valueTag, QString::number(barSet->value(category)));
126 valueLabel.replace(valueTag, vString);
128 127 }
129 128 label->setHtml(valueLabel);
130 129 label->setFont(barSet->m_labelFont);
@@ -120,16 +120,15 void PercentBarChartItem::handleUpdatedBars()
120 120 bar->update();
121 121
122 122 QGraphicsTextItem *label = m_labels.at(itemIndex);
123 int p = m_series->d_func()->percentageAt(set, category) * 100;
124 QString vString(QString::number(p));
125 vString.truncate(3);
126 vString.append("%");
123 qreal p = m_series->d_func()->percentageAt(set, category) * 100.0;
124 QString vString(presenter()->numberToString(p, 'f', 0));
127 125 QString valueLabel;
128 126 if (m_series->labelsFormat().isEmpty()) {
127 vString.append("%");
129 128 valueLabel = vString;
130 129 } else {
131 130 valueLabel = m_series->labelsFormat();
132 valueLabel.replace(valueTag, QString::number(barSet->value(category)));
131 valueLabel.replace(valueTag, vString);
133 132 }
134 133 label->setHtml(valueLabel);
135 134 label->setFont(barSet->m_labelFont);
@@ -44,7 +44,8 ChartPresenter::ChartPresenter(QChart *chart, QChart::ChartType type)
44 44 m_state(ShowState),
45 45 m_background(0),
46 46 m_plotAreaBackground(0),
47 m_title(0)
47 m_title(0),
48 m_localizeNumbers(false)
48 49 {
49 50 if (type == QChart::ChartTypeCartesian)
50 51 m_layout = new CartesianChartLayout(this);
@@ -102,6 +103,7 void ChartPresenter::handleSeriesAdded(QAbstractSeries *series)
102 103 {
103 104 series->d_ptr->initializeGraphics(rootItem());
104 105 series->d_ptr->initializeAnimations(m_options);
106 series->d_ptr->setPresenter(this);
105 107 ChartItem *chart = series->d_ptr->chartItem();
106 108 chart->setPresenter(this);
107 109 chart->setThemeManager(m_chart->d_ptr->m_themeManager);
@@ -344,6 +346,17 bool ChartPresenter::isBackgroundDropShadowEnabled() const
344 346 return m_background->isDropShadowEnabled();
345 347 }
346 348
349 void ChartPresenter::setLocalizeNumbers(bool localize)
350 {
351 m_localizeNumbers = localize;
352 m_layout->invalidate();
353 }
354
355 bool ChartPresenter::localizeNumbers() const
356 {
357 return m_localizeNumbers;
358 }
359
347 360
348 361 AbstractChartLayout *ChartPresenter::layout()
349 362 {
@@ -475,6 +488,14 QString ChartPresenter::truncatedText(const QFont &font, const QString &text, qr
475 488 return truncatedString;
476 489 }
477 490
491 QString ChartPresenter::numberToString(double value, char f, int prec)
492 {
493 if (m_localizeNumbers)
494 return m_locale.toString(value, f, prec);
495 else
496 return QString::number(value, f, prec);
497 }
498
478 499 #include "moc_chartpresenter_p.cpp"
479 500
480 501 QTCOMMERCIALCHART_END_NAMESPACE
@@ -34,6 +34,7
34 34 #include "qchart.h" //because of QChart::ChartThemeId
35 35 #include <QRectF>
36 36 #include <QMargins>
37 #include <QLocale>
37 38
38 39 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39 40
@@ -129,6 +130,9 public:
129 130 void setBackgroundDropShadowEnabled(bool enabled);
130 131 bool isBackgroundDropShadowEnabled() const;
131 132
133 void setLocalizeNumbers(bool localize);
134 bool localizeNumbers() const;
135
132 136 void setVisible(bool visible);
133 137
134 138 void setAnimationOptions(QChart::AnimationOptions options);
@@ -148,6 +152,10 public:
148 152 static QString truncatedText(const QFont &font, const QString &text, qreal angle,
149 153 qreal maxWidth, qreal maxHeight, QRectF &boundingRect);
150 154 inline static qreal textMargin() { return qreal(0.5); }
155
156 QString numberToString(double value, char f = 'g', int prec = 6);
157 inline const QLocale &locale() const { return m_locale; }
158
151 159 private:
152 160 void createBackgroundItem();
153 161 void createPlotAreaBackgroundItem();
@@ -173,6 +181,8 private:
173 181 QAbstractGraphicsShapeItem *m_plotAreaBackground;
174 182 ChartTitle *m_title;
175 183 QRectF m_rect;
184 bool m_localizeNumbers;
185 QLocale m_locale;
176 186 };
177 187
178 188 QTCOMMERCIALCHART_END_NAMESPACE
@@ -303,6 +303,16 void QAbstractSeriesPrivate::setDomain(AbstractDomain* domain)
303 303 }
304 304 }
305 305
306 void QAbstractSeriesPrivate::setPresenter(ChartPresenter *presenter)
307 {
308 m_presenter = presenter;
309 }
310
311 ChartPresenter *QAbstractSeriesPrivate::presenter() const
312 {
313 return m_presenter;
314 }
315
306 316 void QAbstractSeriesPrivate::initializeGraphics(QGraphicsItem* parent)
307 317 {
308 318 Q_ASSERT(!m_item.isNull());
@@ -73,6 +73,9 public:
73 73 virtual void setDomain(AbstractDomain* domain);
74 74 AbstractDomain* domain() { return m_domain.data(); }
75 75
76 virtual void setPresenter(ChartPresenter *presenter);
77 ChartPresenter *presenter() const;
78
76 79 QChart* chart() { return m_chart; }
77 80
78 81 Q_SIGNALS:
@@ -88,6 +91,7 private:
88 91 QString m_name;
89 92 bool m_visible;
90 93 qreal m_opacity;
94 ChartPresenter *m_presenter;
91 95
92 96 friend class QAbstractSeries;
93 97 friend class ChartDataSet;
@@ -145,6 +145,15 QTCOMMERCIALCHART_BEGIN_NAMESPACE
145 145 */
146 146
147 147 /*!
148 \property QChart::localizeNumbers
149 \since QtCharts 2.0
150 When \c{true}, all generated numbers appearing in various series and axis labels will be
151 localized using the default QLocale of the application, which defaults to the system locale.
152 When \c{false}, the "C" locale is always used.
153 Defaults to \c{false}.
154 */
155
156 /*!
148 157 \internal
149 158 Constructs a chart object of \a type which is a child of a \a parent.
150 159 Parameter \a wFlags is passed to the QGraphicsWidget constructor.
@@ -561,6 +570,16 bool QChart::isPlotAreaBackgroundVisible() const
561 570 return d_ptr->m_presenter->isPlotAreaBackgroundVisible();
562 571 }
563 572
573 void QChart::setLocalizeNumbers(bool localize)
574 {
575 d_ptr->m_presenter->setLocalizeNumbers(localize);
576 }
577
578 bool QChart::localizeNumbers() const
579 {
580 return d_ptr->m_presenter->localizeNumbers();
581 }
582
564 583 void QChart::setAnimationOptions(AnimationOptions options)
565 584 {
566 585 d_ptr->m_presenter->setAnimationOptions(options);
@@ -49,6 +49,7 class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsWidget
49 49 Q_PROPERTY(QMargins margins READ margins WRITE setMargins)
50 50 Q_PROPERTY(QChart::ChartType chartType READ chartType)
51 51 Q_PROPERTY(bool plotAreaBackgroundVisible READ isPlotAreaBackgroundVisible WRITE setPlotAreaBackgroundVisible)
52 Q_PROPERTY(bool localizeNumbers READ localizeNumbers WRITE setLocalizeNumbers)
52 53 Q_ENUMS(ChartTheme)
53 54 Q_ENUMS(AnimationOption)
54 55 Q_ENUMS(ChartType)
@@ -151,6 +152,8 public:
151 152 QPen plotAreaBackgroundPen() const;
152 153 void setPlotAreaBackgroundVisible(bool visible = true);
153 154 bool isPlotAreaBackgroundVisible() const;
155 void setLocalizeNumbers(bool localize);
156 bool localizeNumbers() const;
154 157
155 158 QPointF mapToValue(const QPointF &position, QAbstractSeries *series = 0);
156 159 QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = 0);
@@ -785,8 +785,8 void QXYSeriesPrivate::drawSeriesPointLabels(QPainter *painter, const QVector<QP
785 785
786 786 for (int i(0); i < m_points.size(); i++) {
787 787 QString pointLabel = m_pointLabelsFormat;
788 pointLabel.replace(xPointTag, QString::number(m_points.at(i).x()));
789 pointLabel.replace(yPointTag, QString::number(m_points.at(i).y()));
788 pointLabel.replace(xPointTag, presenter()->numberToString(m_points.at(i).x()));
789 pointLabel.replace(yPointTag, presenter()->numberToString(m_points.at(i).y()));
790 790
791 791 // Position text in relation to the point
792 792 int pointLabelWidth = fm.width(pointLabel);
General Comments 0
You need to be logged in to leave comments. Login now