-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Scheme colors in Charts #2863
Comments
As you've noted, we've recently added Scheme colors for Chart fonts. The additional opportunities you've described are on my to-do list, but it may take a while. Thank you for providing a sample spreadsheet to use for testing when the time comes. |
Fix PHPOffice#2219. Address some, but not all, issues mentioned in PHPOffice#2863. For Pie Charts, fill color is stored in XML as part of dPt node, which had been ignored by Reader/Xlsx/Chart. Add support for it, including when specified as schemeClr or prstClr rather than srgbClr. Add support for prstClr in other cases where schemeClr is supported.
* Expand Chart Support for schemeClr and prstClr Fix #2219. Address some, but not all, issues mentioned in #2863. For Pie Charts, fill color is stored in XML as part of dPt node, which had been ignored by Reader/Xlsx/Chart. Add support for it, including when specified as schemeClr or prstClr rather than srgbClr. Add support for prstClr in other cases where schemeClr is supported. * Update Change Log Add this PR.
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).
Please test with PR #2906 if you are able. I'm not sure how easy that is since there are prerequisite changes since the last release. At the very least, I am able to copy your sample file accurately. |
Yes. Glad to do it.
From: oleibman ***@***.***>
Sent: Wednesday, June 22, 2022 5:21 PM
To: PHPOffice/PhpSpreadsheet ***@***.***>
Cc: bridgeplayr ***@***.***>; Author ***@***.***>
Subject: Re: [PHPOffice/PhpSpreadsheet] Scheme colors in Charts (Issue #2863)
Please test with PR #2906 <#2906> if you are able. I'm not sure how easy that is since there are prerequisite changes since the last release. At the very least, I am able to copy your sample file accurately.
—
Reply to this email directly, view it on GitHub <#2863 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AYXANOBRICP3OC7RWFIM2WDVQOUWDANCNFSM5XP3DLKA> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/AYXANOHD4AQ5OEY6JG4TEATVQOUWDA5CNFSM5XP3DLKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIVPBLWA.gif> Message ID: ***@***.*** ***@***.***> >
|
It took me some time to recall that the "connect-the-dots" property is named "scatterLines", with its getter/setter methods. That's ok, but it confuses me. In my attempted implementation, I added keys 'smooth' and 'connected' with boolean values in the property $lineStyleProperties. I then defined $scatterLine as an object described by the many getter/setter methods dealing with LineStyle/Color/Shadow/Glow/SoftEdge special effects. I'm still figuring out how to describe all of the properties of each DataSeriesValues objects in my proposed chart. I must modify the methods which I was close to implementing. No worries. I am working hard to do it. |
33_Chart_create_Color_scatter.php.txt Success. Not the prettiest code you will see. Feel free to clean things up as you see fit. |
Please do not double-post in this thread and the PR. I have adopted several of your suggestions in my latest commit; your code sample is incorporated into the existing 33_chart_create_scatter2. There was a slight mismatch between your code and my changes; previously, you needed to set a marker shape in order to support marker colors, and your code didn't do that. I have changed so that this is no longer necessary; I explicitly set the marker shape for 2 of the 3 series in the updated sample, and leave it unset for the other. Is "scatterlines" applicable to other types of chart? I can certainly consider making it part of line styles if so. I think I added it after the latest release, so that wouldn't be a breaking change at this point. |
Got it.
I don’t see how ‘scatterlines’ can apply to other chart types. Type LINECHART has the possible converse relation between points and line – the points can be hidden or displayed. With type SCATTERCHART, the points are always present, and the line can be hidden or displayed. However, I confess to small experience with any chart type than SCATTERCHARTs.
From: oleibman ***@***.***>
Sent: Saturday, June 25, 2022 11:46 PM
To: PHPOffice/PhpSpreadsheet ***@***.***>
Cc: bridgeplayr ***@***.***>; Author ***@***.***>
Subject: Re: [PHPOffice/PhpSpreadsheet] Scheme colors in Charts (Issue #2863)
Please do not double-post in this thread and the PR. I have adopted several of your suggestions in my latest commit; your code sample is incorporated into the existing 33_chart_create_scatter2. There was a slight mismatch between your code and my changes; previously, you needed to set a marker shape in order to support marker colors, and your code didn't do that. I have changed so that this is no longer necessary; I explicitly set the marker shape for 2 of the 3 series in the updated sample, and leave it unset for the other.
Is "scatterlines" applicable to other types of chart? I can certainly consider making it part of line styles if so. I think I added it after the latest release, so that wouldn't be a breaking change at this point.
—
Reply to this email directly, view it on GitHub <#2863 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AYXANOAXGY4BCCUGRAUNWHDVQ74B5ANCNFSM5XP3DLKA> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/AYXANOH5HPOJ5QKWNNOTJNTVQ74B5A5CNFSM5XP3DLKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIWDFLNI.gif> Message ID: ***@***.*** ***@***.***> >
|
FYI, there is a typo in Chart/Properties.php |
I might be wrong, but it's deliberate, not a typo. When I tried setting the property to 'round' in Excel, I thought the XML nevertheless specified 'bevel'. If you think otherwise, I will try that experiment again. |
I changed a chart line join property to 'round' in Excel, and the xml also showed 'round'. |
Okay, I will take another look. |
My latest push is probably the one where I'm done tinkering. Have a look. I did change 'round', but I haven't been successful in creating an Excel spreadsheet that uses it. Please upload yours and I'll incorporate some tests for it in my next PR. |
Glad to do it. |
Small changes to samples/Chart/33_Chart_create_scatter2.php:
33_Chart_create_scatter2.1.php.txt |
Why is ROUND_DOT a better test than SQUARE_DOT? |
Oops. WRONG round. Retrying with JOIN instead of DASH. In my own version, I included the yAxis, but in the edited version of the released sample, I neglected to add it to the chart. If added, it will work. Yes, its impact is hard to see. But it is in the xml, which is all that counts. |
Results of experiments with 33_Chart_create_scatter2.1.xlsx
To try something else with LineStyle properties, I added a border around the Title, with these settings which I kept constant:
Here are the results of changing the JOIN setting of the Title border:
Bottom line:
|
I will make one more push tonight. The results of using schemeClr for Axis lines wasn't entirely satisfactory - it's in the Xml, but you can't see it in Excel. This might be another case where Excel is acting on its own - perhaps accent2 used a certain way means one color, but used in another way means a different color. I will use srgbClr for this demonstration. |
* Additional Support for Chart DataSeriesValues 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: - 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). * Update Change Log I had updated previously but forgot to stage the member. * Adopt Some Suggestions Incorporate some changes suggested by @bridgeplayr. * Use ChartColor for DSV Fill And Font Text DataSeriesValues Fill could be a scalar or an array, so I saved it till last. * Some Final Cleanup 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.
Well done. These are big improvements. |
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)
This is:
See also issue #2299 and fix #2828
What is the expected behavior?
PhpSpreadsheet/Chart/DataSeriesValues.php and PhpSpreadsheet/Writer/Xlsx/Chart.php should support "Scheme colors" as well as RGB colors (both string and hex value), for lines, markers, and fill properties. Scheme colors are available in 4 "colorful" palettes and 11 "monochrome" palettes. These built-in palette colors are labeled as 'schemeClr', [string] in xml attributes.
E.g. xml snippet: <a:schemeClr val="accent6">
What is the current behavior?
Phpspreadsheet Chart does not currently support these colors, which are the default (automatic) colors when none is chosen by the user.
What are the steps to reproduce?
33_Chart_create_scatterManual.xlsx
Attached is a manually modified version of the chart produced by '33_Chart_create_scatter2.php' which demonstrates several unsupported properties related to SchemeClr, as well as unsupported line properties demonstrated below:
<c:spPr>
<a:ln w="31750" cap="sq" cmpd="tri"> width, cap type, compound type
<a:solidFill>
<a:schemeClr val="accent1"> palette color
<a:alpha val="60000"/> transparency ?
</a:schemeClr>
</a:solidFill>
<a:prstDash val="sysDash"/> dash type
<a:miter lim="800000"/> miter
<a:headEnd type="arrow" w="med" len="sm"/> arrow-head type, width, size
<a:tailEnd type="triangle" w="med" len="lg"/> arrow-tail type, with, size
</a:ln>
</c:spPr>
Note: Bezier (smooth) line property is the very last attribute of a data series:
...
</c:v>
</c:pt>
</c:numCache>
</c:numRef>
</c:yVal>
<c:smooth val="1"/> Bezier line designation
Marker properties
Markers types and sizes are now supported properties.
Marker fill colors and marker border colors are not supported quite right yet. (even in the cloned version from a week ago).
<a:schemeClr val="accent1"> for the first dataseries,
<a:schemeClr val="accent2"> for the second, and so on.)
e.g.
<a:ln>
<a:solidFill>
<a:srgbClr val="002060"/>
</a:solidFill>
</a:ln>
<c:marker>
<c:symbol val="square"/>
<c:size val="7"/>
<c:spPr>
<a:solidFill>
<a:schemeClr val="accent6">
<a:alpha val="97000"/>
</a:schemeClr>
</a:solidFill>
<a:ln>
<a:solidFill>
<a:srgbClr val="0FF000"/>
</a:solidFill>
</a:ln>
</c:spPr>
</c:marker>
I have not been successful in creating php code to implement these new properties with setter/getter methods, but they can probably be implemented in ./Chart/DataSeriesValues.php (& maybe ./Chart/Properties.php) and ./Writer/Xlsx/Chart.php
None of the above properties are propagated to any other files (like ./xl/drawings/drawingsN.xml) as I feared they might. Good news.
If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.
What features do you think are causing the issue
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
I have not experimented with any format other than xlsx.
Which versions of PhpSpreadsheet and PHP are affected?
1.23 & 7.3
I didn't forget. I'm just slow (& old).
The text was updated successfully, but these errors were encountered: