Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secondary y-axis not available in PHP Spreadsheet #560

Closed
rf1234 opened this issue Jun 21, 2018 · 5 comments
Closed

Secondary y-axis not available in PHP Spreadsheet #560

rf1234 opened this issue Jun 21, 2018 · 5 comments
Labels

Comments

@rf1234
Copy link

rf1234 commented Jun 21, 2018

This is:

- [ ] a bug report
- [ x ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

PHP Spreadsheet should be able to handle a secondary Y axis.

What is the current behavior?

It is not possible to define a secondary Y axis.

What are the steps to reproduce?

Somebody has already posted a solution for PHP Excel which wasn't implemented because PHP Excel is deprecated. Could you integrate the feature based on this post please:
PHPOffice/PHPExcel#1037

Which versions of PhpSpreadsheet and PHP are affected?

The current version

@rf1234
Copy link
Author

rf1234 commented Jun 21, 2018

Because I can't wait for a fix I have adapted Porrapat's fix to PHP Spreadsheet and it works. But of course it is hard coded ... would be better if it was integrated into the standard. If you need the code just let me know - and tell me how to post it please.

@PowerKiKi
Copy link
Member

PowerKiKi commented Jun 22, 2018 via email

@rf1234
Copy link
Author

rf1234 commented Jun 22, 2018

I guess that requires I use github as version control solution which I currently don't. For your convenience I have attached the files that I changed and an example that I created. All is based on PHPSpreadsheet version 1.2.1, 10 April 2018
FilesSecondaryAxis.zip
FileWriterXlsx.zip

@rf1234 rf1234 closed this as completed Jun 22, 2018
@rf1234 rf1234 reopened this Jun 22, 2018
@stale
Copy link

stale bot commented Aug 21, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@stale stale bot added the stale label Aug 21, 2018
@stale stale bot closed this as completed Aug 28, 2018
@qdkid
Copy link

qdkid commented Nov 18, 2020

Followed rf1234's codes, merge with current version 1.15.0 and create a patch
chart_2nd_y_axis.patch.zip

It enables secondary y-axis in PHP spreadsheet.
rf1234 uploaded file has a test sample as well. Please use default displayBlanksAs 'gap' to avoid error
$chart = new Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotArea, // plotArea
true, // plotVisibleOnly
'gap', // displayBlanksAs
null, // xAxisLabel
$yAxisLabel, // yAxisLabel
null, // xAxis
null, // yAxis
null, // majorGridlines
null, //minor Gridlines
$secondaryYAxisLabel // secondaryYAxisLabel
);

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Apr 9, 2023
Stock charts currently ignore upDownBars tag and its subsidiary gapWidth, upBars, and downBars tags when reading, and hard-codes those tags on write. As a result, the sample reproductions of stock charts in the 32* series aren't faithful to the originals. This PR fixes samples 1, 2, and 5. Samples 3 and 4 are reproduced better, but they require currently unsupported secondary axes (issue PHPOffice#560, issue PHPOffice#1072, and PR PHPOffice#1073 were closed as stale; see also PHPOffice/PHPExcel#1037). I will start to look at those, but it could take a while, and I don't think there's a reason to delay this in the meantime.

Charts which depended on the hard-coded values written by the Xlsx Chart writer will be slightly different as a result of this change. To restore the hard-coded behavior:
```php
$plotArea->setGapWidth(300);
$plotArea->setUseUpBars(true);
$plotArea->setUseDownBars(true);
```
The new behavior is demonstrated in 33_Chart_create_stock. The old behavior is demonstrated (with the code above) in new 33_Chart_create_stock2.
oleibman added a commit that referenced this issue Apr 15, 2023
Stock charts currently ignore upDownBars tag and its subsidiary gapWidth, upBars, and downBars tags when reading, and hard-codes those tags on write. As a result, the sample reproductions of stock charts in the 32* series aren't faithful to the originals. This PR fixes samples 1, 2, and 5. Samples 3 and 4 are reproduced better, but they require currently unsupported secondary axes (issue #560, issue #1072, and PR #1073 were closed as stale; see also PHPOffice/PHPExcel#1037). I will start to look at those, but it could take a while, and I don't think there's a reason to delay this in the meantime.

Charts which depended on the hard-coded values written by the Xlsx Chart writer will be slightly different as a result of this change. To restore the hard-coded behavior:
```php
$plotArea->setGapWidth(300);
$plotArea->setUseUpBars(true);
$plotArea->setUseDownBars(true);
```
The new behavior is demonstrated in 33_Chart_create_stock. The old behavior is demonstrated (with the code above) in new 33_Chart_create_stock2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants