26 mCategoryBrush.setStyle( Qt::SolidPattern );
27 mPen.setStyle( Qt::SolidLine );
49 attrVal = expression->
evaluate( &expressionContext );
57 double value = fabs( attrVal.toDouble( &ok ) );
68 double painterUnitConversionScale =
c.convertToPainterUnits( 1, s.
sizeType );
71 mApplySpacingAdjust =
true;
78 const double totalBarLength = size.height() + spacing * std::max( 0, s.
categoryAttributes.size() - 1 );
79 size = QSizeF( s.
barWidth, totalBarLength );
86 const double totalBarLength = size.width() + spacing * std::max( 0, s.
categoryAttributes.size() - 1 );
87 size = QSizeF( totalBarLength, s.
barWidth );
95 size.setWidth( size.width() + 2 * maxBleed );
96 size.setHeight( size.height() + 2 * maxBleed );
114 return value * scaleFactor;
127 if ( attributes.isEmpty() )
135 double painterUnitConversionScale =
c.convertToPainterUnits( 1, s.
sizeType );
157 QPainter *p =
c.painter();
163 QList< QPair<double, QColor> > values;
164 QList< QPair<double, QColor> > negativeValues;
173 double negativeTotal = 0;
175 QList< QColor >::const_iterator colIt = s.
categoryColors.constBegin();
179 double currentVal = expression->
evaluate( &expressionContext ).toDouble();
180 total += fabs( currentVal );
181 if ( currentVal >= 0 )
183 values.push_back( qMakePair( currentVal, *colIt ) );
187 negativeTotal += currentVal;
188 negativeValues.push_back( qMakePair( -currentVal, *colIt ) );
197 double scaledMaxVal = 0;
210 if ( mApplySpacingAdjust )
211 scaledMaxVal -= totalSpacing;
213 double axisOffset = 0;
214 if ( !negativeValues.isEmpty() )
216 axisOffset = -negativeTotal / total * scaledMaxVal + ( negativeValues.size() - 1 ) * spacing;
220 double baseX = position.x();
221 double baseY = position.y();
236 while ( !negativeValues.isEmpty() )
238 values.push_front( negativeValues.takeLast() );
241 double currentOffset = 0;
242 QList< QPair<double, QColor> >::const_iterator valIt = values.constBegin();
243 for ( ; valIt != values.constEnd(); ++valIt )
245 double length = valIt->first / total * scaledMaxVal;
247 mCategoryBrush.setColor( valIt->second );
248 p->setBrush( mCategoryBrush );
253 p->drawRect( QRectF( baseX, baseY - currentOffset, scaledWidth, length * -1 ) );
257 p->drawRect( QRectF( baseX, baseY + currentOffset - scaledMaxVal - spacing * std::max( 0, values.size() - 1 ), scaledWidth, length ) );
261 p->drawRect( QRectF( baseX + currentOffset, baseY - scaledWidth, length, scaledWidth ) );
265 p->drawRect( QRectF( baseX + scaledMaxVal - currentOffset + spacing * std::max( 0, values.size() - 1 ), baseY - scaledWidth, 0 - length, scaledWidth ) );
269 currentOffset += length + spacing;
275 QPolygonF axisPoints;
279 axisPoints << QPointF( baseX, baseY - scaledMaxVal - spacing * std::max( 0, values.size() - 1 ) )
280 << QPointF( baseX, baseY - axisOffset )
281 << QPointF( baseX + scaledWidth, baseY - axisOffset );
285 axisPoints << QPointF( baseX, baseY )
286 << QPointF( baseX, baseY - scaledMaxVal - spacing * std::max( 0, values.size() - 1 ) + axisOffset )
287 << QPointF( baseX + scaledWidth, baseY - scaledMaxVal - spacing * std::max( 0, values.size() - 1 ) + axisOffset );
291 axisPoints << QPointF( baseX + scaledMaxVal + spacing * std::max( 0, values.size() - 1 ), baseY - scaledWidth )
292 << QPointF( baseX + axisOffset, baseY - scaledWidth )
293 << QPointF( baseX + axisOffset, baseY );
297 axisPoints << QPointF( baseX, baseY - scaledWidth )
298 << QPointF( baseX + scaledMaxVal + spacing * std::max( 0, values.size() - 1 ) - axisOffset, baseY - scaledWidth )
299 << QPointF( baseX + scaledMaxVal + spacing * std::max( 0, values.size() - 1 ) - axisOffset, baseY );