Skip to content

Conversation

seanlynchwv
Copy link
Contributor

@seanlynchwv seanlynchwv commented Jul 10, 2025

Description

We needed the ability to create a half circle from 270' to 90' but it was not working

This is now fixed by adding a new ->setFirstSliceAngle( int ); helper to Doughnut.php

Previously this was hard-coded to 0. Over-writing this did not work as <c:view3D> was imported into every chart which was conflicting with the rule.

After debugging the output from powerpoint itself, I learned that we can fix this by making <c:view3D> conditional. Now making programatic changes to 2d charts works as expected.

It now works:

            $real = [15, 25, 30, 20, 10];
            $dummy = array_sum($real);
            $values = array_merge([$dummy], $real);

            $doughnut = (new Doughnut())
                ->setHoleSize(75)
                ->setFirstSliceAngle(90);

            $series = new Series('Gauge', $values);
            $series->setShowValue(false);
            $doughnut->addSeries($series);

            /* make the dummy slice transparent */
            $series->getDataPointFill(0)
                ->setFillType(Fill::FILL_SOLID)
                ->setStartColor(new Color('00FFFFFF'));

            $chart = $slide->createChartShape()
                ->setName('Gauge')
                ->setResizeProportional(false)
                ->setOffsetX($offsetX)
                ->setOffsetY($offsetY)
                ->setWidth($w)
                ->setHeight($h);

            $chart->getPlotArea()->setType($doughnut);
            $chart->getLegend()->setVisible(false);
            $chart->getTitle()->setVisible(false);
Screenshot 2025-07-11 at 14 43 54

Fixes # (issue)

Checklist:

  • My CI is 🟢
  • I have covered by unit tests my new code (check build/coverage for coverage report)
  • [o] I have updated the documentation to describe the changes - not yet, its still TODO
  • I have updated the changelog - not yet

@auto-assign auto-assign bot requested a review from Progi1984 July 10, 2025 10:56
@seanlynchwv
Copy link
Contributor Author

Sorry did not mean to create a PR here which happened automatically when I created a PR on my copy of the repo. Will try to submit a PR later if I can get the doughnut rotation working as expected

@seanlynchwv seanlynchwv reopened this Jul 11, 2025
@seanlynchwv seanlynchwv changed the title Add rotation Added setFirstSliceAngle to Doughnut Chart Jul 11, 2025
@coveralls
Copy link

coveralls commented Jul 11, 2025

Coverage Status

coverage: 91.643% (+0.004%) from 91.639%
when pulling cb71bea on seanlynchwv:feature/angle-rotation
into b9cdcd4 on PHPOffice:master.

@seanlynchwv
Copy link
Contributor Author

Hey @Progi1984 thanks for reviewing this PR! If you can merge this I can follow up with another one to change the corner radius on roundedRect

seanlynchwv#2

Copy link
Member

@Progi1984 Progi1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add unit tests for Doughnut Class ?

@seanlynchwv
Copy link
Contributor Author

Added a new unit test @Progi1984

Have 2 more PRs to follow up if you can accept this one please

@Progi1984 Progi1984 merged commit 7018fd8 into PHPOffice:master Sep 2, 2025
32 checks passed
@Progi1984
Copy link
Member

Thanks @seanlynchwv .

Perfect contribution.

@Progi1984 Progi1984 added this to the 1.3.0 milestone Sep 2, 2025
@Progi1984
Copy link
Member

Zut ! I wanted to move the change in changelog file to 1.3.0.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants