@@ -84,8 +84,8 QVector<QRectF> BarChartItem::calculateLayout() | |||||
84 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); |
|
84 | qreal yPos = height + scaleY * m_domainMinY + geometry().topLeft().y(); | |
85 | for (int set = 0; set < setCount; set++) { |
|
85 | for (int set = 0; set < setCount; set++) { | |
86 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); |
|
86 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); | |
87 |
qreal xPos = (barSet-> |
|
87 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; | |
88 |
qreal barHeight = barSet-> |
|
88 | qreal barHeight = barSet->at(category).y() * scaleY; | |
89 |
|
89 | |||
90 | Bar* bar = m_bars.at(itemIndex); |
|
90 | Bar* bar = m_bars.at(itemIndex); | |
91 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); |
|
91 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); | |
@@ -93,12 +93,16 QVector<QRectF> BarChartItem::calculateLayout() | |||||
93 | layout.append(rect); |
|
93 | layout.append(rect); | |
94 | bar->setPen(barSet->m_pen); |
|
94 | bar->setPen(barSet->m_pen); | |
95 | bar->setBrush(barSet->m_brush); |
|
95 | bar->setBrush(barSet->m_brush); | |
96 | bar->setVisible(barsVisible); |
|
96 | if (qFuzzyIsNull(barHeight)) { | |
|
97 | bar->setVisible(false); | |||
|
98 | } else { | |||
|
99 | bar->setVisible(barsVisible); | |||
|
100 | } | |||
97 |
|
101 | |||
98 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
102 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
99 |
|
103 | |||
100 |
if (!qFuzzyIsNull(barSet-> |
|
104 | if (!qFuzzyIsNull(barSet->at(category).y())) { | |
101 |
label->setText(QString::number(barSet-> |
|
105 | label->setText(QString::number(barSet->at(category).y())); | |
102 | } else { |
|
106 | } else { | |
103 | label->setText(QString("")); |
|
107 | label->setText(QString("")); | |
104 | } |
|
108 | } |
@@ -56,22 +56,26 QVector<QRectF> GroupedBarChartItem::calculateLayout() | |||||
56 | for (int set = 0; set < setCount; set++) { |
|
56 | for (int set = 0; set < setCount; set++) { | |
57 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); |
|
57 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); | |
58 |
|
58 | |||
59 |
qreal xPos = (barSet-> |
|
59 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left(); | |
60 | xPos -= setCount*barWidth/2; |
|
60 | xPos -= setCount*barWidth/2; | |
61 | xPos += set*barWidth; |
|
61 | xPos += set*barWidth; | |
62 |
qreal barHeight = barSet-> |
|
62 | qreal barHeight = barSet->at(category).y() * scaleY; | |
63 | Bar* bar = m_bars.at(itemIndex); |
|
63 | Bar* bar = m_bars.at(itemIndex); | |
64 |
|
64 | |||
65 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); |
|
65 | QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); | |
66 | layout.append(rect); |
|
66 | layout.append(rect); | |
67 | bar->setPen(barSet->m_pen); |
|
67 | bar->setPen(barSet->m_pen); | |
68 | bar->setBrush(barSet->m_brush); |
|
68 | bar->setBrush(barSet->m_brush); | |
69 | bar->setVisible(barsVisible); |
|
69 | if (qFuzzyIsNull(barHeight)) { | |
|
70 | bar->setVisible(false); | |||
|
71 | } else { | |||
|
72 | bar->setVisible(barsVisible); | |||
|
73 | } | |||
70 |
|
74 | |||
71 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
75 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
72 |
|
76 | |||
73 |
if (!qFuzzyIsNull(barSet-> |
|
77 | if (!qFuzzyIsNull(barSet->at(category).y())) { | |
74 |
label->setText(QString::number(barSet-> |
|
78 | label->setText(QString::number(barSet->at(category).y())); | |
75 | } else { |
|
79 | } else { | |
76 | label->setText(QString("")); |
|
80 | label->setText(QString("")); | |
77 | } |
|
81 | } |
@@ -58,13 +58,17 QVector<QRectF> PercentBarChartItem::calculateLayout() | |||||
58 | for (int set=0; set < setCount; set++) { |
|
58 | for (int set=0; set < setCount; set++) { | |
59 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); |
|
59 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); | |
60 |
|
60 | |||
61 |
qreal xPos = (barSet-> |
|
61 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; | |
62 |
|
62 | |||
63 |
qreal barHeight = barSet-> |
|
63 | qreal barHeight = barSet->at(category).y() * percentage * scaleY; | |
64 | Bar* bar = m_bars.at(itemIndex); |
|
64 | Bar* bar = m_bars.at(itemIndex); | |
65 | bar->setPen(barSet->m_pen); |
|
65 | bar->setPen(barSet->m_pen); | |
66 | bar->setBrush(barSet->m_brush); |
|
66 | bar->setBrush(barSet->m_brush); | |
67 | bar->setVisible(barsVisible); |
|
67 | if (qFuzzyIsNull(barHeight)) { | |
|
68 | bar->setVisible(false); | |||
|
69 | } else { | |||
|
70 | bar->setVisible(barsVisible); | |||
|
71 | } | |||
68 |
|
72 | |||
69 | QRectF rect(xPos, yPos-barHeight, barWidth, barHeight); |
|
73 | QRectF rect(xPos, yPos-barHeight, barWidth, barHeight); | |
70 | layout.append(rect); |
|
74 | layout.append(rect); |
@@ -611,6 +611,16 void QBarSetPrivate::replace(const int index, const QPointF value) | |||||
611 | emit updatedBars(); |
|
611 | emit updatedBars(); | |
612 | } |
|
612 | } | |
613 |
|
613 | |||
|
614 | QPointF QBarSetPrivate::at(const int index) | |||
|
615 | { | |||
|
616 | if (index < 0 || index >= m_values.count()) { | |||
|
617 | return QPointF(0,0); | |||
|
618 | } | |||
|
619 | ||||
|
620 | return m_values.at(index); | |||
|
621 | } | |||
|
622 | ||||
|
623 | ||||
614 | #include "moc_qbarset.cpp" |
|
624 | #include "moc_qbarset.cpp" | |
615 | #include "moc_qbarset_p.cpp" |
|
625 | #include "moc_qbarset_p.cpp" | |
616 |
|
626 |
@@ -57,6 +57,8 public: | |||||
57 | void replace(const int index, const qreal value); |
|
57 | void replace(const int index, const qreal value); | |
58 | void replace(const int index, const QPointF value); |
|
58 | void replace(const int index, const QPointF value); | |
59 |
|
59 | |||
|
60 | QPointF at(const int index); | |||
|
61 | ||||
60 | Q_SIGNALS: |
|
62 | Q_SIGNALS: | |
61 | void restructuredBars(); |
|
63 | void restructuredBars(); | |
62 | void updatedBars(); |
|
64 | void updatedBars(); |
@@ -55,21 +55,25 QVector<QRectF> StackedBarChartItem::calculateLayout() | |||||
55 | for (int set=0; set < setCount; set++) { |
|
55 | for (int set=0; set < setCount; set++) { | |
56 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); |
|
56 | QBarSetPrivate* barSet = m_series->d_func()->barsetAt(set)->d_ptr.data(); | |
57 |
|
57 | |||
58 |
qreal xPos = (barSet-> |
|
58 | qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2; | |
59 |
|
59 | |||
60 |
qreal barHeight = barSet-> |
|
60 | qreal barHeight = barSet->at(category).y() * scaleY; | |
61 | Bar* bar = m_bars.at(itemIndex); |
|
61 | Bar* bar = m_bars.at(itemIndex); | |
62 | bar->setPen(barSet->m_pen); |
|
62 | bar->setPen(barSet->m_pen); | |
63 | bar->setBrush(barSet->m_brush); |
|
63 | bar->setBrush(barSet->m_brush); | |
64 | bar->setVisible(barsVisible); |
|
64 | if (qFuzzyIsNull(barHeight)) { | |
|
65 | bar->setVisible(false); | |||
|
66 | } else { | |||
|
67 | bar->setVisible(barsVisible); | |||
|
68 | } | |||
65 |
|
69 | |||
66 | QRectF rect(xPos, yPos-barHeight, barWidth, barHeight); |
|
70 | QRectF rect(xPos, yPos-barHeight, barWidth, barHeight); | |
67 | layout.append(rect); |
|
71 | layout.append(rect); | |
68 |
|
72 | |||
69 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); |
|
73 | QGraphicsSimpleTextItem* label = m_labels.at(itemIndex); | |
70 |
|
74 | |||
71 |
if (!qFuzzyIsNull(barSet-> |
|
75 | if (!qFuzzyIsNull(barSet->at(category).y())) { | |
72 |
label->setText(QString::number(barSet-> |
|
76 | label->setText(QString::number(barSet->at(category).y())); | |
73 | } else { |
|
77 | } else { | |
74 | label->setText(QString("")); |
|
78 | label->setText(QString("")); | |
75 | } |
|
79 | } |
General Comments 0
You need to be logged in to leave comments.
Login now