##// END OF EJS Templates
Fixed bar label visibility...
Titta Heikkala -
r2814:79dc9c599f41
parent child
Show More
@@ -225,12 +225,17 void AbstractBarChartItem::handleUpdatedBars()
225 QGraphicsTextItem *label = m_labels.at(itemIndex);
225 QGraphicsTextItem *label = m_labels.at(itemIndex);
226 QString valueLabel;
226 QString valueLabel;
227 if (presenter()) { // At startup presenter is not yet set, yet somehow update comes
227 if (presenter()) { // At startup presenter is not yet set, yet somehow update comes
228 if (m_series->labelsFormat().isEmpty()) {
228 if (barSet->value(category) == 0) {
229 valueLabel = presenter()->numberToString(barSet->value(category));
229 label->setVisible(false);
230 } else {
230 } else {
231 valueLabel = m_series->labelsFormat();
231 label->setVisible(true);
232 valueLabel.replace(valueTag,
232 if (m_series->labelsFormat().isEmpty()) {
233 valueLabel = presenter()->numberToString(barSet->value(category));
234 } else {
235 valueLabel = m_series->labelsFormat();
236 valueLabel.replace(valueTag,
233 presenter()->numberToString(barSet->value(category)));
237 presenter()->numberToString(barSet->value(category)));
238 }
234 }
239 }
235 }
240 }
236 label->setHtml(valueLabel);
241 label->setHtml(valueLabel);
@@ -116,12 +116,17 void HorizontalPercentBarChartItem::handleUpdatedBars()
116 qreal p = m_series->d_func()->percentageAt(set, category) * 100.0;
116 qreal p = m_series->d_func()->percentageAt(set, category) * 100.0;
117 QString vString(presenter()->numberToString(p, 'f', 0));
117 QString vString(presenter()->numberToString(p, 'f', 0));
118 QString valueLabel;
118 QString valueLabel;
119 if (m_series->labelsFormat().isEmpty()) {
119 if (p == 0) {
120 vString.append(QStringLiteral("%"));
120 label->setVisible(false);
121 valueLabel = vString;
122 } else {
121 } else {
123 valueLabel = m_series->labelsFormat();
122 label->setVisible(true);
124 valueLabel.replace(valueTag, vString);
123 if (m_series->labelsFormat().isEmpty()) {
124 vString.append(QStringLiteral("%"));
125 valueLabel = vString;
126 } else {
127 valueLabel = m_series->labelsFormat();
128 valueLabel.replace(valueTag, vString);
129 }
125 }
130 }
126 label->setHtml(valueLabel);
131 label->setHtml(valueLabel);
127 label->setFont(barSet->m_labelFont);
132 label->setFont(barSet->m_labelFont);
@@ -32,6 +32,7 QT_CHARTS_BEGIN_NAMESPACE
32 First value of set is assumed to belong to first category, second to second category and so on.
32 First value of set is assumed to belong to first category, second to second category and so on.
33 If set has fewer values than there are categories, then the missing values are assumed to be
33 If set has fewer values than there are categories, then the missing values are assumed to be
34 at the end of set. For missing values in middle of a set, numerical value of zero is used.
34 at the end of set. For missing values in middle of a set, numerical value of zero is used.
35 Labels for zero value sets are not shown.
35
36
36 \sa QAbstractBarSeries, QBarSeries, QStackedBarSeries, QPercentBarSeries
37 \sa QAbstractBarSeries, QBarSeries, QStackedBarSeries, QPercentBarSeries
37 */
38 */
@@ -46,6 +47,7 QT_CHARTS_BEGIN_NAMESPACE
46 First value of set is assumed to belong to first category, second to second category and so on.
47 First value of set is assumed to belong to first category, second to second category and so on.
47 If set has fewer values than there are categories, then the missing values are assumed to be
48 If set has fewer values than there are categories, then the missing values are assumed to be
48 at the end of set. For missing values in middle of a set, numerical value of zero is used.
49 at the end of set. For missing values in middle of a set, numerical value of zero is used.
50 Labels for zero value sets are not shown.
49 \sa AbstractBarSeries, BarSeries, StackedBarSeries, PercentBarSeries
51 \sa AbstractBarSeries, BarSeries, StackedBarSeries, PercentBarSeries
50 */
52 */
51
53
@@ -121,12 +121,17 void PercentBarChartItem::handleUpdatedBars()
121 qreal p = m_series->d_func()->percentageAt(set, category) * 100.0;
121 qreal p = m_series->d_func()->percentageAt(set, category) * 100.0;
122 QString vString(presenter()->numberToString(p, 'f', 0));
122 QString vString(presenter()->numberToString(p, 'f', 0));
123 QString valueLabel;
123 QString valueLabel;
124 if (m_series->labelsFormat().isEmpty()) {
124 if (p == 0) {
125 vString.append(QStringLiteral("%"));
125 label->setVisible(false);
126 valueLabel = vString;
127 } else {
126 } else {
128 valueLabel = m_series->labelsFormat();
127 label->setVisible(true);
129 valueLabel.replace(valueTag, vString);
128 if (m_series->labelsFormat().isEmpty()) {
129 vString.append(QStringLiteral("%"));
130 valueLabel = vString;
131 } else {
132 valueLabel = m_series->labelsFormat();
133 valueLabel.replace(valueTag, vString);
134 }
130 }
135 }
131 label->setHtml(valueLabel);
136 label->setHtml(valueLabel);
132 label->setFont(barSet->m_labelFont);
137 label->setFont(barSet->m_labelFont);
General Comments 0
You need to be logged in to leave comments. Login now