##// END OF EJS Templates
Fixed bar label visibility...
Titta Heikkala -
r2814:79dc9c599f41
parent child
Show More
@@ -225,12 +225,17 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 (m_series->labelsFormat().isEmpty()) {
229 valueLabel = presenter()->numberToString(barSet->value(category));
228 if (barSet->value(category) == 0) {
229 label->setVisible(false);
230 230 } else {
231 valueLabel = m_series->labelsFormat();
232 valueLabel.replace(valueTag,
231 label->setVisible(true);
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 237 presenter()->numberToString(barSet->value(category)));
238 }
234 239 }
235 240 }
236 241 label->setHtml(valueLabel);
@@ -116,12 +116,17 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 (m_series->labelsFormat().isEmpty()) {
120 vString.append(QStringLiteral("%"));
121 valueLabel = vString;
119 if (p == 0) {
120 label->setVisible(false);
122 121 } else {
123 valueLabel = m_series->labelsFormat();
124 valueLabel.replace(valueTag, vString);
122 label->setVisible(true);
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 131 label->setHtml(valueLabel);
127 132 label->setFont(barSet->m_labelFont);
@@ -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,12 +121,17 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 (m_series->labelsFormat().isEmpty()) {
125 vString.append(QStringLiteral("%"));
126 valueLabel = vString;
124 if (p == 0) {
125 label->setVisible(false);
127 126 } else {
128 valueLabel = m_series->labelsFormat();
129 valueLabel.replace(valueTag, vString);
127 label->setVisible(true);
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 136 label->setHtml(valueLabel);
132 137 label->setFont(barSet->m_labelFont);
General Comments 0
You need to be logged in to leave comments. Login now