[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - chart2/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Dec 20 09:42:01 UTC 2018
chart2/source/view/charttypes/BarChart.cxx | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
New commits:
commit ab24108a996879e76a08a17afdce59814a5531eb
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: Thu Dec 20 10:41:38 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>
(cherry picked from commit abd9272ef1be9da58d405a0ddf3913a816a7e362)
Reviewed-on: https://gerrit.libreoffice.org/65440
Reviewed-by: Balazs Varga <balazs.varga991 at gmail.com>
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