Skip to content

Can't hide axis #1446

Closed
Closed
@cwolcott

Description

@cwolcott

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?

To be able to fully disable the x and/or y axis from being shown.

What is the current behavior?

Can't be done. Code currently hardcodes axis to always be displayed.

    $objWriter->startElement('c:delete');
    $objWriter->writeAttribute('val', 0);
    $objWriter->endElement();

What are the steps to reproduce?

There is no api interface to control desired outcome.

Which versions of PhpSpreadsheet and PHP are affected?

1.11.0

I plan to submit a pull request that will allow the developer to hide the axis fully. By default the axis is visible.

    $yAxis = new Axis();
    $yAxis->hideAxis();

Before
image

The xl\charts\chart1.xml for the category axis looks like with <c:delete val="0"/>:

<c:catAx><c:axId val="75091328"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:delete val="0"/><c:axPos val="b"/><c:title><c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:pPr><a:defRPr sz="1400" b="1"/></a:pPr><a:r><a:rPr lang="en-US" sz="1400" b="1"/><a:t>Assay Wells</a:t></a:r></a:p></c:rich></c:tx><c:overlay val="0"/></c:title><c:numFmt formatCode="General" sourceLinked="1"/><c:majorTickMark val="none"/><c:minorTickMark val="none"/><c:tickLblPos val="low"/><c:crossAx val="75089408"/><c:crosses val="autoZero"/><c:auto val="1"/><c:lblAlgn val="ctr"/><c:lblOffset val="100"/><c:noMultiLvlLbl val="0"/></c:catAx>

After
image

The Xlsx/Charts.php will now dynamically generate the delete tag based on the axis configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions