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

Scatter plotStyle not working #1431

Closed
cwolcott opened this issue Mar 31, 2020 · 10 comments
Closed

Scatter plotStyle not working #1431

cwolcott opened this issue Mar 31, 2020 · 10 comments

Comments

@cwolcott
Copy link

This is:

- [x] a bug report
- [ ] 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?

The ScatterPlot chart is shown with MARKERS only instead of LINES & MARKERS.

What is the current behavior?

No matter what the plotStyle is the chart is always shown as LINES & MARKERS.

What are the steps to reproduce?

Use the current chart sample for Scatter 33_Chart_create_scatter.php. Of course change the Chart displayBlanksAs parameter from 0 to 'gap' since this is a known issue.

Change the DataSeries plotStyle parameter from DataSeries::STYLE_LINEMARKER to DataSeries::STYLE_MARKER.

Which versions of PhpSpreadsheet and PHP are affected?

PhpSpreadsheet 1.10.1
Php 7.4.2

Additional Comments

I am attempting to totally customizing the scatter chart and having several issues. The first step is described above, but next I have tried to setAxisOptionsProperties for the yAxis (min and max) and that doesn't seem to work either.

@cwolcott cwolcott changed the title ScatterPlot plotStyle not working Scatter plotStyle not working Mar 31, 2020
@cwolcott
Copy link
Author

cwolcott commented Apr 1, 2020

Looking through the PhpSpreadsheet code and OpenXml docs everything looks fine on initial inspection.

Writer / Xlsx / Chart.php Line 248
OpenXml / ScatterStyle
OpenXml / ScatterStyleValues

Setting $plotStyle to DataSeries::STYLE_MARKER set the parameter to "marker" which is the correct value in xml for c:scatterStyle.

The XML produced likes fine also:
... <c:plotArea><c:layout/><c:scatterChart><c:scatterStyle val="marker"/><c:varyColors val="0"/> ...

@cwolcott
Copy link
Author

cwolcott commented Apr 1, 2020

Sorry to keep adding to my own issue. I opened the xlsx and changed the plotStyle to Marker only, Line Only, Line and Marker, Smooth Only, Smooth and Marker. I then saved each xlsx to a unique name and extracted the xlsx using 7-Zip. I then opened each xl/charts/chart1.xml file to review the differences.

I am using the following Excels:
Microsoft Office Professional Plus Excel 2013 (Windows)
Microsoft Office 365 ProPlus Excel (Windows)
Microsoft OfficeMicrosoft for MacOS 16.35

I am not sure what versions of Excel that PhpSpreadsheet is compatible with. Here is what I found:

PhpSpreadsheet CREATED - MARKER ONLY

<c:chart><c:title>
<c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:rPr b="0" i="0" u="none" strike="noStrike"><a:latin typeface="Calibri"/></a:rPr><a:t>Test Scatter Chart</a:t></a:r></a:p></c:rich></c:tx>
<c:layout/><c:overlay val="0"/></c:title><c:autoTitleDeleted val="0"/>
<c:plotArea><c:layout/><c:scatterChart><c:scatterStyle val="marker"/><c:varyColors val="0"/>
<c:ser><c:idx val="0"/><c:order val="0"/>
<c:tx><c:strRef><c:f>'Samples-Wells'!$D$3</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>RPN_030320_01a</c:v></c:pt></c:strCache></c:strRef></c:tx>
<c:marker><c:symbol val="circle"/><c:size val="3"/></c:marker>

XLSX SAVED - MARKER Only

<c:chart><c:title>
<c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:rPr lang="en-US" b="0" i="0" u="none" strike="noStrike"><a:latin typeface="Calibri"/></a:rPr><a:t>Test Scatter Chart</a:t></a:r></a:p></c:rich></c:tx>
<c:layout/><c:overlay val="0"/></c:title><c:autoTitleDeleted val="0"/>
<c:plotArea><c:layout/><c:scatterChart><c:scatterStyle val="lineMarker"/><c:varyColors val="0"/>
<c:ser><c:idx val="0"/><c:order val="0"/>
<c:tx><c:strRef><c:f>'Samples-Wells'!$D$3</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>RPN_030320_01a</c:v></c:pt></c:strCache></c:strRef></c:tx>
<c:spPr><a:ln w="28575"><a:noFill/></a:ln></c:spPr>
<c:marker><c:symbol val="circle"/><c:size val="3"/></c:marker>

XLSX SAVED - LINE Only

<c:chart><c:title>
<c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:rPr lang="en-US" b="0" i="0" u="none" strike="noStrike"><a:latin typeface="Calibri"/></a:rPr><a:t>Test Scatter Chart</a:t></a:r></a:p></c:rich></c:tx>
<c:layout/><c:overlay val="0"/></c:title><c:autoTitleDeleted val="0"/>
<c:plotArea><c:layout/><c:scatterChart><c:scatterStyle val="lineMarker"/><c:varyColors val="0"/>
<c:ser><c:idx val="0"/><c:order val="0"/>
<c:tx><c:strRef><c:f>'Samples-Wells'!$D$3</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>RPN_030320_01a</c:v></c:pt></c:strCache></c:strRef></c:tx>
<c:marker><c:symbol val="none"/></c:marker>

XLSX SAVED - LINE & MARKER

<c:chart><c:title>
<c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:rPr lang="en-US" b="0" i="0" u="none" strike="noStrike"><a:latin typeface="Calibri"/></a:rPr><a:t>Test Scatter Chart</a:t></a:r></a:p></c:rich></c:tx>
<c:layout/><c:overlay val="0"/></c:title><c:autoTitleDeleted val="0"/>
<c:plotArea><c:layout/><c:scatterChart><c:scatterStyle val="lineMarker"/><c:varyColors val="0"/>
<c:ser><c:idx val="0"/><c:order val="0"/>
<c:tx><c:strRef><c:f>'Samples-Wells'!$D$3</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>RPN_030320_01a</c:v></c:pt></c:strCache></c:strRef></c:tx>
<c:marker><c:symbol val="circle"/><c:size val="3"/></c:marker>

XLSX SAVED - SMOOTH Only

<c:chart><c:title>
<c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:rPr lang="en-US" b="0" i="0" u="none" strike="noStrike"><a:latin typeface="Calibri"/></a:rPr><a:t>Test Scatter Chart</a:t></a:r></a:p></c:rich></c:tx>
<c:layout/><c:overlay val="0"/></c:title><c:autoTitleDeleted val="0"/>
<c:plotArea><c:layout/><c:scatterChart><c:scatterStyle val="smoothMarker"/><c:varyColors val="0"/>
<c:ser><c:idx val="0"/><c:order val="0"/>
<c:tx><c:strRef><c:f>'Samples-Wells'!$D$3</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>RPN_030320_01a</c:v></c:pt></c:strCache></c:strRef></c:tx>
<c:marker><c:symbol val="none"/></c:marker>

XLSX SAVED - SMOOTH & MARKER

<c:chart><c:title>
<c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:rPr lang="en-US" b="0" i="0" u="none" strike="noStrike"><a:latin typeface="Calibri"/></a:rPr><a:t>Test Scatter Chart</a:t></a:r></a:p></c:rich></c:tx>
<c:layout/><c:overlay val="0"/></c:title><c:autoTitleDeleted val="0"/>
<c:plotArea><c:layout/><c:scatterChart><c:scatterStyle val="smoothMarker"/><c:varyColors val="0"/>
<c:ser><c:idx val="0"/><c:order val="0"/>
<c:tx><c:strRef><c:f>'Samples-Wells'!$D$3</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>RPN_030320_01a</c:v></c:pt></c:strCache></c:strRef></c:tx>
<c:marker><c:symbol val="circle"/><c:size val="3"/></c:marker>

Observations:

Changes that I will attempt to make to PhpSpreadsheet are:

The create a $plotStyle of MARKER ONLY the XML needs to include the following:
<c:scatterStyle val="lineMarker"/> // Will try to keep as marker, but XLSX actually uses lineMarker
<c:spPr><a:ln w="28575"><a:noFill/></a:ln></c:spPr> // Removes the line

@cwolcott
Copy link
Author

cwolcott commented Apr 1, 2020

So here is my final comment for attempting to show a Scatter Chart with a plot style of MARKER only.

  • I still set the $plotStyle to DataSeries::STYLE_MARKER

  • Updated Writer/Xlsx/Chart.php following lines:

  • Change blank line to get the plotStyle to be used in later code
    $plotStyle = $plotGroup->getPlotStyle();

  • Line 1157 add additional check for ScatterChart & STYLE_MARKER to remove lines
    if (($groupType == DataSeries::TYPE_LINECHART) || ($groupType == DataSeries::TYPE_STOCKCHART) || (($groupType == DataSeries::TYPE_SCATTERCHART) && ($plotStyle == DataSeries::STYLE_MARKER)))

  • Line 1168 add additional check for ScatterChart & STYLE_MARKER to remove lines
    if (($groupType == DataSeries::TYPE_STOCKCHART) || (($groupType == DataSeries::TYPE_SCATTERCHART) && ($plotStyle == DataSeries::STYLE_MARKER)))

If I can I will try to remember how to create a Pull Request to submit these changes. If any one can help tutor me I would appreciate it.

@stale
Copy link

stale bot commented May 31, 2020

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 May 31, 2020
@stale stale bot closed this as completed Jun 7, 2020
@AnneBT
Copy link

AnneBT commented Oct 16, 2020

Have you found a solution to the problem? It also seems that the colors of the lines are not taken into account.

@ikisler
Copy link

ikisler commented Mar 2, 2021

Is it possible to get this re-opened? It looks like this is still an issue -- using the sample code in the samples/chart/33_Chart_create_scatter.php, scatter charts do not honor either the STYLE_SMOOTHMARKER or STYLE_MARKER settings, only showing STYLE_LINEMARKER instead.

@JorgeGGOjeda
Copy link

Hi @cwolcott ,
I am trying to custom the marker color on ScatterChart, have you found any property?

@oleibman
Copy link
Collaborator

oleibman commented Jun 8, 2023

See #3428 (comment)

The referenced sample performs:

$dataSeriesValues[0]->getMarkerFillColor()
    ->setColorProperties('accent1', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME);

@JorgeGGOjeda
Copy link

Hi, someone know how add to DataSeriesValues range of separate cells?
Example: Adding values from continus cells
$xAxisTickValues = [ new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$A$1:$G$1', null, 4), ];
but i need something like this:
$xAxisTickValues = [ new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$A$1,Worksheet!$C$1,Worksheet!$E$1,Worksheet!$G$1', null, 4), ];

@oleibman
Copy link
Collaborator

Addressed by, among others, PR #2828 in July 2022.

@oleibman oleibman removed the stale label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants