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