From d4fb395946373e5d12eb81812bc9863806935ec2 2012-05-29 14:22:36 From: sauimone Date: 2012-05-29 14:22:36 Subject: [PATCH] fix in barmargin calculations --- diff --git a/src/barchart/percentbarchartitem.cpp b/src/barchart/percentbarchartitem.cpp index 7cf1154..552356a 100644 --- a/src/barchart/percentbarchartitem.cpp +++ b/src/barchart/percentbarchartitem.cpp @@ -47,7 +47,7 @@ QVector PercentBarChartItem::calculateLayout() qreal scaleY = (height / rangeY); qreal scaleX = (width / rangeX); qreal categoryWidth = width / categoryCount; - qreal barWidth = categoryWidth / setCount - categoryWidth * m_series->d_func()->barMargin(); + qreal barWidth = categoryWidth - categoryWidth * m_series->d_func()->barMargin(); int itemIndex(0); for (int category = 0; category < categoryCount; category++) { diff --git a/src/barchart/qbarseries.cpp b/src/barchart/qbarseries.cpp index 56ce1c6..9285ac0 100644 --- a/src/barchart/qbarseries.cpp +++ b/src/barchart/qbarseries.cpp @@ -231,7 +231,7 @@ bool QBarSeries::isLabelsVisible() const QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) : QAbstractSeriesPrivate(q), - m_barMargin(0.05), // Default value is 5% of category width + m_barMargin(0.5), // Default value is 50% of category width m_labelsVisible(false), m_visible(true) { diff --git a/src/barchart/stackedbarchartitem.cpp b/src/barchart/stackedbarchartitem.cpp index 604e0e8..83e547c 100644 --- a/src/barchart/stackedbarchartitem.cpp +++ b/src/barchart/stackedbarchartitem.cpp @@ -46,12 +46,12 @@ QVector StackedBarChartItem::calculateLayout() qreal scaleY = (height / rangeY); qreal scaleX = (width / rangeX); qreal categoryWidth = width / categoryCount; - qreal barWidth = categoryWidth / setCount - categoryWidth * m_series->d_func()->barMargin(); + qreal barWidth = categoryWidth - categoryWidth * m_series->d_func()->barMargin(); int itemIndex(0); for (int category = 0; category < categoryCount; category++) { qreal yPos = height + rangeY * m_domainMinY + geometry().topLeft().y(); - for (int set=0; set < m_series->barsetCount(); set++) { + for (int set=0; set < setCount; set++) { QBarSet* barSet = m_series->d_func()->barsetAt(set); qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2;