diff --git a/src/barchart/barchartitem.cpp b/src/barchart/barchartitem.cpp index 9246b74..1131801 100644 --- a/src/barchart/barchartitem.cpp +++ b/src/barchart/barchartitem.cpp @@ -60,7 +60,7 @@ void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti QRectF BarChartItem::boundingRect() const { - return m_rect.translated(-m_rect.topLeft()); + return m_rect; } void BarChartItem::dataChanged() @@ -117,8 +117,8 @@ QVector BarChartItem::calculateLayout() int itemIndex(0); for (int category = 0; category < categoryCount; category++) { - qreal xPos = categoryWidth * category + barWidth / 2; - qreal yPos = height + scale * m_domainMinY; + qreal xPos = categoryWidth * category + barWidth / 2 + geometry().topLeft().x(); + qreal yPos = height + scale * m_domainMinY + geometry().topLeft().y(); for (int set = 0; set < setCount; set++) { QBarSet* barSet = m_series->d_func()->barsetAt(set); @@ -185,11 +185,9 @@ void BarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal void BarChartItem::handleGeometryChanged(const QRectF &rect) { prepareGeometryChange(); - m_clipRect = rect.translated(-rect.topLeft()); m_rect = rect; handleLayoutChanged(); m_layoutSet = true; - setPos(rect.topLeft()); } void BarChartItem::handleLayoutChanged() diff --git a/src/barchart/barchartitem_p.h b/src/barchart/barchartitem_p.h index 2dd7a8a..d720b3b 100644 --- a/src/barchart/barchartitem_p.h +++ b/src/barchart/barchartitem_p.h @@ -72,7 +72,6 @@ protected: qreal m_domainMaxY; QRectF m_rect; - QRectF m_clipRect; bool m_layoutSet; // True, if component has been laid out. QVector m_layout; diff --git a/src/barchart/percentbarchartitem.cpp b/src/barchart/percentbarchartitem.cpp index 9f30272..540adeb 100644 --- a/src/barchart/percentbarchartitem.cpp +++ b/src/barchart/percentbarchartitem.cpp @@ -43,7 +43,7 @@ QVector PercentBarChartItem::calculateLayout() qreal categoryCount = m_series->categoryCount(); qreal barWidth = width / (m_series->categoryCount() * 2); qreal xStep = width / categoryCount; - qreal xPos = xStep / 2 - barWidth / 2; + qreal xPos = xStep / 2 - barWidth / 2 + geometry().topLeft().x(); qreal range = m_domainMaxY - m_domainMinY; qreal domainScale = (height / range); @@ -52,7 +52,7 @@ QVector PercentBarChartItem::calculateLayout() for (int category = 0; category < categoryCount; category++) { qreal colSum = m_series->d_func()->categorySum(category); qreal percentage = (100 / colSum); - qreal yPos = height + domainScale * m_domainMinY; + qreal yPos = height + domainScale * m_domainMinY + geometry().topLeft().y(); for (int set=0; set < m_series->barsetCount(); set++) { QBarSet* barSet = m_series->d_func()->barsetAt(set); qreal barHeight = barSet->valueAt(category) * percentage * domainScale; diff --git a/src/barchart/stackedbarchartitem.cpp b/src/barchart/stackedbarchartitem.cpp index 4389f3a..7a5a345 100644 --- a/src/barchart/stackedbarchartitem.cpp +++ b/src/barchart/stackedbarchartitem.cpp @@ -45,11 +45,11 @@ QVector StackedBarChartItem::calculateLayout() qreal categotyCount = m_series->categoryCount(); qreal barWidth = width / (categotyCount * 2); qreal xStep = width / categotyCount; - qreal xPos = xStep / 2 - barWidth / 2; + qreal xPos = xStep / 2 - barWidth / 2 + geometry().topLeft().x(); int itemIndex(0); for (int category = 0; category < categotyCount; category++) { - qreal yPos = height + scale * m_domainMinY; + qreal yPos = height + scale * m_domainMinY + geometry().topLeft().y(); for (int set=0; set < m_series->barsetCount(); set++) { QBarSet* barSet = m_series->d_func()->barsetAt(set);