summaryrefslogtreecommitdiff
path: root/chart2/source/view
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2020-12-11 09:13:46 +0100
committerLászló Németh <nemeth@numbertext.org>2020-12-16 18:26:26 +0100
commitb0068342398786ca50304260434a18880dddf74d (patch)
tree3ab817e39b7c9bad27a825f335008ed347ee2cf6 /chart2/source/view
parentf5ab8bcbfd20ecce4a358f62ee3f81b8b968a5de (diff)
tdf#138777 pie chart: improve long data label width
to avoid chart distortion. Reduce the maximum text width of data point label shape based, because in some cases the long data label flowed out of the chart. Change-Id: I045c81ecc6ce579e1f472d7ea67e04315ce9c60b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107585 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2/source/view')
-rw-r--r--chart2/source/view/charttypes/PieChart.cxx25
1 files changed, 10 insertions, 15 deletions
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index 7bf2eaa2a89b..3b61cb9c46e3 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -386,14 +386,14 @@ void PieChart::createTextLabelShape(
// set the maximum text width to be used when text wrapping is enabled
double fTextMaximumFrameWidth = 0.8 * fPieRadius;
- if( nLabelPlacement == css::chart::DataLabelPlacement::OUTSIDE && m_aAvailableOuterRect.getWidth() )
+ if (nLabelPlacement == css::chart::DataLabelPlacement::OUTSIDE
+ && m_aAvailableOuterRect.getWidth())
{
- if (fAngleDegree < 67.5 || fAngleDegree >= 292.5)
- fTextMaximumFrameWidth = m_aAvailableOuterRect.getMaxX() - aPieLabelInfo.aFirstPosition.getX();
- else if (fAngleDegree < 112.5 || fAngleDegree >= 247.5)
- fTextMaximumFrameWidth = m_aAvailableOuterRect.getWidth();
+ if ((fAngleDegree >= 67.5 && fAngleDegree <= 112.5)
+ || (fAngleDegree >= 247.5 && fAngleDegree <= 292.5))
+ fTextMaximumFrameWidth = m_aAvailableOuterRect.getWidth() / 3.0;
else
- fTextMaximumFrameWidth = aPieLabelInfo.aFirstPosition.getX() - m_aAvailableOuterRect.getMinX();
+ fTextMaximumFrameWidth = 0.85 * (m_aAvailableOuterRect.getWidth() / 2.0 - fPieRadius);
}
sal_Int32 nTextMaximumFrameWidth = ceil(fTextMaximumFrameWidth);
@@ -424,17 +424,12 @@ void PieChart::createTextLabelShape(
{
if (m_aAvailableOuterRect.getWidth())
{
- if (fAngleDegree < 67.5 || fAngleDegree >= 292.5)
- fTextMaximumFrameWidth
- = 0.8
- * (m_aAvailableOuterRect.getMaxX() - aPieLabelInfo.aFirstPosition.getX());
- else if (fAngleDegree < 112.5 || fAngleDegree >= 247.5)
- fTextMaximumFrameWidth = 0.8 * m_aAvailableOuterRect.getWidth();
+ if ((fAngleDegree >= 67.5 && fAngleDegree <= 112.5)
+ || (fAngleDegree >= 247.5 && fAngleDegree <= 292.5))
+ fTextMaximumFrameWidth = m_aAvailableOuterRect.getWidth() / 3.0;
else
fTextMaximumFrameWidth
- = 0.8
- * (aPieLabelInfo.aFirstPosition.getX() - m_aAvailableOuterRect.getMinX());
-
+ = 0.85 * (m_aAvailableOuterRect.getWidth() / 2.0 - fPieRadius);
nTextMaximumFrameWidth = ceil(fTextMaximumFrameWidth);
}