@@ -60,7 +60,7 void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti | |||
|
60 | 60 | |
|
61 | 61 | QRectF BarChartItem::boundingRect() const |
|
62 | 62 | { |
|
63 | return m_rect.translated(-m_rect.topLeft()); | |
|
63 | return m_rect; | |
|
64 | 64 | } |
|
65 | 65 | |
|
66 | 66 | void BarChartItem::dataChanged() |
@@ -117,8 +117,8 QVector<QRectF> BarChartItem::calculateLayout() | |||
|
117 | 117 | |
|
118 | 118 | int itemIndex(0); |
|
119 | 119 | for (int category = 0; category < categoryCount; category++) { |
|
120 | qreal xPos = categoryWidth * category + barWidth / 2; | |
|
121 | qreal yPos = height + scale * m_domainMinY; | |
|
120 | qreal xPos = categoryWidth * category + barWidth / 2 + geometry().topLeft().x(); | |
|
121 | qreal yPos = height + scale * m_domainMinY + geometry().topLeft().y(); | |
|
122 | 122 | for (int set = 0; set < setCount; set++) { |
|
123 | 123 | QBarSet* barSet = m_series->d_func()->barsetAt(set); |
|
124 | 124 | |
@@ -185,11 +185,9 void BarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal | |||
|
185 | 185 | void BarChartItem::handleGeometryChanged(const QRectF &rect) |
|
186 | 186 | { |
|
187 | 187 | prepareGeometryChange(); |
|
188 | m_clipRect = rect.translated(-rect.topLeft()); | |
|
189 | 188 | m_rect = rect; |
|
190 | 189 | handleLayoutChanged(); |
|
191 | 190 | m_layoutSet = true; |
|
192 | setPos(rect.topLeft()); | |
|
193 | 191 | } |
|
194 | 192 | |
|
195 | 193 | void BarChartItem::handleLayoutChanged() |
@@ -72,7 +72,6 protected: | |||
|
72 | 72 | qreal m_domainMaxY; |
|
73 | 73 | |
|
74 | 74 | QRectF m_rect; |
|
75 | QRectF m_clipRect; | |
|
76 | 75 | bool m_layoutSet; // True, if component has been laid out. |
|
77 | 76 | QVector<QRectF> m_layout; |
|
78 | 77 |
@@ -43,7 +43,7 QVector<QRectF> PercentBarChartItem::calculateLayout() | |||
|
43 | 43 | qreal categoryCount = m_series->categoryCount(); |
|
44 | 44 | qreal barWidth = width / (m_series->categoryCount() * 2); |
|
45 | 45 | qreal xStep = width / categoryCount; |
|
46 | qreal xPos = xStep / 2 - barWidth / 2; | |
|
46 | qreal xPos = xStep / 2 - barWidth / 2 + geometry().topLeft().x(); | |
|
47 | 47 | |
|
48 | 48 | qreal range = m_domainMaxY - m_domainMinY; |
|
49 | 49 | qreal domainScale = (height / range); |
@@ -52,7 +52,7 QVector<QRectF> PercentBarChartItem::calculateLayout() | |||
|
52 | 52 | for (int category = 0; category < categoryCount; category++) { |
|
53 | 53 | qreal colSum = m_series->d_func()->categorySum(category); |
|
54 | 54 | qreal percentage = (100 / colSum); |
|
55 | qreal yPos = height + domainScale * m_domainMinY; | |
|
55 | qreal yPos = height + domainScale * m_domainMinY + geometry().topLeft().y(); | |
|
56 | 56 | for (int set=0; set < m_series->barsetCount(); set++) { |
|
57 | 57 | QBarSet* barSet = m_series->d_func()->barsetAt(set); |
|
58 | 58 | qreal barHeight = barSet->valueAt(category) * percentage * domainScale; |
@@ -45,11 +45,11 QVector<QRectF> StackedBarChartItem::calculateLayout() | |||
|
45 | 45 | qreal categotyCount = m_series->categoryCount(); |
|
46 | 46 | qreal barWidth = width / (categotyCount * 2); |
|
47 | 47 | qreal xStep = width / categotyCount; |
|
48 | qreal xPos = xStep / 2 - barWidth / 2; | |
|
48 | qreal xPos = xStep / 2 - barWidth / 2 + geometry().topLeft().x(); | |
|
49 | 49 | |
|
50 | 50 | int itemIndex(0); |
|
51 | 51 | for (int category = 0; category < categotyCount; category++) { |
|
52 | qreal yPos = height + scale * m_domainMinY; | |
|
52 | qreal yPos = height + scale * m_domainMinY + geometry().topLeft().y(); | |
|
53 | 53 | for (int set=0; set < m_series->barsetCount(); set++) { |
|
54 | 54 | QBarSet* barSet = m_series->d_func()->barsetAt(set); |
|
55 | 55 |
General Comments 0
You need to be logged in to leave comments.
Login now