Skip to content
Permalink
Browse files

Fixed scale factor for histogram diagrams.

  • Loading branch information
m-kuhn committed Aug 15, 2012
1 parent f22d23e commit ef3a086a95cdbbd1232d23da7a29d65319c53340
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/core/diagram/qgshistogramdiagram.cpp
@@ -31,6 +31,7 @@ QgsHistogramDiagram::~QgsHistogramDiagram()

QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is )
{
Q_UNUSED( c );
QgsAttributeMap::const_iterator attIt = attributes.constBegin();
if ( attIt == attributes.constEnd() )
{
@@ -50,16 +51,16 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributeMap& attributes, cons
maxValue = s.minimumSize;
}

mScaleFactor = ( maxValue - is.lowerValue ) / ( is.upperValue - is.lowerValue );

switch ( s.diagramOrientation )
{
case QgsDiagramSettings::Up:
case QgsDiagramSettings::Down:
mScaleFactor = ( ( is.upperSize.width() - is.lowerSize.height() ) / ( is.upperValue - is.lowerValue ) );
return QSizeF( s.barWidth * attributes.size(), maxValue * mScaleFactor );

case QgsDiagramSettings::Right:
case QgsDiagramSettings::Left:
mScaleFactor = ( ( is.upperSize.width() - is.lowerSize.width() ) / ( is.upperValue - is.lowerValue ) );
return QSizeF( maxValue * mScaleFactor, s.barWidth * attributes.size() );
}

@@ -68,6 +69,7 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributeMap& attributes, cons

QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s )
{
Q_UNUSED( c );
QgsAttributeMap::const_iterator attIt = attributes.constBegin();
if ( attIt == attributes.constEnd() )
{
@@ -154,4 +156,4 @@ void QgsHistogramDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderCo

currentOffset += scaledWidth;
}
}
}

0 comments on commit ef3a086

Please sign in to comment.
You can’t perform that action at this time.