summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorTünde Tóth <tundeth@gmail.com>2020-01-16 12:10:24 +0100
committerLászló Németh <nemeth@numbertext.org>2020-01-28 09:51:07 +0100
commitf8966bb398cf0623be841c618b123866801a063c (patch)
tree2077ea488f825151cd921eda640d1b70849adf65 /chart2
parentb5bde198a8e5054277787d3c6b5feddb4c5b93fd (diff)
tdf#130031 Chart OOXML import: fix area chart data label position
Default data label positioning of area charts in Excel is vertically centered between the X axes and the data point. In LibreOffice the data labels positioning was above the data point. Change-Id: Icff3e2554dee7b5ee264bc6f9579a84852da6f7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86927 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/tools/ChartTypeHelper.cxx3
-rw-r--r--chart2/source/view/charttypes/AreaChart.cxx14
2 files changed, 12 insertions, 5 deletions
diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx
index ebd2af04ab45..b7b3e889e1a1 100644
--- a/chart2/source/tools/ChartTypeHelper.cxx
+++ b/chart2/source/tools/ChartTypeHelper.cxx
@@ -314,9 +314,10 @@ uno::Sequence < sal_Int32 > ChartTypeHelper::getSupportedLabelPlacements( const
}
else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) )
{
- aRet.realloc(1);
+ aRet.realloc(2);
sal_Int32* pSeq = aRet.getArray();
*pSeq++ = css::chart::DataLabelPlacement::TOP;
+ *pSeq++ = css::chart::DataLabelPlacement::CENTER;
}
else if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
{
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index 6d67d0b6a94c..158d3f21bca6 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -750,6 +750,7 @@ void AreaChart::createShapes()
if( rLogicYForNextSeriesMap.find(nAttachedAxisIndex) == rLogicYForNextSeriesMap.end() )
rLogicYForNextSeriesMap[nAttachedAxisIndex] = 0.0;
+ double fPreviousYValue = rLogicYForNextSeriesMap[nAttachedAxisIndex];
fLogicY += rLogicYForNextSeriesMap[nAttachedAxisIndex];
rLogicYForNextSeriesMap[nAttachedAxisIndex] = fLogicY;
@@ -897,13 +898,19 @@ void AreaChart::createShapes()
if( pSeries->getDataPointLabelIfLabel(nIndex) )
{
LabelAlignment eAlignment = LABEL_ALIGN_TOP;
+ sal_Int32 nLabelPlacement = pSeries->getLabelPlacement(
+ nIndex, m_xChartTypeModel, rPosHelper.isSwapXAndY());
+
+ if (m_bArea && nLabelPlacement == css::chart::DataLabelPlacement::CENTER)
+ {
+ fLogicY -= (fLogicY - fPreviousYValue) / 2.0;
+ aScenePosition = rPosHelper.transformLogicToScene(fLogicX, fLogicY, fLogicZ, false);
+ }
+
drawing::Position3D aScenePosition3D( aScenePosition.PositionX
, aScenePosition.PositionY
, aScenePosition.PositionZ+getTransformedDepth() );
- sal_Int32 nLabelPlacement = pSeries->getLabelPlacement(
- nIndex, m_xChartTypeModel, rPosHelper.isSwapXAndY());
-
switch(nLabelPlacement)
{
case css::chart::DataLabelPlacement::TOP:
@@ -924,7 +931,6 @@ void AreaChart::createShapes()
break;
case css::chart::DataLabelPlacement::CENTER:
eAlignment = LABEL_ALIGN_CENTER;
- //todo implement this different for area charts
break;
default:
OSL_FAIL("this label alignment is not implemented yet");