Skip to content

Commit

Permalink
Merge pull request #410 from PHPOffice/issue271pptx
Browse files Browse the repository at this point in the history
#271 : PowerPoint2007/ODPresentation Writer : Support for rotation for axis label
  • Loading branch information
Progi1984 authored Jul 25, 2021
2 parents 6c46ff2 + 56a6b19 commit 543e19a
Show file tree
Hide file tree
Showing 10 changed files with 347 additions and 154 deletions.
6 changes: 5 additions & 1 deletion docs/changes/1.0.0.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# 1.0.0 - WIP

## Bugfix
- PowerPoint2007 : Text is subscripted when set superscript to false - @qmachard GH-360
- PowerPoint2007 Writer : Text is subscripted when set superscript to false - @qmachard GH-360
- Core : Defining width & height of a shape don't return any error if width & height were equal to 0 - @surger GH-555
- ODPresentation Writer : Display axis title depending the visibility - @Progi1984 GH-410

## Changes
- Dropped support for HHVM - @sunspikes GH-556
Expand Down Expand Up @@ -36,6 +37,9 @@
- PowerPoint2007 Reader
- PowerPoint2007 Writer
- Support for Border & Fill for Chart's Marker in PowerPoint2007 Writer - @ksmeeks0001 GH-627 & @Progi1986 GH-658
- Support for rotation for axis label - @Progi1986 GH-410
- ODPresentation Writer
- PowerPoint2007 Writer

## Project Management
- Migrated from Travis CI to Github Actions - @Progi1984 GH-635
Expand Down
31 changes: 30 additions & 1 deletion docs/usage/shapes/chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ $chartShape = $slide->createChartShape();

### Axis

#### Title

You can define title for each axis (X & Y) with `setTitle` method.
You can apply a rotation with the `setTitleRotation` method with an expected paremeter in degrees.

``` php
<?php

use PhpOffice\PhpPresentation\Shape\Chart\Gridlines;

$line = new Line();

$shape = $slide->createChartShape();
$shape->getPlotArea()->setType($line);

$shape->getPlotArea()->getAxisX()->setTitle('Axis X');
$shape->getPlotArea()->getAxisX()->setTitleRotation(45);
```

#### Gridlines

You can define gridlines (minor and major) for each axis (X & Y).
For each gridline, you can custom the width (in points), the fill type and the fill color.

Expand All @@ -31,6 +52,8 @@ $shape->getPlotArea()->setType($line);
$shape->getPlotArea()->getAxisX()->setMajorGridlines($gridlines);
```

#### Bounds (Min & Max)

For Axis, you can define the min & max bounds with `setMinBounds` & `setMaxBounds` methods.
For resetting them, you pass null as parameter to these methods.

Expand All @@ -47,6 +70,8 @@ $shape->getPlotArea()->getAxisX()->setMinBounds(0);
$shape->getPlotArea()->getAxisX()->setMaxBounds(200);
```

#### Outline

You can define outline for each axis (X & Y).

``` php
Expand All @@ -59,9 +84,10 @@ $shape->getPlotArea()->setType($line);
$shape->getPlotArea()->getAxisX()->getOutline()->setWidth(10);
$shape->getPlotArea()->getAxisX()->getOutline()->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
```
#### Tick Marks

For Axis Y, you can define tick mark with `setMinorTickMark` & `setMajorTickMark` methods.
For resetting them, you pass Axis::TICK_MARK_NONE as parameter to these methods.
For resetting them, you pass `Axis::TICK_MARK_NONE` as parameter to these methods.

``` php
<?php
Expand All @@ -76,6 +102,8 @@ $shape->getPlotArea()->getAxisY()->setMinorTickMark(Axis::TICK_MARK_NONE);
$shape->getPlotArea()->getAxisY()->setMajorTickMark(Axis::TICK_MARK_INSIDE);
```

#### Unit

For Axis Y, you can define unit with `setMinorUnit` & `setMajorUnit` methods.
For resetting them, you pass null as parameter to these methods.

Expand All @@ -91,6 +119,7 @@ $shape->getPlotArea()->setType($line);
$shape->getPlotArea()->getAxisY()->setMinorUnit(null);
$shape->getPlotArea()->getAxisY()->setMajorUnit(0.05);
```
#### Visibility

You can define visibility for each axis (X & Y).

Expand Down
2 changes: 2 additions & 0 deletions samples/Sample_05_Chart_Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@
$shape4->getTitle()->setText('Chart with Outline on Axis');
$shape4->getPlotArea()->setType($lineChart4);
$shape4->getPlotArea()->getAxisX()->setOutline($oOutlineAxisX);
$shape4->getPlotArea()->getAxisX()->setTitleRotation(45);
$shape4->getPlotArea()->getAxisY()->setOutline($oOutlineAxisY);
$shape4->getPlotArea()->getAxisY()->setTitleRotation(135);
$currentSlide->addShape($shape4);

// Create templated slide
Expand Down
2 changes: 1 addition & 1 deletion samples/Sample_Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function createTemplatedSlide(PhpOffice\PhpPresentation\PhpPresentation $objPHPP
$shape = $slide->createDrawingShape();
$shape->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('./resources/phppowerpoint_logo.gif')
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
Expand Down
Loading

0 comments on commit 543e19a

Please sign in to comment.