Skip to content

Commit

Permalink
[diagrams] Fix incorrectly calculated size of diagrams when bar spaci…
Browse files Browse the repository at this point in the history
…ng is set
  • Loading branch information
nyalldawson committed Nov 23, 2019
1 parent c7d4892 commit ee26089
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/diagram/qgshistogramdiagram.cpp
Expand Up @@ -61,7 +61,12 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsFeature &feature, const QgsRen
maxValue = s.minimumSize;
}

const double spacing = c.convertToPainterUnits( s.spacing(), s.spacingUnit(), s.spacingMapUnitScale() );
// eh - this method returns size in unknown units ...! We'll have to fake it and use a rough estimation of
// a conversion factor to painter units...
// TODO QGIS 4.0 -- these methods should all use painter units, dependant on the render context scaling...
double painterUnitConversionScale = c.convertToPainterUnits( 1, s.sizeType );

const double spacing = c.convertToPainterUnits( s.spacing(), s.spacingUnit(), s.spacingMapUnitScale() ) / painterUnitConversionScale;

switch ( s.diagramOrientation )
{
Expand Down Expand Up @@ -118,7 +123,12 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributes &attributes, const
maxValue = std::max( attributes.at( i ).toDouble(), maxValue );
}

const double spacing = c.convertToPainterUnits( s.spacing(), s.spacingUnit(), s.spacingMapUnitScale() );
// eh - this method returns size in unknown units ...! We'll have to fake it and use a rough estimation of
// a conversion factor to painter units...
// TODO QGIS 4.0 -- these methods should all use painter units, dependant on the render context scaling...
double painterUnitConversionScale = c.convertToPainterUnits( 1, s.sizeType );

const double spacing = c.convertToPainterUnits( s.spacing(), s.spacingUnit(), s.spacingMapUnitScale() ) / painterUnitConversionScale;

switch ( s.diagramOrientation )
{
Expand Down

0 comments on commit ee26089

Please sign in to comment.