@@ -29,7 +29,7 | |||||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | static const char *labelFormatMatchString = "%[\\-\\+#\\s\\d\\.lhjztL]*([dicuoxfegXFEG])"; |
|
31 | static const char *labelFormatMatchString = "%[\\-\\+#\\s\\d\\.lhjztL]*([dicuoxfegXFEG])"; | |
32 | static const char *labelFormatMatchLocalizedString = "^([^%]*)%\\.?(\\d)*([defgEG])(.*)$"; |
|
32 | static const char *labelFormatMatchLocalizedString = "^([^%]*)%\\.?(\\d)*([defgiEG])(.*)$"; | |
33 | static QRegExp *labelFormatMatcher = 0; |
|
33 | static QRegExp *labelFormatMatcher = 0; | |
34 | static QRegExp *labelFormatMatcherLocalized = 0; |
|
34 | static QRegExp *labelFormatMatcherLocalized = 0; | |
35 | class StaticLabelFormatMatcherDeleter |
|
35 | class StaticLabelFormatMatcherDeleter | |
@@ -295,13 +295,14 QStringList ChartAxisElement::createValueLabels(qreal min, qreal max, int ticks, | |||||
295 | QString formatSpec; |
|
295 | QString formatSpec; | |
296 | QString preStr; |
|
296 | QString preStr; | |
297 | QString postStr; |
|
297 | QString postStr; | |
298 | int precision = 0; |
|
298 | int precision = 6; // Six is the default precision in Qt API | |
299 | if (presenter()->localizeNumbers()) { |
|
299 | if (presenter()->localizeNumbers()) { | |
300 | if (!labelFormatMatcherLocalized) |
|
300 | if (!labelFormatMatcherLocalized) | |
301 | labelFormatMatcherLocalized = new QRegExp(labelFormatMatchLocalizedString); |
|
301 | labelFormatMatcherLocalized = new QRegExp(labelFormatMatchLocalizedString); | |
302 | if (labelFormatMatcherLocalized->indexIn(format, 0) != -1) { |
|
302 | if (labelFormatMatcherLocalized->indexIn(format, 0) != -1) { | |
303 | preStr = labelFormatMatcherLocalized->cap(1); |
|
303 | preStr = labelFormatMatcherLocalized->cap(1); | |
304 |
|
|
304 | if (!labelFormatMatcherLocalized->cap(2).isEmpty()) | |
|
305 | precision = labelFormatMatcherLocalized->cap(2).toInt(); | |||
305 | formatSpec = labelFormatMatcherLocalized->cap(3); |
|
306 | formatSpec = labelFormatMatcherLocalized->cap(3); | |
306 | postStr = labelFormatMatcherLocalized->cap(4); |
|
307 | postStr = labelFormatMatcherLocalized->cap(4); | |
307 | } |
|
308 | } | |
@@ -348,13 +349,14 QStringList ChartAxisElement::createLogValueLabels(qreal min, qreal max, qreal b | |||||
348 | QString formatSpec; |
|
349 | QString formatSpec; | |
349 | QString preStr; |
|
350 | QString preStr; | |
350 | QString postStr; |
|
351 | QString postStr; | |
351 | int precision = 0; |
|
352 | int precision = 6; // Six is the default precision in Qt API | |
352 | if (presenter()->localizeNumbers()) { |
|
353 | if (presenter()->localizeNumbers()) { | |
353 | if (!labelFormatMatcherLocalized) |
|
354 | if (!labelFormatMatcherLocalized) | |
354 | labelFormatMatcherLocalized = new QRegExp(labelFormatMatchLocalizedString); |
|
355 | labelFormatMatcherLocalized = new QRegExp(labelFormatMatchLocalizedString); | |
355 | if (labelFormatMatcherLocalized->indexIn(format, 0) != -1) { |
|
356 | if (labelFormatMatcherLocalized->indexIn(format, 0) != -1) { | |
356 | preStr = labelFormatMatcherLocalized->cap(1); |
|
357 | preStr = labelFormatMatcherLocalized->cap(1); | |
357 |
|
|
358 | if (!labelFormatMatcherLocalized->cap(2).isEmpty()) | |
|
359 | precision = labelFormatMatcherLocalized->cap(2).toInt(); | |||
358 | formatSpec = labelFormatMatcherLocalized->cap(3); |
|
360 | formatSpec = labelFormatMatcherLocalized->cap(3); | |
359 | postStr = labelFormatMatcherLocalized->cap(4); |
|
361 | postStr = labelFormatMatcherLocalized->cap(4); | |
360 | } |
|
362 | } |
@@ -110,7 +110,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
110 | See QString::sprintf() for additional details. |
|
110 | See QString::sprintf() for additional details. | |
111 |
|
111 | |||
112 | If the QChart::localizeNumbers is \c{true}, the supported specifiers are limited to: d, e, E, f, |
|
112 | If the QChart::localizeNumbers is \c{true}, the supported specifiers are limited to: d, e, E, f, | |
113 |
g, |
|
113 | g, G, and i. Also, only the precision modifier is supported. The rest of the formatting comes from | |
114 | the default QLocale of the application. |
|
114 | the default QLocale of the application. | |
115 | */ |
|
115 | */ | |
116 | /*! |
|
116 | /*! | |
@@ -120,7 +120,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
120 | See QString::sprintf() for additional details. |
|
120 | See QString::sprintf() for additional details. | |
121 |
|
121 | |||
122 | If the ChartView::localizeNumbers is \c{true}, the supported specifiers are limited to: d, e, E, f, |
|
122 | If the ChartView::localizeNumbers is \c{true}, the supported specifiers are limited to: d, e, E, f, | |
123 |
g, |
|
123 | g, G, and i. Also, only the precision modifier is supported. The rest of the formatting comes from | |
124 | the default QLocale of the application. |
|
124 | the default QLocale of the application. | |
125 | */ |
|
125 | */ | |
126 |
|
126 |
@@ -950,7 +950,7 void QAbstractBarSeriesPrivate::populateCategories(QBarCategoryAxis *axis) | |||||
950 | QStringList categories; |
|
950 | QStringList categories; | |
951 | if (axis->categories().isEmpty()) { |
|
951 | if (axis->categories().isEmpty()) { | |
952 | for (int i(1); i < categoryCount() + 1; i++) |
|
952 | for (int i(1); i < categoryCount() + 1; i++) | |
953 |
categories << |
|
953 | categories << presenter()->numberToString(i); | |
954 | axis->append(categories); |
|
954 | axis->append(categories); | |
955 | } |
|
955 | } | |
956 | } |
|
956 | } |
@@ -418,7 +418,7 void QBoxPlotSeriesPrivate::populateCategories(QBarCategoryAxis *axis) | |||||
418 | for (int i(1); i < m_boxSets.count() + 1; i++) { |
|
418 | for (int i(1); i < m_boxSets.count() + 1; i++) { | |
419 | QBoxSet *set = m_boxSets.at(i - 1); |
|
419 | QBoxSet *set = m_boxSets.at(i - 1); | |
420 | if (set->label().isEmpty()) |
|
420 | if (set->label().isEmpty()) | |
421 |
categories << |
|
421 | categories << presenter()->numberToString(i); | |
422 | else |
|
422 | else | |
423 | categories << set->label(); |
|
423 | categories << set->label(); | |
424 | } |
|
424 | } |
@@ -496,6 +496,14 QString ChartPresenter::numberToString(double value, char f, int prec) | |||||
496 | return QString::number(value, f, prec); |
|
496 | return QString::number(value, f, prec); | |
497 | } |
|
497 | } | |
498 |
|
498 | |||
|
499 | QString ChartPresenter::numberToString(int value) | |||
|
500 | { | |||
|
501 | if (m_localizeNumbers) | |||
|
502 | return m_locale.toString(value); | |||
|
503 | else | |||
|
504 | return QString::number(value); | |||
|
505 | } | |||
|
506 | ||||
499 | #include "moc_chartpresenter_p.cpp" |
|
507 | #include "moc_chartpresenter_p.cpp" | |
500 |
|
508 | |||
501 | QTCOMMERCIALCHART_END_NAMESPACE |
|
509 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -156,6 +156,7 public: | |||||
156 | inline static qreal textMargin() { return qreal(0.5); } |
|
156 | inline static qreal textMargin() { return qreal(0.5); } | |
157 |
|
157 | |||
158 | QString numberToString(double value, char f = 'g', int prec = 6); |
|
158 | QString numberToString(double value, char f = 'g', int prec = 6); | |
|
159 | QString numberToString(int value); | |||
159 |
|
160 | |||
160 | private: |
|
161 | private: | |
161 | void createBackgroundItem(); |
|
162 | void createBackgroundItem(); |
General Comments 0
You need to be logged in to leave comments.
Login now