@@ -196,25 +196,27 void AbstractBarChartItem::handleOpacityChanged() | |||||
196 |
|
196 | |||
197 | void AbstractBarChartItem::handleUpdatedBars() |
|
197 | void AbstractBarChartItem::handleUpdatedBars() | |
198 | { |
|
198 | { | |
199 | // Handle changes in pen, brush, labels etc. |
|
199 | if (!m_series->d_func()->blockBarUpdate()) { | |
200 | int categoryCount = m_series->d_func()->categoryCount(); |
|
200 | // Handle changes in pen, brush, labels etc. | |
201 |
int |
|
201 | int categoryCount = m_series->d_func()->categoryCount(); | |
202 | int itemIndex(0); |
|
202 | int setCount = m_series->count(); | |
203 |
|
203 | int itemIndex(0); | ||
204 | for (int category = 0; category < categoryCount; category++) { |
|
204 | ||
205 |
for (int |
|
205 | for (int category = 0; category < categoryCount; category++) { | |
206 | QBarSetPrivate *barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); |
|
206 | for (int set = 0; set < setCount; set++) { | |
207 | Bar *bar = m_bars.at(itemIndex); |
|
207 | QBarSetPrivate *barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); | |
208 | bar->setPen(barSet->m_pen); |
|
208 | Bar *bar = m_bars.at(itemIndex); | |
209 |
bar->set |
|
209 | bar->setPen(barSet->m_pen); | |
210 |
bar-> |
|
210 | bar->setBrush(barSet->m_brush); | |
211 |
|
211 | bar->update(); | ||
212 | QGraphicsTextItem *label = m_labels.at(itemIndex); |
|
212 | ||
213 | label->setHtml(QString("%1").arg(barSet->value(category))); |
|
213 | QGraphicsTextItem *label = m_labels.at(itemIndex); | |
214 |
label->set |
|
214 | label->setHtml(QString("%1").arg(barSet->value(category))); | |
215 |
label->set |
|
215 | label->setFont(barSet->m_labelFont); | |
216 | label->update(); |
|
216 | label->setDefaultTextColor(barSet->m_labelBrush.color()); | |
217 | itemIndex++; |
|
217 | label->update(); | |
|
218 | itemIndex++; | |||
|
219 | } | |||
218 | } |
|
220 | } | |
219 | } |
|
221 | } | |
220 | } |
|
222 | } |
@@ -413,7 +413,8 QAbstractBarSeriesPrivate::QAbstractBarSeriesPrivate(QAbstractBarSeries *q) : | |||||
413 | QAbstractSeriesPrivate(q), |
|
413 | QAbstractSeriesPrivate(q), | |
414 | m_barWidth(0.5), // Default value is 50% of category width |
|
414 | m_barWidth(0.5), // Default value is 50% of category width | |
415 | m_labelsVisible(false), |
|
415 | m_labelsVisible(false), | |
416 | m_visible(true) |
|
416 | m_visible(true), | |
|
417 | m_blockBarUpdate(false) | |||
417 | { |
|
418 | { | |
418 | } |
|
419 | } | |
419 |
|
420 | |||
@@ -652,6 +653,10 qreal QAbstractBarSeriesPrivate::bottom() | |||||
652 | return bottom; |
|
653 | return bottom; | |
653 | } |
|
654 | } | |
654 |
|
655 | |||
|
656 | bool QAbstractBarSeriesPrivate::blockBarUpdate() | |||
|
657 | { | |||
|
658 | return m_blockBarUpdate; | |||
|
659 | } | |||
655 |
|
660 | |||
656 | void QAbstractBarSeriesPrivate::initializeDomain() |
|
661 | void QAbstractBarSeriesPrivate::initializeDomain() | |
657 | { |
|
662 | { | |
@@ -843,6 +848,8 QAbstractAxis* QAbstractBarSeriesPrivate::createDefaultAxis(Qt::Orientation orie | |||||
843 |
|
848 | |||
844 | void QAbstractBarSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) |
|
849 | void QAbstractBarSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced) | |
845 | { |
|
850 | { | |
|
851 | m_blockBarUpdate = true; // Ensures that the bars are not updated before the theme is ready | |||
|
852 | ||||
846 | const QList<QGradient> gradients = theme->seriesGradients(); |
|
853 | const QList<QGradient> gradients = theme->seriesGradients(); | |
847 |
|
854 | |||
848 | qreal takeAtPos = 0.5; |
|
855 | qreal takeAtPos = 0.5; | |
@@ -875,12 +882,13 void QAbstractBarSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bo | |||||
875 | else |
|
882 | else | |
876 | m_barSets.at(i)->setLabelBrush(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0)); |
|
883 | m_barSets.at(i)->setLabelBrush(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0)); | |
877 | } |
|
884 | } | |
878 |
|
||||
879 | if (forced || QChartPrivate::defaultPen() == m_barSets.at(i)->d_ptr->m_pen) { |
|
885 | if (forced || QChartPrivate::defaultPen() == m_barSets.at(i)->d_ptr->m_pen) { | |
880 | QColor c = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0); |
|
886 | QColor c = ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0); | |
881 | m_barSets.at(i)->setPen(c); |
|
887 | m_barSets.at(i)->setPen(c); | |
882 | } |
|
888 | } | |
883 | } |
|
889 | } | |
|
890 | m_blockBarUpdate = false; | |||
|
891 | emit updatedBars(); | |||
884 | } |
|
892 | } | |
885 |
|
893 | |||
886 | void QAbstractBarSeriesPrivate::initializeAnimations(QChart::AnimationOptions options) |
|
894 | void QAbstractBarSeriesPrivate::initializeAnimations(QChart::AnimationOptions options) |
@@ -85,6 +85,8 public: | |||||
85 | qreal top(); |
|
85 | qreal top(); | |
86 | qreal bottom(); |
|
86 | qreal bottom(); | |
87 |
|
87 | |||
|
88 | bool blockBarUpdate(); | |||
|
89 | ||||
88 | Q_SIGNALS: |
|
90 | Q_SIGNALS: | |
89 | void clicked(int index, QBarSet *barset); |
|
91 | void clicked(int index, QBarSet *barset); | |
90 | void updatedBars(); |
|
92 | void updatedBars(); | |
@@ -101,6 +103,7 protected: | |||||
101 | qreal m_barWidth; |
|
103 | qreal m_barWidth; | |
102 | bool m_labelsVisible; |
|
104 | bool m_labelsVisible; | |
103 | bool m_visible; |
|
105 | bool m_visible; | |
|
106 | bool m_blockBarUpdate; | |||
104 |
|
107 | |||
105 | private: |
|
108 | private: | |
106 | Q_DECLARE_PUBLIC(QAbstractBarSeries) |
|
109 | Q_DECLARE_PUBLIC(QAbstractBarSeries) |
General Comments 0
You need to be logged in to leave comments.
Login now