[Libreoffice-commits] core.git: chart2/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Dec 14 21:46:29 UTC 2018


 chart2/source/view/charttypes/BarChart.cxx |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

New commits:
commit abd9272ef1be9da58d405a0ddf3913a816a7e362
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Thu Dec 13 10:19:04 2018 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Dec 14 22:46:02 2018 +0100

    Related: tdf#118705 Fix Column/Bar Chart data label placement
    
    Modify the chart data label rendering in case of Column/Bar chart
    only if the datapoint value is 0. This patch fix in case of NEAR_ORIGIN
    and CENTER DataLabelPlacement.
    
    Change-Id: Ia9857b5ac0cc5feaf2e1fd08e98c9f8534e5af04
    Reviewed-on: https://gerrit.libreoffice.org/65082
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Tested-by: László Németh <nemeth at numbertext.org>

diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx
index 51dba0143bf2..42741fb37a2e 100644
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -244,11 +244,13 @@ awt::Point BarChart::getLabelScreenPositionAndAlignment(
         {
         fY = (fBaseValue < fScaledUpperYValue) ? fScaledUpperYValue : fScaledLowerYValue;
         if( pPosHelper->isSwapXAndY() )
+            // if datapoint value is 0 the label will appear RIGHT in case of Bar Chart
             if( fBaseValue == fScaledUpperYValue && fBaseValue == fScaledLowerYValue )
                 rAlignment = LABEL_ALIGN_RIGHT;
             else
                 rAlignment = bNormalOutside ? LABEL_ALIGN_RIGHT : LABEL_ALIGN_LEFT;
         else
+            // if datapoint value is 0 the label will appear TOP in case of Column Chart
             if( fBaseValue == fScaledUpperYValue && fBaseValue == fScaledLowerYValue )
                 rAlignment = LABEL_ALIGN_TOP;
             else
@@ -272,16 +274,31 @@ awt::Point BarChart::getLabelScreenPositionAndAlignment(
         {
         fY = (fBaseValue < fScaledUpperYValue) ? fScaledLowerYValue : fScaledUpperYValue;
         if( pPosHelper->isSwapXAndY() )
-            rAlignment = bNormalOutside ? LABEL_ALIGN_RIGHT : LABEL_ALIGN_LEFT;
+            // if datapoint value is 0 the label will appear RIGHT in case of Bar Chart
+            if( fBaseValue == fScaledUpperYValue && fBaseValue == fScaledLowerYValue )
+                rAlignment = LABEL_ALIGN_RIGHT;
+            else
+                rAlignment = bNormalOutside ? LABEL_ALIGN_RIGHT : LABEL_ALIGN_LEFT;
         else
-            rAlignment = bNormalOutside ? LABEL_ALIGN_TOP : LABEL_ALIGN_BOTTOM;
+            // if datapoint value is 0 the label will appear TOP in case of Column Chart
+            if( fBaseValue == fScaledUpperYValue && fBaseValue == fScaledLowerYValue )
+                rAlignment = LABEL_ALIGN_TOP;
+            else
+                rAlignment = bNormalOutside ? LABEL_ALIGN_TOP : LABEL_ALIGN_BOTTOM;
         if(m_nDimension==3)
             fDepth = (fBaseValue < fScaledUpperYValue) ? fabs(fScaledLowerBarDepth) : fabs(fScaledUpperBarDepth);
         }
         break;
     case css::chart::DataLabelPlacement::CENTER:
         fY -= (fScaledUpperYValue-fScaledLowerYValue)/2.0;
-        rAlignment = LABEL_ALIGN_CENTER;
+        // if datapoint value is 0 the label will appear TOP/RIGHT in case of Column/Bar Charts
+        if( fBaseValue == fScaledUpperYValue && fBaseValue == fScaledLowerYValue )
+            if( pPosHelper->isSwapXAndY() )
+                rAlignment = LABEL_ALIGN_RIGHT;
+            else
+                rAlignment = LABEL_ALIGN_TOP;
+        else
+            rAlignment = LABEL_ALIGN_CENTER;
         if(m_nDimension==3)
             fDepth = fabs(fScaledUpperBarDepth-fScaledLowerBarDepth)/2.0;
         break;


More information about the Libreoffice-commits mailing list