diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2020-05-26 14:13:00 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-06-02 14:07:08 +0200 |
commit | 73477348e30c6931a537cba5557c250183fbeb9b (patch) | |
tree | 47d9e863d4453de74bcb0d309eaaa18a41da4a04 /chart2/source | |
parent | a9b47360c2af2514b1064fb179f9fb9f0b8ad225 (diff) |
tdf#133376 Chart view: improve BestFit position of data labels
Put exceeding data label outside the pie slice
without overlapping the other pie slices.
Change-Id: I220fd43f0d52c940cf3ef30764074776d19da184
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94859
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2/source')
-rw-r--r-- | chart2/source/view/charttypes/PieChart.cxx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 009552c1800f..03e928a85c23 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -1591,6 +1591,41 @@ void PieChart::performLabelBestFit(ShapeParam& rShapeParam, PieLabelInfo const & aTranslationVector.setLength(150); aScreenPosition2D.X += aTranslationVector.getX(); aScreenPosition2D.Y += aTranslationVector.getY(); + + double fAngleDegree = rShapeParam.mfUnitCircleStartAngleDegree + rShapeParam.mfUnitCircleWidthAngleDegree / 2.0; + ::basegfx::B2IRectangle aBb(lcl_getRect(rPieLabelInfo.xLabelGroupShape)); + double fLabelWidth = aBb.getWidth(); + double fLabelHeight = aBb.getHeight(); + + while (fAngleDegree > 360.0) + fAngleDegree -= 360.0; + while (fAngleDegree < 0.0) + fAngleDegree += 360.0; + + if( fAngleDegree <= 22.5 || fAngleDegree >= 337.5 ) + aScreenPosition2D.Y -= fLabelHeight / 2; + else if( fAngleDegree < 67.5 ) + aScreenPosition2D.Y -= fLabelHeight; + else if( fAngleDegree < 112.5 ) + { + aScreenPosition2D.X -= fLabelWidth / 2; + aScreenPosition2D.Y -= fLabelHeight; + } + else if (fAngleDegree <= 157.5) + { + aScreenPosition2D.X -= fLabelWidth; + aScreenPosition2D.Y -= fLabelHeight; + } + else if (fAngleDegree <= 202.5) + { + aScreenPosition2D.X -= fLabelWidth; + aScreenPosition2D.Y -= fLabelHeight / 2; + } + else if (fAngleDegree < 247.5) + aScreenPosition2D.X -= fLabelWidth; + else if (fAngleDegree < 292.5) + aScreenPosition2D.X -= fLabelWidth / 2; + rPieLabelInfo.xLabelGroupShape->setPosition(aScreenPosition2D); } |