Skip to content

Reassigning chart getName to getIndex and adding a proper getName. #2991

Open
@rolinger

Description

@rolinger

This is:

- [ ] a bug report
- [ ] a feature request
- [ x] change chart object identifiers

In excel, there are three references to charts:
chartIndex - index of all charts, starting with chart1 (top left most chart on sheet1), across all sheets, ending in chartX (bottom right most chart on sheetX). Adding, deleting charts will re-index all the charts in order. In phpspreadsheet, this is represented by $chart->getName()
chartName - above column A, there is a name field you can edit. In phpspreadsheet, there appears no way to get/set this value, please correct me if I am wrong.
chartTitle - the visual chart title, in the chart (IE: "Annual Sales Revenue"). In phpspreadsheet, this is represented by $chart->getTitle()->getCaptionText().

It took me a while to get to the bottom of all this as it kept tripping me up as I kept misinterpreting the close but different meanings of these values between excel and phpspreadsheet and what represented what.

Is it possible for these phpspreadsheet object methods to be renamed to align with excel?

getName() to getIndex()
create a new getName() that actually gets to the chart name
getTitle() would stay the same.

Unfortunately, its not easy to rely on the chart index, esp for an imported templates, because of adding/deleting/moving charts will reindex all of them making it challenging to know the exact chart you need to be working with. Thus adding a new proper getName() can allow us to tag/name a chart that we can then easily reference, the user never needs to change the name, just use it as a solid reference in order to edit/copy/duplicate/delete charts.

In my case, in my template I want to be name a chart Chart_Monthly. Using phpspreadsheet, change its title to January Sales, then later grab/copy Chart Monthly to create a new chart titled February Sales, etc. But because I might have other charts between January & February sales, I can't easily rely on the current getName() (aka: index) to retrieve the original January chart to copy. Also, this way, one wouldn't have to rely on tracking changing chart titles to find the original chart you wanted to copy.

I know this ask might be a long shot and probably has some versioning issues to simply rename certain object methods, but I thought I would throw it out there and see.

What features do you think are causing the issue

  • Reader
  • Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • [x ] Charts
  • AutoFilter
  • Form Elements

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

Which versions of PhpSpreadsheet and PHP are affected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions