From 1b872afb5c9f823ce1f3da8655bf98812fc23435 2012-01-26 13:25:48 From: sauimone Date: 2012-01-26 13:25:48 Subject: [PATCH] drawing fix for bar chart --- diff --git a/src/barchart/bar.cpp b/src/barchart/bar.cpp index a57356a..7aa29e5 100644 --- a/src/barchart/bar.cpp +++ b/src/barchart/bar.cpp @@ -42,6 +42,7 @@ void Bar::setPos(qreal x, qreal y) void Bar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { if (0 == mHeight) { + // Nothing to draw return; } // Set color for bar. TODO: gradients, textures etc @@ -51,10 +52,8 @@ void Bar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidg painter->setPen(pen); // Draw bar - // TODO: Pen width affects bar height for now. This should be rect -// painter->drawRect(mXpos,mYpos,mWidth,mHeight); - painter->drawLine(mXpos, mYpos + mHeight - mWidth, - mXpos, mYpos + mWidth); + painter->drawLine(mXpos, mYpos , + mXpos, mYpos - mHeight); } QRectF Bar::boundingRect() const diff --git a/src/barchart/bargroup.cpp b/src/barchart/bargroup.cpp index d1e5182..3821a7c 100644 --- a/src/barchart/bargroup.cpp +++ b/src/barchart/bargroup.cpp @@ -128,7 +128,8 @@ void BarGroup::layoutChanged() bar->setColor(mColors.at(series)); // TODO: bar width shouldn't affect height. Currently it does because pen width also affects height. (QPainter thingy...) - bar->setPos(item*posStep+startPos + series * mBarDefaultWidth, mHeight - barHeight + mBarDefaultWidth); +// bar->setPos(item*posStep+startPos + series * mBarDefaultWidth, mHeight - barHeight); + bar->setPos(item*posStep+startPos + series * mBarDefaultWidth, mHeight); itemIndex++; } }