-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Additional Support for Chart DataSeriesValues #2906
Conversation
Fix PHPOffice#2863. DataSeriesValues now extends Properties, allowing it to share code in common with Axis and Gridlines. This causes some minor breakages; in particular line width is now initialized to null instead of Excel's default value, and is specified in points, as the user would expect from Excel, rather than the value stored in Xml. This change: - adds support for 1 or 2 marker colors. - adds support for `smoothLine` to DataSeriesValues. - will determine `catAx` or `valAx` for Axis based on what is read from the Xml when available, rather than guessing based on format. (Another minor break.) - reads `formatCode` and `sourceLinked` for Axis. - correct 2 uses of `$plotSeriesRef` to `$plotSeriesIndex` in Writer/Xlsx/Chart. - pushes coverage over 90% for Chart (88.70% overall).
I had updated previously but forgot to stage the member.
All your changes are very similar to my work to address these issues. I admit your implementation is better. Adding Class ChartColor is good. That makes the various object's colors much easier to deal with. I have some suggestions: Property smoothLine (and its getter/setter methods) should be removed from DataSeries. They belong only in DataSeriesValues. TYPOS: You found and corrected almost all of the misnamed parameters "$AlphaType", but it escaped your correction in Axis. I renamed it "$ColorType", but it appears that you prefer "$colorType". Your call. (Someday - I suggest adding another Class - ChartLine - as an extension of Properties, which can accommodate all of the classes Axis, Gridlines, Scatterlines (as well as the yet-to-be-added Trendline), all of which have very similar line properties (linewidth and color), as well as special effects: LineStyle, Shadow, Glow, and SoftEdges. The implications of implementing it in Writer/Xlsx are messy, of course.) |
One more suggestion: And rename their respective getter/setter methods: Further: In Writer/Xlsx function writePlotGroup(), in the loop for $plotSeriesIdx => $plotSeriesRef, inside qualifiers "if ($plotSeriesValues) { Between those sections of xml generation must be the description of the line connecting the markers (or points). And, because it is a 'line', it can have color, linewidth, Styling, Shadow, Glow, SoftEdges - the whole barnyard of special effects. That is where all that stuff must be added. No fun, but I've taken a stab at it. More later. |
@bridgeplayr, thank you for the original suggestions, and for your thoughtful review of the change. There must be a way to insert replies in the correct place in the original message in Github, but I haven't figured it out yet. So I'll just put all my replies here.
|
I think you are correct that the statement which initializes fillColor is superfluous. However, I don't think we miss any important executable code as a result. Writing of the line styles takes place with the call to writeLineStyles just at the end of the if statement immediately following "Formatting for the points". You are right that the effects aren't written there. In theory, they could be written, and quite simply, if the necessary support is added to Reader. Those changes are too big to add to this one; they are on my to-do list. |
Success. Not the prettiest code you will see. Feel free to clean things up as you see fit. |
Incorporate some changes suggested by @bridgeplayr.
DataSeriesValues Fill could be a scalar or an array, so I saved it till last.
No code changes. Illustrate even more of the new features in existing sample files. Deprecate *_ARGB in Properties/ChartColors in favor of *_RGB, because it uses only 6 hex digits. The alpha value is stored separately.
Note that this will be the last 1.x branch release before the 2.x release. We will maintain both branches in parallel for a time; but users are requested to update to version 2.0 once that is fully available. ### Added - Added `removeComment()` method for Worksheet [PR #2875](https://github.com/PHPOffice/PhpSpreadsheet/pull/2875/files) - Add point size option for scatter charts [Issue #2298](#2298) [PR #2801](#2801) - Basic support for Xlsx reading/writing Chart Sheets [PR #2830](#2830) Note that a ChartSheet is still only written as a normal Worksheet containing a single chart, not as an actual ChartSheet. - Added Worksheet visibility in Ods Reader [PR #2851](#2851) and Gnumeric Reader [PR #2853](#2853) - Added Worksheet visibility in Ods Writer [PR #2850](#2850) - Allow Csv Reader to treat string as contents of file [Issue #1285](#1285) [PR #2792](#2792) - Allow Csv Reader to store null string rather than leave cell empty [Issue #2840](#2840) [PR #2842](#2842) - Provide new Worksheet methods to identify if a row or column is "empty", making allowance for different definitions of "empty": - Treat rows/columns containing no cell records as empty (default) - Treat cells containing a null value as empty - Treat cells containing an empty string as empty ### Changed - Modify `rangeBoundaries()`, `rangeDimension()` and `getRangeBoundaries()` Coordinate methods to work with row/column ranges as well as with cell ranges and cells [PR #2926](#2926) - Better enforcement of value modification to match specified datatype when using `setValueExplicit()` - Relax validation of merge cells to allow merge for a single cell reference [Issue #2776](#2776) - Memory and speed improvements, particularly for the Cell Collection, and the Writers. See [the Discussion section on github](#2821) for details of performance across versions - Improved performance for removing rows/columns from a worksheet ### Deprecated - Nothing ### Removed - Nothing ### Fixed - Xls Reader resolving absolute named ranges to relative ranges [Issue #2826](#2826) [PR #2827](#2827) - Null value handling in the Excel Math/Trig PRODUCT() function [Issue #2833](#2833) [PR #2834](#2834) - Invalid Print Area defined in Xlsx corrupts internal storage of print area [Issue #2848](#2848) [PR #2849](#2849) - Time interval formatting [Issue #2768](#2768) [PR #2772](#2772) - Copy from Xls(x) to Html/Pdf loses drawings [PR #2788](#2788) - Html Reader converting cell containing 0 to null string [Issue #2810](#2810) [PR #2813](#2813) - Many fixes for Charts, especially, but not limited to, Scatter, Bubble, and Surface charts. [Issue #2762](#2762) [Issue #2299](#2299) [Issue #2700](#2700) [Issue #2817](#2817) [Issue #2763](#2763) [Issue #2219](#2219) [Issue #2863](#2863) [PR #2828](#2828) [PR #2841](#2841) [PR #2846](#2846) [PR #2852](#2852) [PR #2856](#2856) [PR #2865](#2865) [PR #2872](#2872) [PR #2879](#2879) [PR #2898](#2898) [PR #2906](#2906) [PR #2922](#2922) [PR #2923](#2923) - Adjust both coordinates for two-cell anchors when rows/columns are added/deleted. [Issue #2908](#2908) [PR #2909](#2909) - Keep calculated string results below 32K. [PR #2921](#2921) - Filter out illegal Unicode char values FFFE/FFFF. [Issue #2897](#2897) [PR #2910](#2910) - Better handling of REF errors and propagation of all errors in Calculation engine. [PR #2902](#2902) - Calculating Engine regexp for Column/Row references when there are multiple quoted worksheet references in the formula [Issue #2874](#2874) [PR #2899](#2899)
***@***.***> @oleibman, thank you for your thoughtful reply. I confess to being glad that I am unencumbered by the many constraints of being a Developer. I understand that it is far easier for me to make suggestions than for you to implement them. Being a new dabbler in server-side code and php, I am gratified that my input is recognized. Thank you for that.
I understand all your comments below about the extra effort required for those suggestions and tasks. I’m confident that I can create the sample xlsx using your PR, and I will feedback any modifications I think are necessary.
Lastly, I am so happy to gratefully acknowledge the importance of your consolidating all of the line special effects xml generation functions into ‘writeShadow()’, ‘writeGlow()’, ‘writeSoftEdges()’,’writeLineStyles()’. My final self-assigned task was to attempt precisely this job, but the scope of reorganizing writing XAxis, YAxis, Major/MinorGridlines as well as ScatterLines xml was more than I could accomplish. I could hardly believe my eyes when I saw how neatly you did this. I understand the utility of writeNotEmpty() and writeColor() too. Very clever. Well done.
Back to the keyboard.
Rick Garvin
From: oleibman ***@***.***>
Sent: Friday, June 24, 2022 3:38 PM
To: PHPOffice/PhpSpreadsheet ***@***.***>
Cc: bridgeplayr ***@***.***>; Mention ***@***.***>
Subject: Re: [PHPOffice/PhpSpreadsheet] Additional Support for Chart DataSeriesValues (PR #2906)
@bridgeplayr <https://github.com/bridgeplayr> , thank you for the original suggestions, and for your thoughtful review of the change. There must be a way to insert replies in the correct place in the original message in Github, but I haven't figured it out yet. So I'll just put all my replies here.
* removing smoothLine from DataSeries falls in the "breaking change" category, and I hope to get to those eventually (this isn't the first potential break that I've come across during these PRs), but, for now, it will stay.
* I will spell Square correctly and add a deprecation notice for Squere. I will probably add a new commit to this PR over the weekend.
* our properties are almost always camel case starting with lowercase, so colorType will remain.
* $AlphaType should just be $type. Unfortunately, with Php8, changing parameter names is a breaking change, because you can now specify keyword parameters. So, see earlier comment about breaking changes.
* I considered adding ChartLine as its own class, like ChartColor. I found that I didn't need it for this change; there may be a time when I change my mind. ChartColor was especially needed because it is used by non-Chart classes, in particular Font. Right now, everything that needs Line inherits it from Properties.
* I will rename the properties to markerFillColor and markerBorderColor as you suggest. Part of this weekend's commit.
* I agree that some constructor parameters no longer make sense. See earlier comment about breaking changes.
* I have not yet had a chance to analyze your superfluous statement. If your comment makes sense, I will try to incorporate it over the weekend.
* Work on labels is next on my list. It is too big to add to this change.
* This change does deal with the lines between the markers. Otherwise, I would not have been able to handle your sample file.
—
Reply to this email directly, view it on GitHub <#2906 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AYXANOBW5TUU4CRMGQ72R4DVQY2GHANCNFSM5ZSK7EJA> .
You are receiving this because you were mentioned. <https://github.com/notifications/beacon/AYXANODWDUTINJHKNBA2FGLVQY2GHA5CNFSM5ZSK7EJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIV723EY.gif> Message ID: ***@***.*** ***@***.***> >
|
Thank you for the nice comments. I too have learned a lot from your suggestions (e.g. I had never actually created a chart in Excel before starting to work on them). Don't hesitate to let us know what's still missing. |
Fix #2863. DataSeriesValues now extends Properties, allowing it to share code in common with Axis and Gridlines. This causes some minor breakages; in particular line width is now initialized to null instead of Excel's default value, and is specified in points, as the user would expect from Excel, rather than the value stored in Xml.
This change:
smoothLine
to DataSeriesValues.catAx
orvalAx
for Axis based on what is read from the Xml when available, rather than guessing based on format. (Another minor break.)formatCode
andsourceLinked
for Axis.$plotSeriesRef
to$plotSeriesIndex
in Writer/Xlsx/Chart.This is:
Checklist:
Why this change is needed?
Provide an explanation of why this change is needed, with links to any Issues (if appropriate).
If this is a bugfix or a new feature, and there are no existing Issues, then please also create an issue that will make it easier to track progress with this PR.