##// END OF EJS Templates
fix in barmargin calculations
sauimone -
r1285:d4fb39594637
parent child
Show More
@@ -47,7 +47,7 QVector<QRectF> PercentBarChartItem::calculateLayout()
47 qreal scaleY = (height / rangeY);
47 qreal scaleY = (height / rangeY);
48 qreal scaleX = (width / rangeX);
48 qreal scaleX = (width / rangeX);
49 qreal categoryWidth = width / categoryCount;
49 qreal categoryWidth = width / categoryCount;
50 qreal barWidth = categoryWidth / setCount - categoryWidth * m_series->d_func()->barMargin();
50 qreal barWidth = categoryWidth - categoryWidth * m_series->d_func()->barMargin();
51
51
52 int itemIndex(0);
52 int itemIndex(0);
53 for (int category = 0; category < categoryCount; category++) {
53 for (int category = 0; category < categoryCount; category++) {
@@ -231,7 +231,7 bool QBarSeries::isLabelsVisible() const
231
231
232 QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) :
232 QBarSeriesPrivate::QBarSeriesPrivate(QBarSeries *q) :
233 QAbstractSeriesPrivate(q),
233 QAbstractSeriesPrivate(q),
234 m_barMargin(0.05), // Default value is 5% of category width
234 m_barMargin(0.5), // Default value is 50% of category width
235 m_labelsVisible(false),
235 m_labelsVisible(false),
236 m_visible(true)
236 m_visible(true)
237 {
237 {
@@ -46,12 +46,12 QVector<QRectF> StackedBarChartItem::calculateLayout()
46 qreal scaleY = (height / rangeY);
46 qreal scaleY = (height / rangeY);
47 qreal scaleX = (width / rangeX);
47 qreal scaleX = (width / rangeX);
48 qreal categoryWidth = width / categoryCount;
48 qreal categoryWidth = width / categoryCount;
49 qreal barWidth = categoryWidth / setCount - categoryWidth * m_series->d_func()->barMargin();
49 qreal barWidth = categoryWidth - categoryWidth * m_series->d_func()->barMargin();
50
50
51 int itemIndex(0);
51 int itemIndex(0);
52 for (int category = 0; category < categoryCount; category++) {
52 for (int category = 0; category < categoryCount; category++) {
53 qreal yPos = height + rangeY * m_domainMinY + geometry().topLeft().y();
53 qreal yPos = height + rangeY * m_domainMinY + geometry().topLeft().y();
54 for (int set=0; set < m_series->barsetCount(); set++) {
54 for (int set=0; set < setCount; set++) {
55 QBarSet* barSet = m_series->d_func()->barsetAt(set);
55 QBarSet* barSet = m_series->d_func()->barsetAt(set);
56
56
57 qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2;
57 qreal xPos = (barSet->at(category).x() - m_domainMinX) * scaleX + m_rect.left() - barWidth/2;
General Comments 0
You need to be logged in to leave comments. Login now