From 2c12358822ee7acac5d91a98457807eab5248778 2012-03-21 08:50:46 From: sauimone Date: 2012-03-21 08:50:46 Subject: [PATCH] barchart domain fix --- diff --git a/src/barchart/barchartitem.cpp b/src/barchart/barchartitem.cpp index d7406fc..ab37334 100644 --- a/src/barchart/barchartitem.cpp +++ b/src/barchart/barchartitem.cpp @@ -110,6 +110,12 @@ void BarChartItem::layoutChanged() qreal tW = mWidth; qreal tH = mHeight; qreal tM = mSeries->max(); + + // Domain: + if (mDomainMaxY > tM) { + tM = mDomainMaxY; + } + qreal scale = (tH/tM); qreal tC = categoryCount + 1; qreal categoryWidth = tW/tC; @@ -222,11 +228,11 @@ void BarChartItem::handleModelChanged(int index) void BarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY) { - // TODO: - Q_UNUSED(minX) - Q_UNUSED(maxX) - Q_UNUSED(minY) - Q_UNUSED(maxY) + mDomainMinX = minX; + mDomainMaxX = maxX; + mDomainMinY = minY; + mDomainMaxY = maxY; + layoutChanged(); /* int count = mSeries->categoryCount(); diff --git a/src/barchart/barchartitem_p.h b/src/barchart/barchartitem_p.h index 59bcb60..61568f9 100644 --- a/src/barchart/barchartitem_p.h +++ b/src/barchart/barchartitem_p.h @@ -57,6 +57,11 @@ protected: int mWidth; qreal mBarWidth; + qreal mDomainMinX; + qreal mDomainMaxX; + qreal mDomainMinY; + qreal mDomainMaxY; + bool mLayoutSet; // True, if component has been laid out. // Not owned. diff --git a/src/barchart/stackedbarchartitem.cpp b/src/barchart/stackedbarchartitem.cpp index 986f240..7bac8ee 100644 --- a/src/barchart/stackedbarchartitem.cpp +++ b/src/barchart/stackedbarchartitem.cpp @@ -39,6 +39,11 @@ void StackedBarChartItem::layoutChanged() // Use temporary qreals for accurancy (we might get some compiler warnings... :) qreal maxSum = mSeries->maxCategorySum(); + // Domain: + if (mDomainMaxY > maxSum) { + maxSum = mDomainMaxY; + } + qreal h = mHeight; qreal scale = (h / maxSum); qreal tW = mWidth;