diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2018-12-13 10:19:04 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2018-12-14 22:46:02 +0100 |
commit | abd9272ef1be9da58d405a0ddf3913a816a7e362 (patch) | |
tree | be88deb77f102dd63f8e0e909b8d3a3646f0c507 /chart2 | |
parent | lok: Handle Special character menu item's state correctly in online (diff) | |
download | core-abd9272ef1be9da58d405a0ddf3913a816a7e362.tar.gz core-abd9272ef1be9da58d405a0ddf3913a816a7e362.zip |
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@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/charttypes/BarChart.cxx | 23 |
1 files changed, 20 insertions, 3 deletions
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; |