@@ -225,6 +225,10 void AbstractBarChartItem::handleUpdatedBars() | |||
|
225 | 225 | QGraphicsTextItem *label = m_labels.at(itemIndex); |
|
226 | 226 | QString valueLabel; |
|
227 | 227 | if (presenter()) { // At startup presenter is not yet set, yet somehow update comes |
|
228 | if (barSet->value(category) == 0) { | |
|
229 | label->setVisible(false); | |
|
230 | } else { | |
|
231 | label->setVisible(true); | |
|
228 | 232 | if (m_series->labelsFormat().isEmpty()) { |
|
229 | 233 | valueLabel = presenter()->numberToString(barSet->value(category)); |
|
230 | 234 | } else { |
@@ -233,6 +237,7 void AbstractBarChartItem::handleUpdatedBars() | |||
|
233 | 237 | presenter()->numberToString(barSet->value(category))); |
|
234 | 238 | } |
|
235 | 239 | } |
|
240 | } | |
|
236 | 241 | label->setHtml(valueLabel); |
|
237 | 242 | label->setFont(barSet->m_labelFont); |
|
238 | 243 | label->setDefaultTextColor(barSet->m_labelBrush.color()); |
@@ -116,6 +116,10 void HorizontalPercentBarChartItem::handleUpdatedBars() | |||
|
116 | 116 | qreal p = m_series->d_func()->percentageAt(set, category) * 100.0; |
|
117 | 117 | QString vString(presenter()->numberToString(p, 'f', 0)); |
|
118 | 118 | QString valueLabel; |
|
119 | if (p == 0) { | |
|
120 | label->setVisible(false); | |
|
121 | } else { | |
|
122 | label->setVisible(true); | |
|
119 | 123 | if (m_series->labelsFormat().isEmpty()) { |
|
120 | 124 | vString.append(QStringLiteral("%")); |
|
121 | 125 | valueLabel = vString; |
@@ -123,6 +127,7 void HorizontalPercentBarChartItem::handleUpdatedBars() | |||
|
123 | 127 | valueLabel = m_series->labelsFormat(); |
|
124 | 128 | valueLabel.replace(valueTag, vString); |
|
125 | 129 | } |
|
130 | } | |
|
126 | 131 | label->setHtml(valueLabel); |
|
127 | 132 | label->setFont(barSet->m_labelFont); |
|
128 | 133 | label->setDefaultTextColor(barSet->m_labelBrush.color()); |
@@ -32,6 +32,7 QT_CHARTS_BEGIN_NAMESPACE | |||
|
32 | 32 | First value of set is assumed to belong to first category, second to second category and so on. |
|
33 | 33 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
34 | 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 | 37 | \sa QAbstractBarSeries, QBarSeries, QStackedBarSeries, QPercentBarSeries |
|
37 | 38 | */ |
@@ -46,6 +47,7 QT_CHARTS_BEGIN_NAMESPACE | |||
|
46 | 47 | First value of set is assumed to belong to first category, second to second category and so on. |
|
47 | 48 | If set has fewer values than there are categories, then the missing values are assumed to be |
|
48 | 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 | 51 | \sa AbstractBarSeries, BarSeries, StackedBarSeries, PercentBarSeries |
|
50 | 52 | */ |
|
51 | 53 |
@@ -121,6 +121,10 void PercentBarChartItem::handleUpdatedBars() | |||
|
121 | 121 | qreal p = m_series->d_func()->percentageAt(set, category) * 100.0; |
|
122 | 122 | QString vString(presenter()->numberToString(p, 'f', 0)); |
|
123 | 123 | QString valueLabel; |
|
124 | if (p == 0) { | |
|
125 | label->setVisible(false); | |
|
126 | } else { | |
|
127 | label->setVisible(true); | |
|
124 | 128 | if (m_series->labelsFormat().isEmpty()) { |
|
125 | 129 | vString.append(QStringLiteral("%")); |
|
126 | 130 | valueLabel = vString; |
@@ -128,6 +132,7 void PercentBarChartItem::handleUpdatedBars() | |||
|
128 | 132 | valueLabel = m_series->labelsFormat(); |
|
129 | 133 | valueLabel.replace(valueTag, vString); |
|
130 | 134 | } |
|
135 | } | |
|
131 | 136 | label->setHtml(valueLabel); |
|
132 | 137 | label->setFont(barSet->m_labelFont); |
|
133 | 138 | label->setDefaultTextColor(barSet->m_labelBrush.color()); |
General Comments 0
You need to be logged in to leave comments.
Login now