core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx | 92 - chart2/source/view/charttypes/PieChart.hxx |9 ++ 2 files changed, 62 insertions(+), 39 deletions(-) New commits: commit 86dcdfd097b0fdd91d69ecb8be0e72a84112a514 Author: Kurt Nordback AuthorDate: Wed May 15 17:27:22 2024 -0600 Commit: Noel Grandin CommitDate: Thu May 16 10:56:21 2024 +0200 tdf#159547 of-pie connector lines aren't quite geometrically correct Fixed code computing the left endpoints of of-pie connector lines, so that they're tangent to the circle when the composite slice is large enough (and they terminate at the tangent point). Change-Id: I4ff4d8e31f47259f0f48721b532dc245ede83003 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167712 Reviewed-by: Noel Grandin Tested-by: Jenkins diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index d99e3d944af3..fcb79ef1907a 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -807,6 +807,47 @@ bool PieChart::isSeparateStackingForDifferentSigns( sal_Int32 /* nDimensionIndex return false; } +// Determine left endpoints of connecting lines. These will terminate either +// at the corners of the composite wedge (if the wedge is small enough), or +// tangent to the left pie circle (if the wedge is larger). The endpoints +// are at the returned values (xl0, +/-yl0). +// static +void PieChart::leftConnEndpoints(double* xl0_p, double* yl0_p, +const PieDataSrcBase *pDataSrc, +const VDataSeries *pSeries, +const ShapeParam ) +{ +const sal_Int32 nEnd = pDataSrc->getNPoints(pSeries, SubPieType::LEFT); +const double compFrac = pDataSrc->getData(pSeries, nEnd - 1, +SubPieType::LEFT) / aParam.mfLogicYSum; + +// Assuming temporarily that the left circle is at the origin, +// the tangent point (xp0, yp0) on the left circle satisfies +// (1) xp0 = (1-r) / t +// (2) xp0^2 + yp0^2 = 1 +// where the left-hand circle has radius 1, the right-hand circle +// has radius r, and the right-hand circle is centered at (t, 0). +const double r0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale; +const double rho = m_fRightScale / m_fLeftScale; +const double xp0 = (1 - rho) / (m_fRightShift - m_fLeftShift); +// Determine if the composite wedge is large enough that the +// connecting lines hit the tangent point, instead of the corners of +// the wedge +assert(abs(xp0) <= 1.0); +const double theta = acos(xp0); + +double xl0, yl0; +if (compFrac < theta / M_PI) { +xl0 = r0 * cos(compFrac * M_PI); +yl0 = r0 * sin(compFrac * M_PI); +} else { +xl0 = r0 * xp0; +yl0 = sqrt(r0 * r0 - xl0 * xl0); +} +*xl0_p = xl0; +*yl0_p = yl0; +} + void PieChart::createShapes() { ///a ZSlot is a vector< vector< VDataSeriesGroup > >. There is only one @@ -941,19 +982,9 @@ void PieChart::createShapes() // double xl0, xl1, yl0, yl1, x0, y0, x1, y1, y2, y3; -// Get coordinates of "corners" of left composite wedge -sal_Int32 nEnd = pDataSrc->getNPoints(pSeries, SubPieType::LEFT); -double compFrac = pDataSrc->getData(pSeries, nEnd - 1, -SubPieType::LEFT) / aParam.mfLogicYSum; -if (compFrac < 0.5) { -xl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale * -cos(compFrac * M_PI) + m_fLeftShift; -yl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale * -sin(compFrac * M_PI); -} else { -xl0 = m_fLeftShift; -yl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale; -} +leftConnEndpoints(, , pDataSrc, pSeries, aParam); + +xl0 += m_fLeftShift; // Coordinates of bar top left corner xl1 = m_fBarLeft; @@ -1000,39 +1031,22 @@ void PieChart::createShapes() // double xl0, xl1, yl0, yl1, x0, y0, x1, y1, y2, y3; -// Get coordinates of "corners" of left composite wedge -sal_Int32 nEnd = pDataSrc->getNPoints(pSeries, SubPieType::LEFT); -double compFrac = pDataSrc->getData(pSeries, nEnd - 1, -SubPieType::LEFT) / aParam.mfLogicYSum; -// The following isn't quite right. The tangent points on the left -// pie are only at pi/2 and -pi/2 for composite wedges over 1/2 the -// total if left and right pies are the same diameter. And the -// threshold of 1/2 isn't quite right either. So there -// really should be a more sophisticated approach here. TODO -if (compFrac < 0.5) { -// Translated, per below -xl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale * -
core.git: chart2/qa chart2/source
chart2/qa/extras/chart2export.cxx | 14 -- chart2/source/view/inc/VDataSeries.hxx |1 - chart2/source/view/main/SeriesPlotterContainer.cxx |2 ++ 3 files changed, 6 insertions(+), 11 deletions(-) New commits: commit 4425741937fbd240fe414a68a7d5e9ac4b40affd Author: Kurt Nordback AuthorDate: Fri May 10 09:59:52 2024 -0600 Commit: Noel Grandin CommitDate: Fri May 10 19:57:15 2024 +0200 tdf#161013 Rendering error when changing chart type for saved of-pie chart Reset pie sub-type property in XDiagram after passing it down, so that it does not persist and overwrite the modified sub-type Change-Id: If23ef2b1cff29efa5232d49381676592a0f39d17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167487 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 1c4977f5d38b..4335ee9ff887 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -1147,11 +1147,8 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest, tdf50934_barOfPie) xChartType->getChartType()); // Verify that it saves and loads as bar-of-pie -Reference< chart2::XDiagram> xDia(xChartDoc->getFirstDiagram()); -CPPUNIT_ASSERT(xDia.is()); -uno::Reference< beans::XPropertySet > xDiaProp( xDia, uno::UNO_QUERY ); -CPPUNIT_ASSERT(xDiaProp.is()); -uno::Any aAny = xDiaProp->getPropertyValue(u"SubPieType"_ustr); +Reference< beans::XPropertySet > xPropSet( xChartType, uno::UNO_QUERY_THROW ); +uno::Any aAny = xPropSet->getPropertyValue(u"SubPieType"_ustr); CPPUNIT_ASSERT(aAny.hasValue()); chart2::PieChartSubType subPieType; aAny >>= subPieType; @@ -1173,11 +1170,8 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest, tdf50934_pieOfPie) xChartType->getChartType()); // Verify that it saves and loads as pie-of-pie -Reference< chart2::XDiagram> xDia(xChartDoc->getFirstDiagram()); -CPPUNIT_ASSERT(xDia.is()); -uno::Reference< beans::XPropertySet > xDiaProp( xDia, uno::UNO_QUERY ); -CPPUNIT_ASSERT(xDiaProp.is()); -uno::Any aAny = xDiaProp->getPropertyValue(u"SubPieType"_ustr); +Reference< beans::XPropertySet > xPropSet( xChartType, uno::UNO_QUERY_THROW ); +uno::Any aAny = xPropSet->getPropertyValue(u"SubPieType"_ustr); CPPUNIT_ASSERT(aAny.hasValue()); chart2::PieChartSubType subPieType; aAny >>= subPieType; diff --git a/chart2/source/view/inc/VDataSeries.hxx b/chart2/source/view/inc/VDataSeries.hxx index dd5054d26bd8..72f5fca80089 100644 --- a/chart2/source/view/inc/VDataSeries.hxx +++ b/chart2/source/view/inc/VDataSeries.hxx @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/chart2/source/view/main/SeriesPlotterContainer.cxx b/chart2/source/view/main/SeriesPlotterContainer.cxx index 557bbdae3c11..c76d96a4f20f 100644 --- a/chart2/source/view/main/SeriesPlotterContainer.cxx +++ b/chart2/source/view/main/SeriesPlotterContainer.cxx @@ -232,6 +232,8 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart { xChartType->setFastPropertyValue(PROP_PIECHARTTYPE_SUBTYPE, uno::Any(ePieChartSubType)); +// Reset the diagram-level property so it's not persistent. +xDiagram->setPropertyValue(u"SubPieType"_ustr, uno::Any(PieChartSubType_NONE)); } if (nT == 0)
core.git: chart2/qa chart2/source include/xmloff schema/libreoffice xmloff/source
chart2/qa/extras/chart2export.cxx | 53 chart2/qa/extras/data/ods/tdf50934_barOfPie.ods |binary chart2/qa/extras/data/ods/tdf50934_pieOfPie.ods |binary chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx |9 ++ chart2/source/inc/ChartType.hxx |6 - include/xmloff/xmltoken.hxx |3 schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng | 14 +++ xmloff/source/chart/PropertyMap.hxx |1 xmloff/source/chart/SchXMLChartContext.cxx | 23 - xmloff/source/chart/SchXMLChartContext.hxx |3 xmloff/source/chart/SchXMLExport.cxx|7 + xmloff/source/chart/SchXMLTools.cxx |7 + xmloff/source/core/xmltoken.cxx |3 xmloff/source/token/tokens.txt |3 14 files changed, 124 insertions(+), 8 deletions(-) New commits: commit 9ae8e74fb32254c81d36b1c95411605459e06372 Author: Kurt Nordback AuthorDate: Tue Mar 5 11:01:42 2024 -0700 Commit: Noel Grandin CommitDate: Mon Mar 18 07:07:24 2024 +0100 tdf#50934: Add a pie-with-remainder-as-another-pie chart type Implement ODF import/export for bar-of-pie and pie-of-pie types, and add simple tests for this capability. The associated ODF tags are implemented in the loext namespace. This also required changing the schema. Change-Id: Ib55ae1c5818ad810f7b962d807a9163a3d02ba17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164436 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index b46bc776d587..86f2dee778e6 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -18,6 +18,7 @@ #include #include #include +#include using uno::Reference; using beans::XPropertySet; @@ -1132,6 +1133,58 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testErrorBarDataRangeODS) CPPUNIT_ASSERT_EQUAL(OUString("$Sheet1.$C$1:$C$3"), aNegRange); } +CPPUNIT_TEST_FIXTURE(Chart2ExportTest, tdf50934_barOfPie) +{ +loadFromFile(u"ods/tdf50934_barOfPie.ods"); +saveAndReload("calc8"); + +uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent ); +CPPUNIT_ASSERT(xChartDoc.is()); + +Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, 0 ); +CPPUNIT_ASSERT(xChartType.is()); + +CPPUNIT_ASSERT_EQUAL(u"com.sun.star.chart2.PieChartType"_ustr, +xChartType->getChartType()); + +// Verify that it saves and loads as bar-of-pie +Reference< chart2::XDiagram> xDia(xChartDoc->getFirstDiagram()); +CPPUNIT_ASSERT(xDia.is()); +uno::Reference< beans::XPropertySet > xDiaProp( xDia, uno::UNO_QUERY ); +CPPUNIT_ASSERT(xDiaProp.is()); +uno::Any aAny = xDiaProp->getPropertyValue("SubPieType"); +CPPUNIT_ASSERT(aAny.hasValue()); +chart2::PieChartSubType subPieType; +aAny >>= subPieType; +CPPUNIT_ASSERT_EQUAL(chart2::PieChartSubType_BAR, subPieType); +} + +CPPUNIT_TEST_FIXTURE(Chart2ExportTest, tdf50934_pieOfPie) +{ +loadFromFile(u"ods/tdf50934_pieOfPie.ods"); +saveAndReload("calc8"); + +uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet( 0, mxComponent ); +CPPUNIT_ASSERT(xChartDoc.is()); + +Reference< chart2::XChartType > xChartType = getChartTypeFromDoc( xChartDoc, 0 ); +CPPUNIT_ASSERT(xChartType.is()); + +CPPUNIT_ASSERT_EQUAL(u"com.sun.star.chart2.PieChartType"_ustr, +xChartType->getChartType()); + +// Verify that it saves and loads as pie-of-pie +Reference< chart2::XDiagram> xDia(xChartDoc->getFirstDiagram()); +CPPUNIT_ASSERT(xDia.is()); +uno::Reference< beans::XPropertySet > xDiaProp( xDia, uno::UNO_QUERY ); +CPPUNIT_ASSERT(xDiaProp.is()); +uno::Any aAny = xDiaProp->getPropertyValue("SubPieType"); +CPPUNIT_ASSERT(aAny.hasValue()); +chart2::PieChartSubType subPieType; +aAny >>= subPieType; +CPPUNIT_ASSERT_EQUAL(chart2::PieChartSubType_PIE, subPieType); +} + CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testChartCrash) { loadFromFile(u"docx/FDO75975.docx"); diff --git a/chart2/qa/extras/data/ods/tdf50934_barOfPie.ods b/chart2/qa/extras/data/ods/tdf50934_barOfPie.ods new file mode 100644 index ..d9b577a38a36 Binary files /dev/null and b/chart2/qa/extras/data/ods/tdf50934_barOfPie.ods differ diff --git a/chart2/qa/extras/data/ods/tdf50934_pieOfPie.ods b/chart2/qa/extras/data/ods/tdf50934_pieOfPie.ods new file mode 100644 index ..74a9f85f6981 Binary files /dev/null and b/chart2/qa/extras/data/ods/tdf50934_pieOfPie.ods differ diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
core.git: chart2/source
chart2/source/view/charttypes/BarChart.cxx |2 -- 1 file changed, 2 deletions(-) New commits: commit 46e96625e9dc3c452a7323c8bf231fea3acab606 Author: Kurt Nordback AuthorDate: Thu Jan 4 09:17:48 2024 -0700 Commit: Ilmari Lauhakangas CommitDate: Mon Mar 11 14:56:28 2024 +0100 tdf#96944: Stacked column chart does not show connection lines Change-Id: I14727e8a55231b6695c5a59dd495cd03b15d69f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161626 Tested-by: Jenkins Tested-by: Ilmari Lauhakangas Reviewed-by: Ilmari Lauhakangas diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx index cd8ab4e86c48..fcc969b898ad 100644 --- a/chart2/source/view/charttypes/BarChart.cxx +++ b/chart2/source/view/charttypes/BarChart.cxx @@ -542,8 +542,6 @@ void BarChart::createShapes() getSeriesGroupShape(pSeries.get(), xSeriesTarget) ); rtl::Reference xShape( ShapeFactory::createLine2D( xSeriesGroupShape_Shapes, aPoly ) ); -PropertyMapper::setMappedProperties( *xShape, pSeries->getPropertiesOfSeries() -, PropertyMapper::getPropertyNameMapForFilledSeriesProperties() ); } } }
core.git: chart2/qa chart2/source
chart2/qa/extras/chart2export.cxx | 22 + chart2/qa/extras/data/xlsx/barOfPieChart.xlsx |binary chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx |binary chart2/source/view/charttypes/PieChart.cxx| 63 +++--- chart2/source/view/charttypes/PieChart.hxx|2 5 files changed, 71 insertions(+), 16 deletions(-) New commits: commit 96e9c3a7fd2ce877d6d4d87c534790f7d85a Author: Kurt Nordback AuthorDate: Wed Dec 13 16:16:11 2023 -0700 Commit: Noel Grandin CommitDate: Mon Feb 19 20:34:18 2024 +0100 tdf#50934: Fix compiler complaints and activate OOXML I/O tests Add tests for input and output of very basic pie-of-pie and bar-of-pie charts in OOXML. Change-Id: I6441d99941ea2aca9bf58ede40dbe8f3d38a3291 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160742 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 81ed060e7acb..b46bc776d587 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -529,6 +529,28 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testDoughnutChart) assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:doughnutChart"_ostr); } +CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testPieOfPieChart) +{ +loadFromFile(u"xlsx/pieOfPieChart.xlsx"); +save("Calc Office Open XML"); +xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml"); +CPPUNIT_ASSERT(pXmlDoc); + +assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart"_ostr); +assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart/c:ofPieType[1]"_ostr, "val"_ostr, "pie"); +} + +CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testBarOfPieChart) +{ +loadFromFile(u"xlsx/barOfPieChart.xlsx"); +save("Calc Office Open XML"); +xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml"); +CPPUNIT_ASSERT(pXmlDoc); + +assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart"_ostr); +assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart/c:ofPieType[1]"_ostr, "val"_ostr, "bar"); +} + CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testDisplayUnits) { loadFromFile(u"docx/DisplayUnits.docx"); diff --git a/chart2/qa/extras/data/xlsx/barOfPieChart.xlsx b/chart2/qa/extras/data/xlsx/barOfPieChart.xlsx new file mode 100644 index ..227ab832a4ac Binary files /dev/null and b/chart2/qa/extras/data/xlsx/barOfPieChart.xlsx differ diff --git a/chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx b/chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx index efb1c05ca864..b3a1c3588427 100644 Binary files a/chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx and b/chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx differ diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index b70fde756c74..ff8cf62f133a 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -918,7 +918,7 @@ void PieChart::createShapes() // Default to regular pie if too few points for of-pie ::css::chart2::PieChartSubType eSubType = -nPointCount >= OfPieDataSrc::minPoints() ? +nPointCount >= OfPieDataSrc::minPoints ? m_eSubType : PieChartSubType_NONE; @@ -1068,7 +1068,38 @@ void PieChart::createShapes() }//next x slot } -void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, +static sal_Int32 propIndex( +sal_Int32 nPointIndex, +enum SubPieType eType, +const PieDataSrcBase *pDataSrc, +VDataSeries* pSeries) +{ + +switch (eType) { +case SubPieType::LEFT: +if (nPointIndex == pDataSrc->getNPoints(pSeries, +SubPieType::LEFT) - 1) { +return pSeries->getTotalPointCount(); +} else { +return nPointIndex; +} +break; +case SubPieType::RIGHT: +return pDataSrc->getNPoints(pSeries, SubPieType::LEFT) + +nPointIndex - 1; +break; +case SubPieType::NONE: +return nPointIndex; +break; +default: // shouldn't happen +assert(false); +return 0; // suppress compile warning +} +} + + +void PieChart::createOneRing( +enum SubPieType eType, double fSlotX, ShapeParam& aParam, const rtl::Reference& xSeriesTarget, @@ -1187,11 +1218,9 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, bConcentricExplosion); // Handle coloring of the composite wedge -const sal_Int32 nPropIdx = ( -eType == SubPieType::LEFT && -nPointIndex == pDataSrc->getNPoints(pSeries, SubPieType::LEFT) - 1 ? -pSeries->getTotalPointCount() : -nPointIndex); +sal_Int32 nPropIdx =
core.git: chart2/qa
chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx |binary 1 file changed New commits: commit 72808cb6383b266e3e3e7844305216b9d6c0a058 Author: Kurt Nordback AuthorDate: Mon Dec 11 16:53:02 2023 -0700 Commit: Noel Grandin CommitDate: Mon Feb 19 14:59:05 2024 +0100 tdf#50934: Add one of-pie test Change-Id: I9af705ed671718486d2e46e481b5416e683cdbb7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160741 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx b/chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx new file mode 100644 index ..efb1c05ca864 Binary files /dev/null and b/chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx differ
core.git: chart2/inc icon-themes/breeze icon-themes/breeze_dark icon-themes/colibre icon-themes/colibre_dark icon-themes/elementary icon-themes/karasa_jaga icon-themes/sifr icon-themes/sifr_dark icon-
chart2/inc/bitmaps.hlst |4 ++-- icon-themes/breeze/chart2/res/barofpie_52x60.png|binary icon-themes/breeze/chart2/res/pieofpie_52x60.png|binary icon-themes/breeze_dark/chart2/res/barofpie_52x60.png |binary icon-themes/breeze_dark/chart2/res/pieofpie_52x60.png |binary icon-themes/colibre/chart2/res/barofpie_52x60.png |binary icon-themes/colibre/chart2/res/pieofpie_52x60.png |binary icon-themes/colibre_dark/chart2/res/barofpie_52x60.png |binary icon-themes/colibre_dark/chart2/res/pieofpie_52x60.png |binary icon-themes/elementary/chart2/res/barofpie_52x60.png|binary icon-themes/elementary/chart2/res/pieofpie_52x60.png|binary icon-themes/karasa_jaga/chart2/res/barofpie_52x60.png |binary icon-themes/karasa_jaga/chart2/res/pieofpie_52x60.png |binary icon-themes/sifr/chart2/res/barofpie_52x60.png |binary icon-themes/sifr/chart2/res/pieofpie_52x60.png |binary icon-themes/sifr_dark/chart2/res/barofpie_52x60.png |binary icon-themes/sifr_dark/chart2/res/pieofpie_52x60.png |binary icon-themes/sukapura/chart2/res/barofpie_52x60.png |binary icon-themes/sukapura/chart2/res/pieofpie_52x60.png |binary icon-themes/sukapura_dark/chart2/res/barofpie_52x60.png |binary icon-themes/sukapura_dark/chart2/res/pieofpie_52x60.png |binary 21 files changed, 2 insertions(+), 2 deletions(-) New commits: commit 2b4e95b8f0e04a3c60df1887276068a9674d3d16 Author: Kurt Nordback AuthorDate: Sun Dec 10 21:32:22 2023 -0700 Commit: Noel Grandin CommitDate: Mon Feb 19 12:31:30 2024 +0100 tdf#50934: Rudimentary UI images for pie-of-pie and bar-of-pie Change-Id: If2ddf1ea12804717583ab6df18dc7fbfffc37d31 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160740 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/inc/bitmaps.hlst b/chart2/inc/bitmaps.hlst index b73667d17fcb..4c184dc09aeb 100644 --- a/chart2/inc/bitmaps.hlst +++ b/chart2/inc/bitmaps.hlst @@ -26,7 +26,7 @@ inline constexpr OUString BMP_AREAS_2D_3 = u"chart2/res/areasfull_52x60.png"_ust inline constexpr OUString BMP_AREAS_3D = u"chart2/res/areaspiled3d_52x60.png"_ustr; inline constexpr OUString BMP_AREAS_3D_1 = u"chart2/res/areas3d_52x60.png"_ustr; inline constexpr OUString BMP_AREAS_3D_2 = u"chart2/res/areasfull3d_52x60.png"_ustr; -inline constexpr OUString BMP_BAR_OF_PIE = u"chart2/res/pie_52x60.png"_ustr; // TODO +inline constexpr OUString BMP_BAR_OF_PIE = u"chart2/res/barofpie_52x60.png"_ustr; // TODO inline constexpr OUString BMP_BARS_2D_1 = u"chart2/res/bar_52x60.png"_ustr; inline constexpr OUString BMP_BARS_2D_2 = u"chart2/res/barstack_52x60.png"_ustr; inline constexpr OUString BMP_BARS_2D_3 = u"chart2/res/barpercent_52x60.png"_ustr; @@ -97,7 +97,7 @@ inline constexpr OUString BMP_NET_LINESYMB = u"chart2/res/netlinepoint_52x60.png inline constexpr OUString BMP_NET_LINESYMB_STACK = u"chart2/res/netlinepointstack_52x60.png"_ustr; inline constexpr OUString BMP_NET_FILL = u"chart2/res/netfill_52x60.png"_ustr; inline constexpr OUString BMP_NET_FILL_STACK = u"chart2/res/netstackfill_52x60.png"_ustr; -inline constexpr OUString BMP_PIE_OF_PIE = u"chart2/res/pie_52x60.png"_ustr; // TODO +inline constexpr OUString BMP_PIE_OF_PIE = u"chart2/res/pieofpie_52x60.png"_ustr; // TODO inline constexpr OUString BMP_PYRAMIDQ_3D_1 = u"chart2/res/pyramindhori_52x60.png"_ustr; inline constexpr OUString BMP_PYRAMIDQ_3D_2 = u"chart2/res/pyramindhoristack_52x60.png"_ustr; inline constexpr OUString BMP_PYRAMIDQ_3D_3 = u"chart2/res/pyramindhoripercent_52x60.png"_ustr; diff --git a/icon-themes/breeze/chart2/res/barofpie_52x60.png b/icon-themes/breeze/chart2/res/barofpie_52x60.png new file mode 100644 index ..2992d878ad4a Binary files /dev/null and b/icon-themes/breeze/chart2/res/barofpie_52x60.png differ diff --git a/icon-themes/breeze/chart2/res/pieofpie_52x60.png b/icon-themes/breeze/chart2/res/pieofpie_52x60.png new file mode 100644 index ..7e110f088feb Binary files /dev/null and b/icon-themes/breeze/chart2/res/pieofpie_52x60.png differ diff --git a/icon-themes/breeze_dark/chart2/res/barofpie_52x60.png b/icon-themes/breeze_dark/chart2/res/barofpie_52x60.png new file mode 100644 index ..2992d878ad4a Binary files /dev/null and b/icon-themes/breeze_dark/chart2/res/barofpie_52x60.png differ diff --git a/icon-themes/breeze_dark/chart2/res/pieofpie_52x60.png b/icon-themes/breeze_dark/chart2/res/pieofpie_52x60.png new file mode 100644 index ..7e110f088feb Binary files /dev/null and b/icon-themes/breeze_dark/chart2/res/pieofpie_52x60.png differ diff --git a/icon-themes/colibre/chart2/res/barofpie_52x60.png b/icon-themes/colibre/chart2/res/barofpie_52x60.png new file mode 100644 index ..2992d878ad4a Binary files /dev/null and b/icon-themes/colibre/chart2/res/barofpie_52x60.png differ diff --git
core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit cf2715782d9ccb2acf46dc316e9a8c6990bdf368 Author: Kurt Nordback AuthorDate: Sun Dec 10 21:06:44 2023 -0700 Commit: Noel Grandin CommitDate: Mon Feb 19 12:19:33 2024 +0100 tdf#50934: Fix color of composite wedge for imported of-pie charts Change-Id: I5236ed53e418e31a470a66bdbe21eceaa5f6fc04 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160739 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 6d2f0ce091aa..b70fde756c74 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -1193,7 +1193,7 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, pSeries->getTotalPointCount() : nPointIndex); ///point color: -if (!pSeries->hasPointOwnColor(nPointIndex) && m_xColorScheme.is()) +if (!pSeries->hasPointOwnColor(nPropIdx) && m_xColorScheme.is()) { xPointShape->setPropertyValue("FillColor", uno::Any(m_xColorScheme->getColorByIndex( nPropIdx )));
core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 67e58d16f25332d2c96e2c9702bd78e9d76501c0 Author: Kurt Nordback AuthorDate: Thu Dec 7 19:47:47 2023 -0700 Commit: Noel Grandin CommitDate: Mon Feb 19 09:19:21 2024 +0100 tdf#50934: Fix left of-pie ordering for imported charts Change-Id: I490d6719f5190b0e889bd274ffa9c1b196e656d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160738 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 61583c9d477a..6d2f0ce091aa 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -182,7 +182,7 @@ bool PiePositionHelper::getInnerAndOuterRadius( double fCategoryX bool PiePositionHelper::clockwiseWedges() const { const ExplicitScaleData& rAngleScale = m_bSwapXAndY ? m_aScales[1] : m_aScales[0]; -return rAngleScale.Orientation == AxisOrientation_MATHEMATICAL; +return rAngleScale.Orientation == AxisOrientation_REVERSE; }
core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx | 13 +++-- chart2/source/view/charttypes/PieChart.hxx |7 +++ 2 files changed, 18 insertions(+), 2 deletions(-) New commits: commit dfacc5a522a7458646f4ec42b9fc58c1f3fdb0a8 Author: Kurt Nordback AuthorDate: Thu Dec 7 06:47:50 2023 -0700 Commit: Noel Grandin CommitDate: Mon Feb 19 07:57:44 2024 +0100 tdf#50934: Try to fix wedge ordering for imported of-pie charts Change-Id: I6e9a0d5426fb213c99ee99092596f68d688b928c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160736 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 402857b85cdc..61583c9d477a 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -178,6 +178,14 @@ bool PiePositionHelper::getInnerAndOuterRadius( double fCategoryX return true; } + +bool PiePositionHelper::clockwiseWedges() const +{ +const ExplicitScaleData& rAngleScale = m_bSwapXAndY ? m_aScales[1] : m_aScales[0]; +return rAngleScale.Orientation == AxisOrientation_MATHEMATICAL; +} + + PieChart::PieChart( const rtl::Reference& xChartTypeModel , sal_Int32 nDimensionCount , bool bExcludingPositioning ) @@ -1087,8 +1095,9 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, // Left of-pie has the "composite" wedge (the one expanded in the right // subgraph) facing to the right in the chart, to allow the expansion // lines to meet it -double compositeVal = pDataSrc->getData(pSeries, nRingPtCnt - 1, eType); -return compositeVal * 360 / (ringSum * 2); +const double compositeVal = pDataSrc->getData(pSeries, nRingPtCnt - 1, eType); +const double degAng = compositeVal * 360 / (ringSum * 2); +return m_aPosHelper.clockwiseWedges() ? 360 - degAng : degAng; } else { /// The angle degree offset is set by the same property of the /// data series. diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx index a3e4519ead8c..abcf1cc2db9b 100644 --- a/chart2/source/view/charttypes/PieChart.hxx +++ b/chart2/source/view/charttypes/PieChart.hxx @@ -39,6 +39,10 @@ public: boolgetInnerAndOuterRadius( double fCategoryX, double& fLogicInnerRadius, double& fLogicOuterRadius, bool bUseRings, double fMaxOffset ) const; +// Determine if the pie wedges are ordered clockwise (returns true) or +// counterclockwise (returns false) +boolclockwiseWedges() const; + public: //Distance between different category rings, seen relative to width of a ring: double m_fRingDistance; //>=0 m_fRingDistance=1 --> distance == width @@ -222,6 +226,9 @@ struct PieLabelInfo; sal_Int32 n3DRelativeHeight); private: //member +// Constants for of-pie charts. Some of these will want to become +// user-selectable values. TODO + // Radius scalings for left and right of-pie subcharts static constexpr double m_fLeftScale = 2.0/3; static constexpr double m_fRightScale = 1.0/3;
core.git: chart2/source include/oox oox/inc oox/source xmloff/inc
chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx |7 + chart2/source/inc/ChartType.hxx |6 + chart2/source/model/main/Diagram.cxx|8 + chart2/source/model/template/PieChartType.hxx |1 chart2/source/model/template/PieChartTypeTemplate.cxx |3 chart2/source/view/inc/VDataSeries.hxx |6 + chart2/source/view/main/SeriesPlotterContainer.cxx | 10 + chart2/source/view/main/VDataSeries.cxx | 11 ++ include/oox/export/chartexport.hxx |2 oox/inc/drawingml/chart/typegroupcontext.hxx| 14 ++ oox/inc/drawingml/chart/typegroupconverter.hxx |3 oox/source/drawingml/chart/plotareacontext.cxx |3 oox/source/drawingml/chart/typegroupcontext.cxx | 30 + oox/source/drawingml/chart/typegroupconverter.cxx | 28 + oox/source/export/chartexport.cxx | 66 +--- oox/source/token/properties.txt |1 xmloff/inc/xmlprop.hxx |1 17 files changed, 184 insertions(+), 16 deletions(-) New commits: commit 1cda27cf69054b006aa1b16cab8f56339274588b Author: Kurt Nordback AuthorDate: Fri Dec 1 11:18:31 2023 -0700 Commit: Noel Grandin CommitDate: Mon Feb 19 01:29:36 2024 +0100 tdf#50934: OfPie inport from OOXML, plus initial work for export Change-Id: Ie17b583af28d274b3e7817c646dd4f5873e03fef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160733 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 711d3017a8ee..949aaa9a6dae 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -102,6 +103,7 @@ enum PROP_DIAGRAM_SORT_BY_X_VALUES, PROP_DIAGRAM_STARTING_ANGLE, +PROP_DIAGRAM_OF_PIE_TYPE, PROP_DIAGRAM_RIGHT_ANGLED_AXES, PROP_DIAGRAM_PERSPECTIVE, @@ -228,6 +230,11 @@ void lcl_AddPropertiesToVector( cppu::UnoType::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT ); +rOutProperties.emplace_back( "SubPieType", + PROP_DIAGRAM_OF_PIE_TYPE, + cppu::UnoType::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ); //new for 3D charts rOutProperties.emplace_back( "RightAngledAxes", diff --git a/chart2/source/inc/ChartType.hxx b/chart2/source/inc/ChartType.hxx index fa55cf05694f..fccafdb323b6 100644 --- a/chart2/source/inc/ChartType.hxx +++ b/chart2/source/inc/ChartType.hxx @@ -75,6 +75,12 @@ public: // XChartType // still abstract ! implement ! virtual OUString SAL_CALL getChartType() override = 0; +#if 0 +virtual ::com::sun::star::chart2::PieChartSubType SAL_CALL getPieChartSubType() override +{ +return ::com::sun::star::chart2::PieChartSubType_NONE; +} +#endif virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL createCoordinateSystem( ::sal_Int32 DimensionCount ) final override; virtual css::uno::Sequence< OUString > SAL_CALL diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index 2a4b63c73401..1ef884c796f9 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -97,6 +98,7 @@ enum PROP_DIAGRAM_MISSING_VALUE_TREATMENT, PROP_DIAGRAM_3DRELATIVEHEIGHT, PROP_DIAGRAM_DATATABLEHBORDER, +PROP_DIAGRAM_OF_PIE_TYPE, PROP_DIAGRAM_DATATABLEVBORDER, PROP_DIAGRAM_DATATABLEOUTLINE, PROP_DIAGRAM_EXTERNALDATA @@ -183,6 +185,10 @@ void lcl_AddPropertiesToVector( PROP_DIAGRAM_3DRELATIVEHEIGHT, cppu::UnoType::get(), beans::PropertyAttribute::MAYBEVOID ); +rOutProperties.emplace_back( "SubPieType", + PROP_DIAGRAM_OF_PIE_TYPE, + cppu::UnoType::get(), + beans::PropertyAttribute::MAYBEVOID ); rOutProperties.emplace_back( "ExternalData", PROP_DIAGRAM_EXTERNALDATA, cppu::UnoType::get(), @@ -202,6 +208,8 @@ const ::chart::tPropertyValueMap& StaticDiagramDefaults() ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false ); ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_STARTING_ANGLE, 90 );
core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx |5 + 1 file changed, 5 insertions(+) New commits: commit 1036994301de43f5a41134084ca866ed9ec7bf35 Author: Kurt Nordback AuthorDate: Mon Nov 20 11:53:42 2023 -0700 Commit: Noel Grandin CommitDate: Sun Feb 18 10:10:39 2024 +0100 tdf#50934: Add a comment Change-Id: I3986242fa584310acccba4830d8872043381cef6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160732 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 9b1494596598..402857b85cdc 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -996,6 +996,11 @@ void PieChart::createShapes() sal_Int32 nEnd = pDataSrc->getNPoints(pSeries, SubPieType::LEFT); double compFrac = pDataSrc->getData(pSeries, nEnd - 1, SubPieType::LEFT) / aParam.mfLogicYSum; +// The following isn't quite right. The tangent points on the left +// pie are only at pi/2 and -pi/2 for composite wedges over 1/2 the +// total if left and right pies are the same diameter. And the +// threshold of 1/2 isn't quite right either. So there +// really should be a more sophisticated approach here. TODO if (compFrac < 0.5) { // Translated, per below xl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale *
core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx | 83 ++--- 1 file changed, 76 insertions(+), 7 deletions(-) New commits: commit e1573deaf1b2ecd946d23a4ce623546c08036ec7 Author: Kurt Nordback AuthorDate: Mon Nov 20 11:46:10 2023 -0700 Commit: Noel Grandin CommitDate: Sun Feb 18 07:33:18 2024 +0100 tdf#50934: Implement connector lines for pie-of-pie Change-Id: Ifca083aa07b28d5c604382decaefedfe653ff8ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160731 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index a946616ea5fe..9b1494596598 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -928,20 +928,26 @@ void PieChart::createShapes() createOneBar(SubPieType::RIGHT, aParam, xSeriesTarget, xTextTarget, pSeries, pDataSrc, n3DRelativeHeight); -// draw connecting lines +// +// Draw connecting lines +// double xl0, xl1, yl0, yl1, x0, y0, x1, y1, y2, y3; -if (m_aPosHelper.m_fAngleDegreeOffset < 90.0) { +// Get coordinates of "corners" of left composite wedge +sal_Int32 nEnd = pDataSrc->getNPoints(pSeries, SubPieType::LEFT); +double compFrac = pDataSrc->getData(pSeries, nEnd - 1, +SubPieType::LEFT) / aParam.mfLogicYSum; +if (compFrac < 0.5) { xl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale * -cos(m_aPosHelper.m_fAngleDegreeOffset * M_PI / 180) + -m_fLeftShift; +cos(compFrac * M_PI) + m_fLeftShift; yl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale * -sin(m_aPosHelper.m_fAngleDegreeOffset * M_PI / 180); +sin(compFrac * M_PI); } else { xl0 = m_fLeftShift; yl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale; } +// Coordinates of bar top left corner xl1 = m_fBarLeft; yl1 = m_fFullBarHeight / 2; @@ -974,12 +980,75 @@ void PieChart::createShapes() break; } case PieChartSubType_PIE: +{ pDataSrc = createOneRing(SubPieType::LEFT, 0, aParam, xSeriesTarget, xTextTarget, pSeries, pDataSrc, n3DRelativeHeight); createOneRing(SubPieType::RIGHT, 0, aParam, xSeriesTarget, xTextTarget, pSeries, pDataSrc, n3DRelativeHeight); + +// +// Draw connecting lines +// +double xl0, xl1, yl0, yl1, x0, y0, x1, y1, y2, y3; + +// Get coordinates of "corners" of left composite wedge +sal_Int32 nEnd = pDataSrc->getNPoints(pSeries, SubPieType::LEFT); +double compFrac = pDataSrc->getData(pSeries, nEnd - 1, +SubPieType::LEFT) / aParam.mfLogicYSum; +if (compFrac < 0.5) { +// Translated, per below +xl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale * +cos(compFrac * M_PI) + m_fLeftShift - m_fRightShift; +yl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale * +sin(compFrac * M_PI); +} else { +// Translated, per below +xl0 = m_fLeftShift - m_fRightShift; +yl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale; +} + +// Compute tangent point on the right-hand circle of the line +// through (xl0, yl0). If we translate things so the right-hand +// circle is centered on the origin, then this point (x,y) +// satisfies these two equations, where r is the radius of the +// right-hand circle: +// (1) x^2 + y^2 = r^2 +// (2) (y - yl0) / (x - xl0) = -x / y +const double r = aParam.mfUnitCircleOuterRadius * m_fRightScale; + +xl1 = (r*r * xl0 + yl0 * r * sqrt(xl0*xl0 + yl0*yl0 - r*r)) / +(xl0*xl0 + yl0*yl0); +yl1 = sqrt(r*r - xl1*xl1); + +// Now translate back to the coordinates we use +xl0 += m_fRightShift; +xl1 += m_fRightShift; + +x0 = m_aPosHelper.transformUnitCircleToScene(0, xl0, 0).PositionX; +y0 = m_aPosHelper.transformUnitCircleToScene(90, yl0, 0).PositionY; +x1 = m_aPosHelper.transformUnitCircleToScene(0, xl1, 0).PositionX; +y1 = m_aPosHelper.transformUnitCircleToScene(90, yl1, 0).PositionY; +y2 = m_aPosHelper.transformUnitCircleToScene(90, -yl0, 0).PositionY; +y3 = m_aPosHelper.transformUnitCircleToScene(90, -yl1, 0).PositionY; + +std::vector> linePts; +linePts.resize(2); +
core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx | 19 --- 1 file changed, 12 insertions(+), 7 deletions(-) New commits: commit 5d0093e8c3a862172ca96081d68e7757dfdf6067 Author: Kurt Nordback AuthorDate: Sat Nov 18 19:43:52 2023 -0700 Commit: Noel Grandin CommitDate: Sat Feb 17 18:00:49 2024 +0100 tdf#50934: Improvements to fill color for of-pie composite wedge Change-Id: Ib9f7e3b135bb86e1817edf97b963e3620af7fdf2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160730 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index c3d36cd186fb..a946616ea5fe 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -227,7 +227,6 @@ PieChart::~PieChart() void PieChart::setScales( std::vector< ExplicitScaleData >&& rScales, bool /* bSwapXAndYAxis */ ) { OSL_ENSURE(m_nDimension<=static_cast(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence"); -m_aCartesianScales = m_pPosHelper->getScales(); m_aPosHelper.setScales( std::move(rScales), true ); } @@ -1104,17 +1103,23 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, xPointProperties, aParam, nRingPtCnt, bConcentricExplosion); +// Handle coloring of the composite wedge +sal_Int32 nEnd = pDataSrc->getNPoints(pSeries, eType); +const sal_Int32 nPropIdx = ( +eType == SubPieType::LEFT && nPointIndex == nEnd - 1 ? +pSeries->getTotalPointCount() : +nPointIndex); ///point color: if (!pSeries->hasPointOwnColor(nPointIndex) && m_xColorScheme.is()) { xPointShape->setPropertyValue("FillColor", -uno::Any(m_xColorScheme->getColorByIndex( nPointIndex ))); +uno::Any(m_xColorScheme->getColorByIndex( nPropIdx ))); } if(bHasFillColorMapping) { -double nPropVal = pSeries->getValueByProperty(nPointIndex, "FillColor"); +double nPropVal = pSeries->getValueByProperty(nPropIdx, "FillColor"); if(!std::isnan(nPropVal)) { xPointShape->setPropertyValue("FillColor", uno::Any(static_cast( nPropVal))); @@ -2106,16 +2111,16 @@ uno::Reference< beans::XPropertySet > OfPieDataSrc::getProps( const VDataSeries* pSeries, sal_Int32 nPtIdx, enum SubPieType eType) const { -const sal_Int32 n = pSeries->getTotalPointCount() - 3; +const sal_Int32 nPts = pSeries->getTotalPointCount(); +const sal_Int32 n = nPts - 3; if (eType == SubPieType::LEFT) { // nPtIdx should be in [0, n] if (nPtIdx < n) { return pSeries->getPropertiesOfPoint( nPtIdx ); } else { -assert(nPtIdx == n); // The aggregated wedge -// Not sure what to do here, but this isn't right. TODO -return pSeries->getPropertiesOfPoint(n); +assert(nPtIdx == n); +return pSeries->getPropertiesOfPoint(nPts); } } else { assert(eType == SubPieType::RIGHT);
core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx | 46 + 1 file changed, 46 insertions(+) New commits: commit 4df39957bd985af591f452439c8aa5fc5c7a0d62 Author: Kurt Nordback AuthorDate: Thu Nov 16 17:09:11 2023 -0700 Commit: Noel Grandin CommitDate: Sat Feb 17 07:08:20 2024 +0100 tdf#50934: Ensure of-pie connector lines are black Change-Id: I0548b395455eb17ec06f85ffce63affa15075391 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160729 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index b74a5365374a..c3d36cd186fb 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -922,12 +922,58 @@ void PieChart::createShapes() xTextTarget, pSeries, pDataSrc, n3DRelativeHeight); break; case PieChartSubType_BAR: +{ pDataSrc = createOneRing(SubPieType::LEFT, 0, aParam, xSeriesTarget, xTextTarget, pSeries, pDataSrc, n3DRelativeHeight); createOneBar(SubPieType::RIGHT, aParam, xSeriesTarget, xTextTarget, pSeries, pDataSrc, n3DRelativeHeight); + +// draw connecting lines +double xl0, xl1, yl0, yl1, x0, y0, x1, y1, y2, y3; + +if (m_aPosHelper.m_fAngleDegreeOffset < 90.0) { +xl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale * +cos(m_aPosHelper.m_fAngleDegreeOffset * M_PI / 180) + +m_fLeftShift; +yl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale * +sin(m_aPosHelper.m_fAngleDegreeOffset * M_PI / 180); +} else { +xl0 = m_fLeftShift; +yl0 = aParam.mfUnitCircleOuterRadius * m_fLeftScale; +} + +xl1 = m_fBarLeft; +yl1 = m_fFullBarHeight / 2; + +x0 = m_aPosHelper.transformUnitCircleToScene(0, xl0, 0).PositionX; +y0 = m_aPosHelper.transformUnitCircleToScene(90, yl0, 0).PositionY; +x1 = m_aPosHelper.transformUnitCircleToScene(0, xl1, 0).PositionX; +y1 = m_aPosHelper.transformUnitCircleToScene(90, yl1, 0).PositionY; +y2 = m_aPosHelper.transformUnitCircleToScene(90, -yl0, 0).PositionY; +y3 = m_aPosHelper.transformUnitCircleToScene(90, -yl1, 0).PositionY; + +std::vector> linePts; +linePts.resize(2); +linePts[0].push_back(css::drawing::Position3D(x0, y0, aParam.mfLogicZ)); +linePts[0].push_back(css::drawing::Position3D(x1, y1, aParam.mfLogicZ)); +linePts[1].push_back(css::drawing::Position3D(x0, y2, aParam.mfLogicZ)); +linePts[1].push_back(css::drawing::Position3D(x1, y3, aParam.mfLogicZ)); + +VLineProperties aVLineProperties; // default black + +//create line +rtl::Reference xSeriesGroupShape_Shapes = +getSeriesGroupShape(pSeries, xSeriesTarget); +rtl::Reference xShape = ShapeFactory::createLine2D( +xSeriesGroupShape_Shapes, linePts, ); + +// need to set properties? +//PropertyMapper::setMappedProperties( *xShape, xObjectProperties, +// PropertyMapper::getPropertyNameMapForLineSeriesProperties() ); + break; +} case PieChartSubType_PIE: pDataSrc = createOneRing(SubPieType::LEFT, 0, aParam, xSeriesTarget,
core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx | 68 - chart2/source/view/charttypes/PieChart.hxx | 28 +++ 2 files changed, 39 insertions(+), 57 deletions(-) New commits: commit 756f8c850a38679e5b1b8c68c4c2ea5fe4883fbd Author: Kurt Nordback AuthorDate: Thu Nov 16 16:45:19 2023 -0700 Commit: Noel Grandin CommitDate: Sat Feb 17 07:07:39 2024 +0100 tdf#50934: Initial implementation of connector lines for bar-of-pie Change-Id: I586dd5ae784f5e86ad1e0d863765b058873eac68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160728 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index ed20a65fc0ca..b74a5365374a 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -952,24 +952,11 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, { bool bHasFillColorMapping = pSeries->hasPropertyMapping("FillColor"); -/// The angle degree offset is set by the same property of the -/// data series. -/// Counter-clockwise offset from the 3 o'clock position. -m_aPosHelper.m_fAngleDegreeOffset = pSeries->getStartingAngle(); - -///the `explodeable` ring is the first one except when the radius axis -///orientation is reversed (always!?) and we are dealing with a donut: in -///such a case the `explodeable` ring is the last one. -std::vector< VDataSeriesGroup >::size_type nExplodeableSlot = 0; -if( m_aPosHelper.isMathematicalOrientationRadius() && m_bUseRings ) -nExplodeableSlot = m_aZSlots.front().size()-1; - -sal_Int32 nBegin = pDataSrc->getBeginIndex(pSeries, eType); -sal_Int32 nEnd = pDataSrc->getEndIndex(pSeries, eType); +sal_Int32 nRingPtCnt = pDataSrc->getNPoints(pSeries, eType); // Find sum of entries for this ring or sub-pie double ringSum = 0; -for (sal_Int32 nPointIndex = nBegin; nPointIndex < nEnd; nPointIndex++ ) { +for (sal_Int32 nPointIndex = 0; nPointIndex < nRingPtCnt; nPointIndex++ ) { double fY = pDataSrc->getData(pSeries, nPointIndex, eType); if (!std::isnan(fY) ) ringSum += fY; } @@ -981,7 +968,7 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, // Left of-pie has the "composite" wedge (the one expanded in the right // subgraph) facing to the right in the chart, to allow the expansion // lines to meet it -double compositeVal = pDataSrc->getData(pSeries, nEnd - 1, eType); +double compositeVal = pDataSrc->getData(pSeries, nRingPtCnt - 1, eType); return compositeVal * 360 / (ringSum * 2); } else { /// The angle degree offset is set by the same property of the @@ -993,9 +980,16 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, m_aPosHelper.m_fAngleDegreeOffset = sAngle(); +///the `explodeable` ring is the first one except when the radius axis +///orientation is reversed (always!?) and we are dealing with a donut: in +///such a case the `explodeable` ring is the last one. +std::vector< VDataSeriesGroup >::size_type nExplodeableSlot = 0; +if( m_aPosHelper.isMathematicalOrientationRadius() && m_bUseRings ) +nExplodeableSlot = m_aZSlots.front().size()-1; + double fLogicYForNextPoint = 0.0; ///iterate through all points to create shapes -for(sal_Int32 nPointIndex = nBegin; nPointIndex < nEnd; nPointIndex++ ) +for(sal_Int32 nPointIndex = 0; nPointIndex < nRingPtCnt; nPointIndex++ ) { double fLogicInnerRadius, fLogicOuterRadius; @@ -1061,7 +1055,8 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, const bool bConcentricExplosion = m_bUseRings && (m_aZSlots.front().size() > 1); rtl::Reference xPointShape = createDataPoint(eType, xSeriesGroupShape_Shapes, -xPointProperties, aParam, nEnd, bConcentricExplosion); +xPointProperties, aParam, nRingPtCnt, +bConcentricExplosion); ///point color: if (!pSeries->hasPointOwnColor(nPointIndex) && m_xColorScheme.is()) @@ -1134,12 +1129,11 @@ void PieChart::createOneBar( { bool bHasFillColorMapping = pSeries->hasPropertyMapping("FillColor"); -sal_Int32 nBegin = pDataSrc->getBeginIndex(pSeries, eType); -sal_Int32 nEnd = pDataSrc->getEndIndex(pSeries, eType); +sal_Int32 nBarPtCnt = pDataSrc->getNPoints(pSeries, eType); // Find sum of entries for this bar chart double barSum = 0; -for (sal_Int32 nPointIndex = nBegin; nPointIndex < nEnd; nPointIndex++ ) { +for (sal_Int32 nPointIndex = 0; nPointIndex < nBarPtCnt; nPointIndex++ ) { double fY = pDataSrc->getData(pSeries, nPointIndex, eType); if (!std::isnan(fY) ) barSum
core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx | 49 - chart2/source/view/charttypes/PieChart.hxx | 14 +--- 2 files changed, 45 insertions(+), 18 deletions(-) New commits: commit 853736f0d523c4f5459e15e7e109e81340f8c25e Author: Kurt Nordback AuthorDate: Wed Nov 15 16:49:41 2023 -0700 Commit: Noel Grandin CommitDate: Sat Feb 17 07:06:56 2024 +0100 tdf#50934: Fix of-pie subchart colors Change-Id: I43e0118786853b0258741e5181f7e622c6f747ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160727 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index aee48da35084..ed20a65fc0ca 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -964,11 +964,12 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, if( m_aPosHelper.isMathematicalOrientationRadius() && m_bUseRings ) nExplodeableSlot = m_aZSlots.front().size()-1; -sal_Int32 nRingPtCnt = pDataSrc->getNPoints(pSeries, eType); +sal_Int32 nBegin = pDataSrc->getBeginIndex(pSeries, eType); +sal_Int32 nEnd = pDataSrc->getEndIndex(pSeries, eType); // Find sum of entries for this ring or sub-pie double ringSum = 0; -for (sal_Int32 nPointIndex = 0; nPointIndex < nRingPtCnt; nPointIndex++ ) { +for (sal_Int32 nPointIndex = nBegin; nPointIndex < nEnd; nPointIndex++ ) { double fY = pDataSrc->getData(pSeries, nPointIndex, eType); if (!std::isnan(fY) ) ringSum += fY; } @@ -980,7 +981,7 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, // Left of-pie has the "composite" wedge (the one expanded in the right // subgraph) facing to the right in the chart, to allow the expansion // lines to meet it -double compositeVal = pDataSrc->getData(pSeries, nRingPtCnt - 1, eType); +double compositeVal = pDataSrc->getData(pSeries, nEnd - 1, eType); return compositeVal * 360 / (ringSum * 2); } else { /// The angle degree offset is set by the same property of the @@ -994,7 +995,7 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, double fLogicYForNextPoint = 0.0; ///iterate through all points to create shapes -for(sal_Int32 nPointIndex = 0; nPointIndex < nRingPtCnt; nPointIndex++ ) +for(sal_Int32 nPointIndex = nBegin; nPointIndex < nEnd; nPointIndex++ ) { double fLogicInnerRadius, fLogicOuterRadius; @@ -1060,8 +1061,7 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, const bool bConcentricExplosion = m_bUseRings && (m_aZSlots.front().size() > 1); rtl::Reference xPointShape = createDataPoint(eType, xSeriesGroupShape_Shapes, -xPointProperties, aParam, nRingPtCnt, -bConcentricExplosion); +xPointProperties, aParam, nEnd, bConcentricExplosion); ///point color: if (!pSeries->hasPointOwnColor(nPointIndex) && m_xColorScheme.is()) @@ -1134,11 +1134,12 @@ void PieChart::createOneBar( { bool bHasFillColorMapping = pSeries->hasPropertyMapping("FillColor"); -sal_Int32 nBarPtCnt = pDataSrc->getNPoints(pSeries, eType); +sal_Int32 nBegin = pDataSrc->getBeginIndex(pSeries, eType); +sal_Int32 nEnd = pDataSrc->getEndIndex(pSeries, eType); // Find sum of entries for this bar chart double barSum = 0; -for (sal_Int32 nPointIndex = 0; nPointIndex < nBarPtCnt; nPointIndex++ ) { +for (sal_Int32 nPointIndex = nBegin; nPointIndex < nEnd; nPointIndex++ ) { double fY = pDataSrc->getData(pSeries, nPointIndex, eType); if (!std::isnan(fY) ) barSum += fY; } @@ -1146,7 +1147,7 @@ void PieChart::createOneBar( double fBarBottom = 0.0; double fBarTop = -0.5; // make the bar go from -0.5 to 0.5 ///iterate through all points to create shapes -for(sal_Int32 nPointIndex = 0; nPointIndex < nBarPtCnt; nPointIndex++ ) +for(sal_Int32 nPointIndex = nBegin; nPointIndex < nEnd; nPointIndex++ ) { aParam.mfDepth = getTransformedDepth() * (n3DRelativeHeight / 100.0); @@ -2005,7 +2006,14 @@ double PieDataSrc::getData(const VDataSeries* pSeries, sal_Int32 nPtIdx, return fabs(pSeries->getYValue( nPtIdx )); } -sal_Int32 PieDataSrc::getNPoints(const VDataSeries* pSeries, +sal_Int32 PieDataSrc::getBeginIndex([[maybe_unused]]const VDataSeries* pSeries, +[[maybe_unused]] enum SubPieType eType) const +{ +assert(eType == SubPieType::NONE); +return 0; +} + +sal_Int32 PieDataSrc::getEndIndex(const VDataSeries* pSeries, [[maybe_unused]] enum SubPieType eType) const { assert(eType == SubPieType::NONE); @@ -2030,14 +2038,25 @@ uno::Reference<
core.git: 2 commits - chart2/source download.lst
chart2/source/view/charttypes/PieChart.cxx | 144 - chart2/source/view/charttypes/PieChart.hxx | 26 - download.lst |4 3 files changed, 166 insertions(+), 8 deletions(-) New commits: commit e9658eaa17591e9d1e380054da27ab6c5734f9af Author: Kurt Nordback AuthorDate: Tue Nov 14 22:10:06 2023 -0700 Commit: Noel Grandin CommitDate: Fri Feb 16 09:18:35 2024 +0100 tdf#50934: Implementation of bar-of-pie, plus minor of-pie fixes Change-Id: Ib343953ee30124524884859c8fe9e88d2dc7d822 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160726 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 0424130c8d5e..aee48da35084 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -227,6 +227,7 @@ PieChart::~PieChart() void PieChart::setScales( std::vector< ExplicitScaleData >&& rScales, bool /* bSwapXAndYAxis */ ) { OSL_ENSURE(m_nDimension<=static_cast(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence"); +m_aCartesianScales = m_pPosHelper->getScales(); m_aPosHelper.setScales( std::move(rScales), true ); } @@ -333,6 +334,50 @@ rtl::Reference PieChart::createDataPoint( return xShape; } +rtl::Reference PieChart::createBarDataPoint( +const rtl::Reference& xTarget, +const uno::Reference& xObjectProperties, +const ShapeParam& rParam, +double fBarSegBottom, double fBarSegTop) +{ +drawing::Position3D aP0, aP1; + +// Draw the bar for bar-of-pie small and to the right. Width and +// position are hard-coded for now. + +#if 0 +aP0 = cartesianPosHelper.transformLogicToScene(0.75, fBarSegBottom, +rParam.mfLogicZ, false); +aP1 = cartesianPosHelper.transformLogicToScene(1.25, fBarSegTop, +rParam.mfLogicZ, false); +#else +double x0 = m_aPosHelper.transformUnitCircleToScene(0, 0.75, 0).PositionX; +double x1 = m_aPosHelper.transformUnitCircleToScene(0, 1.25, 0).PositionX; +double y0 = m_aPosHelper.transformUnitCircleToScene( +90, fBarSegBottom, 0).PositionY; +double y1 = m_aPosHelper.transformUnitCircleToScene( +90, fBarSegTop, 0).PositionY; + +aP0 = drawing::Position3D(x0, y0, rParam.mfLogicZ); +aP1 = drawing::Position3D(x1, y1, rParam.mfLogicZ); +#endif + +const css::awt::Point aPos(aP0.PositionX, aP1.PositionY); +const css::awt::Size aSz(fabs(aP0.PositionX - aP1.PositionX), +fabs(aP0.PositionY - aP1.PositionY)); + +const tNameSequence emptyNameSeq; +const tAnySequence emptyValSeq; +//create point +rtl::Reference xShape = ShapeFactory::createRectangle( +xTarget, +aSz, aPos, +emptyNameSeq, emptyValSeq); + +PropertyMapper::setMappedProperties( *xShape, xObjectProperties, PropertyMapper::getPropertyNameMapForFilledSeriesProperties() ); +return xShape; +} + void PieChart::createTextLabelShape( const rtl::Reference& xTextTarget, VDataSeries& rSeries, sal_Int32 nPointIndex, ShapeParam& rParam ) @@ -880,6 +925,8 @@ void PieChart::createShapes() pDataSrc = createOneRing(SubPieType::LEFT, 0, aParam, xSeriesTarget, xTextTarget, pSeries, pDataSrc, n3DRelativeHeight); +createOneBar(SubPieType::RIGHT, aParam, xSeriesTarget, +xTextTarget, pSeries, pDataSrc, n3DRelativeHeight); break; case PieChartSubType_PIE: pDataSrc = @@ -926,6 +973,25 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, if (!std::isnan(fY) ) ringSum += fY; } +// determine the starting angle around the ring +auto sAngle = [&]() +{ +if (eType == SubPieType::LEFT) { +// Left of-pie has the "composite" wedge (the one expanded in the right +// subgraph) facing to the right in the chart, to allow the expansion +// lines to meet it +double compositeVal = pDataSrc->getData(pSeries, nRingPtCnt - 1, eType); +return compositeVal * 360 / (ringSum * 2); +} else { +/// The angle degree offset is set by the same property of the +/// data series. +/// Counter-clockwise offset from the 3 o'clock position. +return static_cast(pSeries->getStartingAngle()); +} +}; + +m_aPosHelper.m_fAngleDegreeOffset = sAngle(); + double fLogicYForNextPoint = 0.0; ///iterate through all points to create shapes for(sal_Int32 nPointIndex = 0; nPointIndex < nRingPtCnt; nPointIndex++ ) @@ -1057,6 +1123,81 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, }//next category } +void PieChart::createOneBar( +enum SubPieType eType, +
core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx | 148 + chart2/source/view/charttypes/PieChart.hxx | 80 ++- 2 files changed, 205 insertions(+), 23 deletions(-) New commits: commit 63562694beb42b86d0f00dd3c18ac47bb094c9fe Author: Kurt Nordback AuthorDate: Tue Oct 31 20:29:34 2023 -0600 Commit: Noel Grandin CommitDate: Fri Feb 16 08:07:12 2024 +0100 tdf#50934: Implement PieDataSrc and related structure Change-Id: I6affb326600d77ddf756d9bc223e7dcc29f87d23 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160725 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 201e226119ab..0424130c8d5e 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -855,20 +855,38 @@ void PieChart::createShapes() aParam.mfLogicYSum += fabs(fY); } -if (aParam.mfLogicYSum == 0.0) +if (aParam.mfLogicYSum == 0.0) { // Total sum of all Y values in this series is zero. Skip the whole series. continue; +} + +PieDataSrcBase *pDataSrc = nullptr; +PieDataSrc normalPieSrc; +OfPieDataSrc ofPieSrc; + +// Default to regular pie if too few points for of-pie +::css::chart2::PieChartSubType eSubType = +nPointCount >= OfPieDataSrc::minPoints() ? +m_eSubType : +PieChartSubType_NONE; -switch (m_eSubType) { +switch (eSubType) { case PieChartSubType_NONE: -createOneRing(SubPieType::NONE, fSlotX, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); +pDataSrc = +createOneRing(SubPieType::NONE, fSlotX, aParam, xSeriesTarget, +xTextTarget, pSeries, pDataSrc, n3DRelativeHeight); break; case PieChartSubType_BAR: -createOneRing(SubPieType::LEFT, 0, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); +pDataSrc = +createOneRing(SubPieType::LEFT, 0, aParam, xSeriesTarget, +xTextTarget, pSeries, pDataSrc, n3DRelativeHeight); break; case PieChartSubType_PIE: -createOneRing(SubPieType::LEFT, 0, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); -createOneRing(SubPieType::RIGHT, 0, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); +pDataSrc = +createOneRing(SubPieType::LEFT, 0, aParam, xSeriesTarget, +xTextTarget, pSeries, pDataSrc, n3DRelativeHeight); +createOneRing(SubPieType::RIGHT, 0, aParam, xSeriesTarget, +xTextTarget, pSeries, pDataSrc, n3DRelativeHeight); break; default: assert(false); // this shouldn't happen @@ -882,6 +900,7 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, const rtl::Reference& xSeriesTarget, const rtl::Reference& xTextTarget, VDataSeries* pSeries, +const PieDataSrcBase *pDataSrc, sal_Int32 n3DRelativeHeight) { bool bHasFillColorMapping = pSeries->hasPropertyMapping("FillColor"); @@ -891,10 +910,6 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, /// Counter-clockwise offset from the 3 o'clock position. m_aPosHelper.m_fAngleDegreeOffset = pSeries->getStartingAngle(); -///iterate through all points to get the sum of all entries of -///the current data series -sal_Int32 nPointCount=pSeries->getTotalPointCount(); - ///the `explodeable` ring is the first one except when the radius axis ///orientation is reversed (always!?) and we are dealing with a donut: in ///such a case the `explodeable` ring is the last one. @@ -902,9 +917,18 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, if( m_aPosHelper.isMathematicalOrientationRadius() && m_bUseRings ) nExplodeableSlot = m_aZSlots.front().size()-1; +sal_Int32 nRingPtCnt = pDataSrc->getNPoints(pSeries, eType); + +// Find sum of entries for this ring or sub-pie +double ringSum = 0; +for (sal_Int32 nPointIndex = 0; nPointIndex < nRingPtCnt; nPointIndex++ ) { +double fY = pDataSrc->getData(pSeries, nPointIndex, eType); +if (!std::isnan(fY) ) ringSum += fY; +} + double fLogicYForNextPoint = 0.0; ///iterate through all points to create shapes -for(sal_Int32 nPointIndex = 0; nPointIndex < nPointCount; nPointIndex++ ) +for(sal_Int32 nPointIndex = 0; nPointIndex < nRingPtCnt; nPointIndex++ ) { double fLogicInnerRadius, fLogicOuterRadius; @@ -923,8 +947,9 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, aParam.mfDepth = getTransformedDepth() * (n3DRelativeHeight / 100.0);
core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx | 37 + chart2/source/view/charttypes/PieChart.hxx |1 2 files changed, 28 insertions(+), 10 deletions(-) New commits: commit 8da681e5ef48606716219b2a4919ee90bf7a0d6b Author: Kurt Nordback AuthorDate: Tue Sep 26 15:23:52 2023 -0600 Commit: Noel Grandin CommitDate: Thu Feb 15 20:26:24 2024 +0100 tdf#50934: Some rejiggering of of-pie code, plus implementing subpie chart Change-Id: I91fca31db0eb0bfb673e77f1369abe110fe405b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160724 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 49cf48de3f05..201e226119ab 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -243,6 +243,7 @@ bool PieChart::shouldSnapRectToUsedArea() } rtl::Reference PieChart::createDataPoint( +const SubPieType e_subType, const rtl::Reference& xTarget, const uno::Reference& xObjectProperties, const ShapeParam& rParam, @@ -286,12 +287,28 @@ rtl::Reference PieChart::createDataPoint( drawing::Position3D aNewOrigin = m_aPosHelper.transformUnitCircleToScene(fAngle, fRadius, rParam.mfLogicZ); aOffset = aNewOrigin - aOrigin; } -} else if (m_eSubType != PieChartSubType_NONE) { -// Draw the main pie for bar-of-pie/pie-of-pie smaller and to the left -drawing::Position3D aOrigin = m_aPosHelper.transformUnitCircleToScene(0, 0, rParam.mfLogicZ); -drawing::Position3D aNewOrigin = m_aPosHelper.transformUnitCircleToScene(180, 1.0, rParam.mfLogicZ); -aOffset = aNewOrigin - aOrigin; -fExplodedOuterRadius *= 2.0/3; +} else { +drawing::Position3D aOrigin, aNewOrigin; +switch (e_subType) { +case SubPieType::LEFT: +// Draw the main pie for bar-of-pie/pie-of-pie smaller and to the left +aOrigin = m_aPosHelper.transformUnitCircleToScene(0, 0, rParam.mfLogicZ); +aNewOrigin = m_aPosHelper.transformUnitCircleToScene(180, 0.75, rParam.mfLogicZ); +aOffset = aNewOrigin - aOrigin; +fExplodedOuterRadius *= 2.0/3; +break; +case SubPieType::RIGHT: +// Draw the sub-pie for pie-of-pie much smaller and to the right +aOrigin = m_aPosHelper.transformUnitCircleToScene(0, 0, rParam.mfLogicZ); +aNewOrigin = m_aPosHelper.transformUnitCircleToScene(0, 0.75, rParam.mfLogicZ); +aOffset = aNewOrigin - aOrigin; +fExplodedOuterRadius *= 1.0/3; +break; +case SubPieType::NONE: +default: +// no change +break; +} } @@ -847,10 +864,11 @@ void PieChart::createShapes() createOneRing(SubPieType::NONE, fSlotX, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); break; case PieChartSubType_BAR: -createOneRing(SubPieType::LEFT, fSlotX, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); +createOneRing(SubPieType::LEFT, 0, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); break; case PieChartSubType_PIE: -createOneRing(SubPieType::LEFT, fSlotX, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); +createOneRing(SubPieType::LEFT, 0, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); +createOneRing(SubPieType::RIGHT, 0, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); break; default: assert(false); // this shouldn't happen @@ -949,8 +967,7 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, // Do concentric explosion if it's a donut chart with more than one series const bool bConcentricExplosion = m_bUseRings && (m_aZSlots.front().size() > 1); rtl::Reference xPointShape = -createDataPoint( -xSeriesGroupShape_Shapes, xPointProperties, aParam, nPointCount, +createDataPoint(eType, xSeriesGroupShape_Shapes, xPointProperties, aParam, nPointCount, bConcentricExplosion); ///point color: diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx index 5c04ee05cf86..0517c87d67cd 100644 --- a/chart2/source/view/charttypes/PieChart.hxx +++ b/chart2/source/view/charttypes/PieChart.hxx @@ -84,6 +84,7 @@ public: private: //methods rtl::Reference createDataPoint( +enum SubPieType eType, const rtl::Reference& xTarget, const css::uno::Reference& xObjectProperties, const ShapeParam& rParam,
core.git: chart2/source
chart2/source/view/charttypes/PieChart.cxx | 286 - chart2/source/view/charttypes/PieChart.hxx | 14 + 2 files changed, 173 insertions(+), 127 deletions(-) New commits: commit d81c98623b2abb991ca696b3b09011f6bb3de673 Author: Kurt Nordback AuthorDate: Fri Sep 1 16:13:15 2023 -0600 Commit: Noel Grandin CommitDate: Wed Feb 14 07:58:41 2024 +0100 tdf#50934: Restructuring for of-pie charts Change-Id: I9682c314efb888d57e94f82f084cc6d0825a4408 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160723 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 0f924de7c5ab..49cf48de3f05 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -790,13 +790,6 @@ void PieChart::createShapes() ///the angle axis scale range is [0, 1]. The max_offset parameter is used ///for exploded pie chart and its value is 0.5. -///the `explodeable` ring is the first one except when the radius axis -///orientation is reversed (always!?) and we are dealing with a donut: in -///such a case the `explodeable` ring is the last one. -std::vector< VDataSeriesGroup >::size_type nExplodeableSlot = 0; -if( m_aPosHelper.isMathematicalOrientationRadius() && m_bUseRings ) -nExplodeableSlot = m_aZSlots.front().size()-1; - m_aLabelInfoList.clear(); m_fMaxOffset = std::numeric_limits::quiet_NaN(); sal_Int32 n3DRelativeHeight = 100; @@ -815,8 +808,6 @@ void PieChart::createShapes() ///(m_bUseRings||fSlotX<0.5) for( double fSlotX=0; aXSlotIter != aXSlotEnd && (m_bUseRings||fSlotX<0.5 ); ++aXSlotIter, fSlotX+=1.0 ) { -ShapeParam aParam; - std::vector< std::unique_ptr >* pSeriesList = &(aXSlotIter->m_aSeriesVector); if(pSeriesList->empty())//there should be only one series in each x slot continue; @@ -824,8 +815,6 @@ void PieChart::createShapes() if(!pSeries) continue; -bool bHasFillColorMapping = pSeries->hasPropertyMapping("FillColor"); - /// The angle degree offset is set by the same property of the /// data series. /// Counter-clockwise offset from the 3 o'clock position. @@ -835,6 +824,8 @@ void PieChart::createShapes() ///the current data series sal_Int32 nPointIndex=0; sal_Int32 nPointCount=pSeries->getTotalPointCount(); +ShapeParam aParam; + for( nPointIndex = 0; nPointIndex < nPointCount; nPointIndex++ ) { double fY = pSeries->getYValue( nPointIndex ); @@ -851,134 +842,175 @@ void PieChart::createShapes() // Total sum of all Y values in this series is zero. Skip the whole series. continue; -double fLogicYForNextPoint = 0.0; -///iterate through all points to create shapes -for( nPointIndex = 0; nPointIndex < nPointCount; nPointIndex++ ) -{ -double fLogicInnerRadius, fLogicOuterRadius; - -///compute the maximum relative distance offset of the current slice -///from the pie center -///it is worth noting that after the first invocation the maximum -///offset value is cached, so it is evaluated only once per each -///call to `createShapes` -double fOffset = getMaxOffset(); - -///compute the outer and the inner radius for the current ring slice -bool bIsVisible = m_aPosHelper.getInnerAndOuterRadius( fSlotX+1.0, fLogicInnerRadius, fLogicOuterRadius, m_bUseRings, fOffset ); -if( !bIsVisible ) -continue; +switch (m_eSubType) { +case PieChartSubType_NONE: +createOneRing(SubPieType::NONE, fSlotX, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); +break; +case PieChartSubType_BAR: +createOneRing(SubPieType::LEFT, fSlotX, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); +break; +case PieChartSubType_PIE: +createOneRing(SubPieType::LEFT, fSlotX, aParam, xSeriesTarget, xTextTarget, pSeries, n3DRelativeHeight); +break; +default: +assert(false); // this shouldn't happen +} +}//next x slot +} -aParam.mfDepth = getTransformedDepth() * (n3DRelativeHeight / 100.0); +void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType, +double fSlotX, +ShapeParam& aParam, +const rtl::Reference& xSeriesTarget, +const rtl::Reference& xTextTarget, +VDataSeries* pSeries, +sal_Int32 n3DRelativeHeight) +{ +bool bHasFillColorMapping = pSeries->hasPropertyMapping("FillColor"); -rtl::Reference xSeriesGroupShape_Shapes = getSeriesGroupShape(pSeries, xSeriesTarget); -
core.git: chart2/source
chart2/source/model/template/ChartTypeTemplate.cxx |8 +++- chart2/source/view/charttypes/PieChart.cxx |1 + 2 files changed, 8 insertions(+), 1 deletion(-) New commits: commit 800b767f13d4fe9c7e7fc3271427a7193e17dbb6 Author: Kurt Nordback AuthorDate: Thu Aug 31 18:39:02 2023 -0600 Commit: Noel Grandin CommitDate: Fri Feb 9 11:03:22 2024 +0100 tdf#50934: Ensure BarOfPie has ScaleData::ShiftedCategoryPosition == false Change-Id: I86c7ba4df89a1350f544345938a29c210903c06d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160722 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index 670391422a85..e91eab13e4e9 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -571,7 +571,13 @@ void ChartTypeTemplate::adaptScales( rtl::Reference< ChartType > xChartType = getChartTypeForNewSeries2({}); if( aData.AxisType == AxisType::CATEGORY ) { -aData.ShiftedCategoryPosition = m_aServiceName.indexOf("Column") != -1 || m_aServiceName.indexOf("Bar") != -1 || m_aServiceName.endsWith("Close"); +// Shift for Column, Hi-Lo-Close, and regular +// Bar types, but not BarOfPie +aData.ShiftedCategoryPosition = +m_aServiceName.indexOf("Column") != -1 || +(m_aServiceName.indexOf("Bar") != -1 && + !m_aServiceName.indexOf("BarOfPie")) || +m_aServiceName.endsWith("Close"); } bool bSupportsDates = ::chart::ChartTypeHelper::isSupportingDateAxis( xChartType, nDimensionX ); if( aData.AxisType != AxisType::CATEGORY && ( aData.AxisType != AxisType::DATE || !bSupportsDates) ) diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 7aeb18d2f6e3..0f924de7c5ab 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -287,6 +287,7 @@ rtl::Reference PieChart::createDataPoint( aOffset = aNewOrigin - aOrigin; } } else if (m_eSubType != PieChartSubType_NONE) { +// Draw the main pie for bar-of-pie/pie-of-pie smaller and to the left drawing::Position3D aOrigin = m_aPosHelper.transformUnitCircleToScene(0, 0, rParam.mfLogicZ); drawing::Position3D aNewOrigin = m_aPosHelper.transformUnitCircleToScene(180, 1.0, rParam.mfLogicZ); aOffset = aNewOrigin - aOrigin;
core.git: chart2/source offapi/com
chart2/source/controller/dialogs/tp_ChartType.cxx |2 +- chart2/source/model/template/ChartTypeManager.cxx |6 ++ chart2/source/model/template/PieChartTypeTemplate.cxx | 17 + chart2/source/view/charttypes/PieChart.cxx| 15 +++ chart2/source/view/charttypes/PieChart.hxx|2 ++ offapi/com/sun/star/chart2/PieChartSubType.idl|1 + 6 files changed, 34 insertions(+), 9 deletions(-) New commits: commit 15633d637e6296df218d56130d041660bf0e8317 Author: Kurt Nordback AuthorDate: Sat Feb 3 09:40:44 2024 -0700 Commit: Noel Grandin CommitDate: Tue Feb 6 15:16:31 2024 +0100 tdf#50934: Add a version comment, and more structure for of-pie Change-Id: I9d7c25e47a3f4a78360f9b2deffe8650e378866d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156305 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx index e0ddd62cd6ed..7d791815e70f 100644 --- a/chart2/source/controller/dialogs/tp_ChartType.cxx +++ b/chart2/source/controller/dialogs/tp_ChartType.cxx @@ -78,7 +78,7 @@ ChartTypeTabPage::ChartTypeTabPage(weld::Container* pPage, weld::DialogControlle m_xSubTypeList->SetStyle(m_xSubTypeList->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_NAMEFIELD | WB_FLATVALUESET | WB_3DLOOK ); -m_xSubTypeList->SetColCount(4); +m_xSubTypeList->SetColCount(6); m_xSubTypeList->SetLineCount(1); bool bEnableComplexChartTypes = true; diff --git a/chart2/source/model/template/ChartTypeManager.cxx b/chart2/source/model/template/ChartTypeManager.cxx index accf2078c2a6..2e6753444d99 100644 --- a/chart2/source/model/template/ChartTypeManager.cxx +++ b/chart2/source/model/template/ChartTypeManager.cxx @@ -405,13 +405,11 @@ rtl::Reference< ::chart::ChartTypeTemplate > ChartTypeManager::createTemplate( break; case TEMPLATE_BAROFPIE: xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, -chart2::PieChartOffsetMode_ALL_EXPLODED, true, -chart2::PieChartSubType_BAR )); +chart2::PieChartOffsetMode_NONE, false, chart2::PieChartSubType_BAR )); break; case TEMPLATE_PIEOFPIE: xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, -chart2::PieChartOffsetMode_ALL_EXPLODED, true, -chart2::PieChartSubType_PIE )); +chart2::PieChartOffsetMode_NONE, false, chart2::PieChartSubType_PIE )); break; case TEMPLATE_THREEDPIE: xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx index 2f8c7fb7705f..322b75243fb9 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.cxx +++ b/chart2/source/model/template/PieChartTypeTemplate.cxx @@ -266,6 +266,8 @@ void PieChartTypeTemplate::createChartTypes( rtl::Reference< ChartType > xCT = new PieChartType(); xCT->setFastPropertyValue( PROP_PIECHARTTYPE_USE_RINGS, getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS )); // "UseRings" +xCT->setFastPropertyValue( +PROP_PIECHARTTYPE_SUBTYPE, getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE )); // "SubType" rCoordSys[0]->setChartTypes( std::vector{xCT} ); if( !aSeriesSeq.empty() ) @@ -294,10 +296,8 @@ bool PieChartTypeTemplate::matchesTemplate2( getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ) >>= bTemplateUsesRings; chart2::PieChartOffsetMode ePieOffsetMode; getFastPropertyValue( PROP_PIE_TEMPLATE_OFFSET_MODE ) >>= ePieOffsetMode; -/* -chart2::PieChartSubType ePieSubType; -getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE ) >>= ePieSubType; -*/ +chart2::PieChartSubType eTemplateSubType; +getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE ) >>= eTemplateSubType; //check offset-mode if( bResult ) @@ -372,6 +372,15 @@ bool PieChartTypeTemplate::matchesTemplate2( bResult = ( bTemplateUsesRings == bUseRings ); } } +if( bResult ) +{ +rtl::Reference< ChartType > xCTProp = xDiagram->getChartTypeByIndex( 0 ); +chart2::PieChartSubType eSubType = chart2::PieChartSubType_NONE; +if( xCTProp->getFastPropertyValue( PROP_PIECHARTTYPE_SUBTYPE ) >>= eSubType ) +{ +bResult = ( eTemplateSubType == eSubType ); +} +} return bResult; } diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index d97324288416..7aeb18d2f6e3 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -185,6 +185,7 @@ PieChart::PieChart( const
core.git: chart2/inc chart2/source offapi/com offapi/UnoApi_offapi.mk
chart2/inc/bitmaps.hlst|2 chart2/inc/strings.hrc |2 chart2/source/controller/dialogs/ChartTypeDialogController.cxx |6 + chart2/source/inc/ChartType.hxx|3 chart2/source/model/template/ChartTypeManager.cxx | 35 +- chart2/source/model/template/PieChartType.cxx |8 + chart2/source/model/template/PieChartTypeTemplate.cxx | 25 chart2/source/model/template/PieChartTypeTemplate.hxx |2 offapi/UnoApi_offapi.mk|1 offapi/com/sun/star/chart2/PieChartSubType.idl | 53 ++ 10 files changed, 124 insertions(+), 13 deletions(-) New commits: commit 6c45285e860a6b2dd7dd1aa6c8b7b9bb02134dd0 Author: Kurt Nordback AuthorDate: Fri Aug 18 12:34:07 2023 -0600 Commit: Noel Grandin CommitDate: Fri Feb 2 06:03:23 2024 +0100 tdf#50934: Initial plumbing and infrastructure Change-Id: I355bdc8e6d67e7cdd47e4d6eccecedc4b53ac11b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155851 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/inc/bitmaps.hlst b/chart2/inc/bitmaps.hlst index 5ef14f869fd8..b73667d17fcb 100644 --- a/chart2/inc/bitmaps.hlst +++ b/chart2/inc/bitmaps.hlst @@ -26,6 +26,7 @@ inline constexpr OUString BMP_AREAS_2D_3 = u"chart2/res/areasfull_52x60.png"_ust inline constexpr OUString BMP_AREAS_3D = u"chart2/res/areaspiled3d_52x60.png"_ustr; inline constexpr OUString BMP_AREAS_3D_1 = u"chart2/res/areas3d_52x60.png"_ustr; inline constexpr OUString BMP_AREAS_3D_2 = u"chart2/res/areasfull3d_52x60.png"_ustr; +inline constexpr OUString BMP_BAR_OF_PIE = u"chart2/res/pie_52x60.png"_ustr; // TODO inline constexpr OUString BMP_BARS_2D_1 = u"chart2/res/bar_52x60.png"_ustr; inline constexpr OUString BMP_BARS_2D_2 = u"chart2/res/barstack_52x60.png"_ustr; inline constexpr OUString BMP_BARS_2D_3 = u"chart2/res/barpercent_52x60.png"_ustr; @@ -96,6 +97,7 @@ inline constexpr OUString BMP_NET_LINESYMB = u"chart2/res/netlinepoint_52x60.png inline constexpr OUString BMP_NET_LINESYMB_STACK = u"chart2/res/netlinepointstack_52x60.png"_ustr; inline constexpr OUString BMP_NET_FILL = u"chart2/res/netfill_52x60.png"_ustr; inline constexpr OUString BMP_NET_FILL_STACK = u"chart2/res/netstackfill_52x60.png"_ustr; +inline constexpr OUString BMP_PIE_OF_PIE = u"chart2/res/pie_52x60.png"_ustr; // TODO inline constexpr OUString BMP_PYRAMIDQ_3D_1 = u"chart2/res/pyramindhori_52x60.png"_ustr; inline constexpr OUString BMP_PYRAMIDQ_3D_2 = u"chart2/res/pyramindhoristack_52x60.png"_ustr; inline constexpr OUString BMP_PYRAMIDQ_3D_3 = u"chart2/res/pyramindhoripercent_52x60.png"_ustr; diff --git a/chart2/inc/strings.hrc b/chart2/inc/strings.hrc index 8c22e850b9c2..8a6ec2fd2777 100644 --- a/chart2/inc/strings.hrc +++ b/chart2/inc/strings.hrc @@ -161,6 +161,8 @@ #define STR_TYPE_AREA NC_("STR_TYPE_AREA", "Area") #define STR_TYPE_PIENC_("STR_TYPE_PIE", "Pie") #define STR_PIE_EXPLODEDNC_("STR_PIE_EXPLODED", "Exploded Pie Chart") +#define STR_BAR_OF_PIE NC_("STR_BAR_OF_PIE", "Bar-of-pie Chart") +#define STR_PIE_OF_PIE NC_("STR_PIE_OF_PIE", "Pie-of-pie Chart") #define STR_DONUT_EXPLODED NC_("STR_DONUT_EXPLODED", "Exploded Donut Chart") #define STR_DONUT NC_("STR_DONUT", "Donut") #define STR_TYPE_LINE NC_("STR_TYPE_LINE", "Line") diff --git a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx index b52dbc289743..2a597a287490 100644 --- a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx +++ b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx @@ -567,6 +567,8 @@ const tTemplateServiceChartTypeParameterMap& PieChartDialogController::getTempla {"com.sun.star.chart2.template.PieAllExploded" , ChartTypeParameter(2,false,false)}, {"com.sun.star.chart2.template.Donut" , ChartTypeParameter(3,false,false)}, {"com.sun.star.chart2.template.DonutAllExploded" , ChartTypeParameter(4,false,false)}, +{"com.sun.star.chart2.template.BarOfPie" , ChartTypeParameter(5,false,false)}, +{"com.sun.star.chart2.template.PieOfPie" , ChartTypeParameter(6,false,false)}, {"com.sun.star.chart2.template.ThreeDPie" , ChartTypeParameter(1,false,true)}, {"com.sun.star.chart2.template.ThreeDPieAllExploded" , ChartTypeParameter(2,false,true)}, {"com.sun.star.chart2.template.ThreeDDonut" , ChartTypeParameter(3,false,true)}, @@ -590,11 +592,15 @@ void
core.git: chart2/source
chart2/source/view/charttypes/VSeriesPlotter.cxx | 42 + chart2/source/view/inc/VSeriesPlotter.hxx |2 + chart2/source/view/main/SeriesPlotterContainer.cxx |7 +++ 3 files changed, 51 insertions(+) New commits: commit ca3112f38ea67d3cff1c9784adcc30ffcb200a0a Author: Kurt Nordback AuthorDate: Mon Jan 8 09:37:28 2024 -0700 Commit: Noel Grandin CommitDate: Fri Jan 12 07:55:02 2024 +0100 tdf#159043: combo chart render order isn't right Change-Id: If20446c8bd5a67f73c2126c26ed6bd160aed Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161797 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index f9fa8fe0fea9..34a702d7b696 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -2307,6 +2307,48 @@ OUString VSeriesPlotter::getCategoryName( sal_Int32 nPointIndex ) const return OUString(); } +namespace { +// The following it to support rendering order for combo charts. A chart type +// with a lower rendering order is rendered before (i.e., behind) a chart with a +// higher rendering order. The rendering orders are based on rough guesses about +// how much one chart (type) will obscure another chart (type). The intent is to +// minimize obscuring of data, by putting charts that generally cover more +// pixels (e.g., area charts) behind ones that generally cover fewer (e.g., line +// charts). +struct ROrderPair +{ +ROrderPair(OUString n, sal_Int32 r) : chartName(n), renderOrder(r) {} + +OUString chartName; +sal_Int32 renderOrder; +}; + +const ROrderPair pairList[] = { +ROrderPair(CHART2_SERVICE_NAME_CHARTTYPE_AREA, 0), +ROrderPair(CHART2_SERVICE_NAME_CHARTTYPE_BAR, 6), // bar & column are same +ROrderPair(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN, 6), +ROrderPair(CHART2_SERVICE_NAME_CHARTTYPE_LINE, 8), +ROrderPair(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER, 5), +ROrderPair(CHART2_SERVICE_NAME_CHARTTYPE_PIE, 1), +ROrderPair(CHART2_SERVICE_NAME_CHARTTYPE_NET, 3), +ROrderPair(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET, 2), +ROrderPair(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK, 7), +ROrderPair(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE, 4) +}; +} // unnamed + +sal_Int32 VSeriesPlotter::getRenderOrder() const +{ +OUString aChartType = m_xChartTypeModel->getChartType(); +for (size_t n = 0; n < sizeof(pairList); ++n) { +if (aChartType.equalsIgnoreAsciiCase(pairList[n].chartName)) { +return pairList[n].renderOrder; +} +} +SAL_WARN("chart2", "Unsupported chart type in getRenderOrder()"); +return 0; +} + std::vector VSeriesPlotter::getAllSeries() const { std::vector aAllSeries; diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index eaf27495d0ed..45676830b538 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -275,6 +275,8 @@ public: OUString getLabelTextForValue(VDataSeries const & rDataSeries, sal_Int32 nPointIndex, double fValue, bool bAsPercentage); +sal_Int32 getRenderOrder() const; + protected: VSeriesPlotter( rtl::Reference< ::chart::ChartType > xChartTypeModel diff --git a/chart2/source/view/main/SeriesPlotterContainer.cxx b/chart2/source/view/main/SeriesPlotterContainer.cxx index bcc5b0f482a3..67e4d75c0b9b 100644 --- a/chart2/source/view/main/SeriesPlotterContainer.cxx +++ b/chart2/source/view/main/SeriesPlotterContainer.cxx @@ -317,6 +317,13 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart } } +auto order += [](const std::unique_ptr& a, const std::unique_ptr& b) { + return a->getRenderOrder() < b->getRenderOrder(); + }; + +std::stable_sort(m_aSeriesPlotterList.begin(), m_aSeriesPlotterList.end(), order); + //transport seriesnames to the coordinatesystems if needed if (m_aSeriesPlotterList.empty()) return;
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - chart2/qa chart2/source
chart2/qa/extras/chart2dump/reference/piecharttest/donut_chart.txt | 10 - chart2/source/view/charttypes/PieChart.cxx | 60 +++--- chart2/source/view/charttypes/PieChart.hxx |4 3 files changed, 55 insertions(+), 19 deletions(-) New commits: commit 597bc417192fd9eac58c3cca9527ce5646d9972f Author: Kurt Nordback AuthorDate: Fri Jun 3 15:19:28 2022 -0600 Commit: Adolfo Jayme Barrientos CommitDate: Tue Jul 5 18:25:24 2022 +0200 tdf#104428 Improve rendering of exploded donut charts This bug shows an exploded donut chart with more than one series. The concern is that the standard pie/donut' explosion' rendering, with the shape of the pieces unchanged but the pieces translated outward, gives unsatisfactory results in the case of a donut with more than one series, where the translated 'exploded' pieces can overlap with the inner ring. This proposed fix renders this case differently, by increasing the radius of the exploded ring but keeping the pieces concentric with the inner ring. This commit also modifies the unit test values for donut_chart.ods. Change-Id: I713b1f3ce4697d46d29914410056f0aa83c6aa8b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135394 Tested-by: Jenkins Reviewed-by: Noel Grandin (cherry picked from commit 9b558357a3e7a4c908084134d56770809116b4f1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136765 Reviewed-by: Adolfo Jayme Barrientos diff --git a/chart2/qa/extras/chart2dump/reference/piecharttest/donut_chart.txt b/chart2/qa/extras/chart2dump/reference/piecharttest/donut_chart.txt index b2dfd33295a2..c1af41103de5 100644 --- a/chart2/qa/extras/chart2dump/reference/piecharttest/donut_chart.txt +++ b/chart2/qa/extras/chart2dump/reference/piecharttest/donut_chart.txt @@ -35,15 +35,15 @@ 16728590 /// /D=0:CS=0:CT=0:Series=0:Point=2 // aSlicePosition.X -8909 +9033 // aSlicePosition.Y -4532 +4635 // aSliceSize.Height -4689 +4659 // aSliceSize.Width -2544 +2458 // aSliceTransformation -2544;0;8909;0;4689;4532;0;0;1 +2458;0;9033;0;4659;4635;0;0;1 // static_cast(aSliceFillStyle) 1 // static_cast(aSliceFillColor) diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 806bc468414c..a81428c24c15 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -246,17 +246,47 @@ bool PieChart::shouldSnapRectToUsedArea() rtl::Reference PieChart::createDataPoint( const rtl::Reference& xTarget, const uno::Reference& xObjectProperties, -const ShapeParam& rParam ) +const ShapeParam& rParam, +const sal_Int32 nPointCount, +const bool bConcentricExplosion) { //transform position: drawing::Direction3D aOffset; -if (rParam.mfExplodePercentage != 0.0) -{ -double fAngle = rParam.mfUnitCircleStartAngleDegree + rParam.mfUnitCircleWidthAngleDegree/2.0; -double fRadius = (rParam.mfUnitCircleOuterRadius-rParam.mfUnitCircleInnerRadius)*rParam.mfExplodePercentage; -drawing::Position3D aOrigin = m_pPosHelper->transformUnitCircleToScene(0, 0, rParam.mfLogicZ); -drawing::Position3D aNewOrigin = m_pPosHelper->transformUnitCircleToScene(fAngle, fRadius, rParam.mfLogicZ); -aOffset = aNewOrigin - aOrigin; +double fExplodedInnerRadius = rParam.mfUnitCircleInnerRadius; +double fExplodedOuterRadius = rParam.mfUnitCircleOuterRadius; +double fStartAngle = rParam.mfUnitCircleStartAngleDegree; +double fWidthAngle = rParam.mfUnitCircleWidthAngleDegree; + +if (rParam.mfExplodePercentage != 0.0) { +double fRadius = (fExplodedOuterRadius-fExplodedInnerRadius)*rParam.mfExplodePercentage; + +if (bConcentricExplosion) { + +// For concentric explosion, increase the radius but retain the original +// arc length of all ring segments together. This results in a gap +// that's evenly divided among all segments, assuming they all have +// the same explosion percentage +assert(fExplodedInnerRadius >= 0 && fExplodedOuterRadius > 0); +double fAngleRatio = (fExplodedInnerRadius + fExplodedOuterRadius) / +(fExplodedInnerRadius + fExplodedOuterRadius + 2 * fRadius); + +assert(nPointCount > 0); +double fAngleGap = 360 * (1.0 - fAngleRatio) / nPointCount; +fStartAngle += fAngleGap / 2; +fWidthAngle -= fAngleGap; + +fExplodedInnerRadius += fRadius; +fExplodedOuterRadius += fRadius; + +} else { +// For the non-concentric explosion case, keep the original radius +// but shift the circle origin +double fAngle = fStartAngle + fWidthAngle/2.0; + +drawing::Position3D aOrigin = m_pPosHelper->transformUnitCircleToScene(0, 0, rParam.mfLogicZ); +
[Libreoffice-commits] core.git: chart2/qa chart2/source
chart2/qa/extras/chart2dump/reference/piecharttest/donut_chart.txt | 10 - chart2/source/view/charttypes/PieChart.cxx | 60 +++--- chart2/source/view/charttypes/PieChart.hxx |4 3 files changed, 55 insertions(+), 19 deletions(-) New commits: commit 9b558357a3e7a4c908084134d56770809116b4f1 Author: Kurt Nordback AuthorDate: Fri Jun 3 15:19:28 2022 -0600 Commit: Noel Grandin CommitDate: Tue Jul 5 11:52:43 2022 +0200 tdf#104428 Improve rendering of exploded donut charts This bug shows an exploded donut chart with more than one series. The concern is that the standard pie/donut' explosion' rendering, with the shape of the pieces unchanged but the pieces translated outward, gives unsatisfactory results in the case of a donut with more than one series, where the translated 'exploded' pieces can overlap with the inner ring. This proposed fix renders this case differently, by increasing the radius of the exploded ring but keeping the pieces concentric with the inner ring. This commit also modifies the unit test values for donut_chart.ods. Change-Id: I713b1f3ce4697d46d29914410056f0aa83c6aa8b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135394 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/chart2/qa/extras/chart2dump/reference/piecharttest/donut_chart.txt b/chart2/qa/extras/chart2dump/reference/piecharttest/donut_chart.txt index b2dfd33295a2..c1af41103de5 100644 --- a/chart2/qa/extras/chart2dump/reference/piecharttest/donut_chart.txt +++ b/chart2/qa/extras/chart2dump/reference/piecharttest/donut_chart.txt @@ -35,15 +35,15 @@ 16728590 /// /D=0:CS=0:CT=0:Series=0:Point=2 // aSlicePosition.X -8909 +9033 // aSlicePosition.Y -4532 +4635 // aSliceSize.Height -4689 +4659 // aSliceSize.Width -2544 +2458 // aSliceTransformation -2544;0;8909;0;4689;4532;0;0;1 +2458;0;9033;0;4659;4635;0;0;1 // static_cast(aSliceFillStyle) 1 // static_cast(aSliceFillColor) diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx index 806bc468414c..a81428c24c15 100644 --- a/chart2/source/view/charttypes/PieChart.cxx +++ b/chart2/source/view/charttypes/PieChart.cxx @@ -246,17 +246,47 @@ bool PieChart::shouldSnapRectToUsedArea() rtl::Reference PieChart::createDataPoint( const rtl::Reference& xTarget, const uno::Reference& xObjectProperties, -const ShapeParam& rParam ) +const ShapeParam& rParam, +const sal_Int32 nPointCount, +const bool bConcentricExplosion) { //transform position: drawing::Direction3D aOffset; -if (rParam.mfExplodePercentage != 0.0) -{ -double fAngle = rParam.mfUnitCircleStartAngleDegree + rParam.mfUnitCircleWidthAngleDegree/2.0; -double fRadius = (rParam.mfUnitCircleOuterRadius-rParam.mfUnitCircleInnerRadius)*rParam.mfExplodePercentage; -drawing::Position3D aOrigin = m_pPosHelper->transformUnitCircleToScene(0, 0, rParam.mfLogicZ); -drawing::Position3D aNewOrigin = m_pPosHelper->transformUnitCircleToScene(fAngle, fRadius, rParam.mfLogicZ); -aOffset = aNewOrigin - aOrigin; +double fExplodedInnerRadius = rParam.mfUnitCircleInnerRadius; +double fExplodedOuterRadius = rParam.mfUnitCircleOuterRadius; +double fStartAngle = rParam.mfUnitCircleStartAngleDegree; +double fWidthAngle = rParam.mfUnitCircleWidthAngleDegree; + +if (rParam.mfExplodePercentage != 0.0) { +double fRadius = (fExplodedOuterRadius-fExplodedInnerRadius)*rParam.mfExplodePercentage; + +if (bConcentricExplosion) { + +// For concentric explosion, increase the radius but retain the original +// arc length of all ring segments together. This results in a gap +// that's evenly divided among all segments, assuming they all have +// the same explosion percentage +assert(fExplodedInnerRadius >= 0 && fExplodedOuterRadius > 0); +double fAngleRatio = (fExplodedInnerRadius + fExplodedOuterRadius) / +(fExplodedInnerRadius + fExplodedOuterRadius + 2 * fRadius); + +assert(nPointCount > 0); +double fAngleGap = 360 * (1.0 - fAngleRatio) / nPointCount; +fStartAngle += fAngleGap / 2; +fWidthAngle -= fAngleGap; + +fExplodedInnerRadius += fRadius; +fExplodedOuterRadius += fRadius; + +} else { +// For the non-concentric explosion case, keep the original radius +// but shift the circle origin +double fAngle = fStartAngle + fWidthAngle/2.0; + +drawing::Position3D aOrigin = m_pPosHelper->transformUnitCircleToScene(0, 0, rParam.mfLogicZ); +drawing::Position3D aNewOrigin = m_pPosHelper->transformUnitCircleToScene(fAngle, fRadius, rParam.mfLogicZ); +aOffset = aNewOrigin - aOrigin; +} } //create
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - chart2/source
chart2/source/view/charttypes/VSeriesPlotter.cxx | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) New commits: commit 31e982283e1abd0233c06f6f224c34298efabe97 Author: Kurt Nordback AuthorDate: Sat May 28 15:29:31 2022 -0600 Commit: Xisco Fauli CommitDate: Mon Jul 4 10:58:22 2022 +0200 tdf#56580 Fix negative error bars on log chart This is a bug in the rendering of negative error bars on log charts, when the error bar size is greater than the chart value. This is numerically invalid, since it leads to taking the logarithm of a non-positive value. - Add a test for this condition, and turn off the negative error bar when the condition is met. Change-Id: If84823c27d68976d3515581b1f913d78d683f446 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135106 Reviewed-by: Mike Kaganski Tested-by: Mike Kaganski (cherry picked from commit ec31df481568f6a654e5f6c1d597dc8b963b99e6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136708 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 640abfebb1ab..fd3a1fe1f9fa 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -1044,7 +1044,21 @@ void VSeriesPlotter::createErrorBar( fLocalX-=fLength; aNegative = m_pPosHelper->transformLogicToScene( fLocalX, fLocalY, fZ, true ); } -bCreateNegativeBorder = m_pPosHelper->isLogicVisible( fLocalX, fLocalY, fZ); +if (std::isfinite(aNegative.PositionX) && +std::isfinite(aNegative.PositionY) && +std::isfinite(aNegative.PositionZ)) { +bCreateNegativeBorder = m_pPosHelper->isLogicVisible( fLocalX, fLocalY, fZ); +} else { +// If error bars result in a numerical problem (e.g., an +// error bar on a logarithmic chart that results in a point +// <= 0) then just turn off the error bar. +// +// TODO: This perhaps should display a warning, so the user +// knows why a bar is not appearing. +// TODO: This test could also be added to the positive case, +// though a numerical overflow there is less likely. +bShowNegative = false; +} } else bShowNegative = false;
[Libreoffice-commits] core.git: chart2/source
chart2/source/view/charttypes/VSeriesPlotter.cxx | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) New commits: commit ec31df481568f6a654e5f6c1d597dc8b963b99e6 Author: Kurt Nordback AuthorDate: Sat May 28 15:29:31 2022 -0600 Commit: Mike Kaganski CommitDate: Fri Jul 1 09:12:00 2022 +0200 tdf#56580 Fix negative error bars on log chart This is a bug in the rendering of negative error bars on log charts, when the error bar size is greater than the chart value. This is numerically invalid, since it leads to taking the logarithm of a non-positive value. - Add a test for this condition, and turn off the negative error bar when the condition is met. Change-Id: If84823c27d68976d3515581b1f913d78d683f446 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135106 Reviewed-by: Mike Kaganski Tested-by: Mike Kaganski diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 360bce2c275f..09e6860c3465 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -1045,7 +1045,21 @@ void VSeriesPlotter::createErrorBar( fLocalX-=fLength; aNegative = m_pPosHelper->transformLogicToScene( fLocalX, fLocalY, fZ, true ); } -bCreateNegativeBorder = m_pPosHelper->isLogicVisible( fLocalX, fLocalY, fZ); +if (std::isfinite(aNegative.PositionX) && +std::isfinite(aNegative.PositionY) && +std::isfinite(aNegative.PositionZ)) { +bCreateNegativeBorder = m_pPosHelper->isLogicVisible( fLocalX, fLocalY, fZ); +} else { +// If error bars result in a numerical problem (e.g., an +// error bar on a logarithmic chart that results in a point +// <= 0) then just turn off the error bar. +// +// TODO: This perhaps should display a warning, so the user +// knows why a bar is not appearing. +// TODO: This test could also be added to the positive case, +// though a numerical overflow there is less likely. +bShowNegative = false; +} } else bShowNegative = false;