mitoteam / jpgraph

JpGraph library composer package with PHP 8.4 support
https://packagist.org/packages/mitoteam/jpgraph
Other
36 stars 5 forks source link

Cannot Use Autoscaling #9

Closed oleibman closed 2 years ago

oleibman commented 2 years ago

There are a small number of rendering issues with PhpSpreadsheet, and I am investigating those now. Some are memory-related, and I will try to fix those on my own. Two look like a change in code is needed in PhpSpreadsheet and/or Jpgraph. I need your help to figure out which (I do need to study what exactly we pass to you). This is the first of those two; I will probably submit the other tomorrow.

In PhpSpreadsheet, all of our rendering samples read an existing spreadsheet and pass any charts on it to Jpgraph. We have a sample file 32readwriteBubbleChart2.xlsx which was created by 3rd-party software. Most charts on spreadsheets cache the values of their data points in the Xml; however, this one does not, and that's probably the source of the problem. When we try to render this chart, we get the following error message:

Error rendering chart: Cannot use auto scaling since it is impossible to determine a valid min/max value of the Y-axis (only null values).

I am not sure if auto scaling is required by your software. If it is not, is there a way we can turn auto scaling off when we pass our chart to you. Alternatively, is it possible for you to silently accept the fact that it's impossible and continue rendering without it?

I can certainly supply the spreadsheet, and the code which attempts to render it, if you need those.

f1mishutka commented 2 years ago

Hi,

Sure I'll try to help. Please provide me with code that causes thos error for I to be able to dig deeper in jpgraph sources.

Is this under php 8.1 or 8.2 ?

oleibman commented 2 years ago

Result is same for all Php. Preparing a file for you.

oleibman commented 2 years ago

Sending you the entire directory, which is probably overkill. The spreadsheet in the main directory is 32readwriteBubbleChart2.xlsx; the script which tries to extract its graph is 35_Chart_Render.php. It is designed to run under Php CLI. It uses your 10.2.2 release. The composer commands that I used to create the software directories is:

composer require phpoffice/phpspreadsheet:dev-master
composer require --dev mitoteam/jpgraph

bubble2prb.zip

f1mishutka commented 2 years ago

Need some help from you.

Please take a look at screenshot: https://prnt.sc/vQSJCsiCA815

Trying to debug this and I see the Plot->Min() and Plot->Max() returned string with range definitions instead of data. And JpGraph expects numeric values at this point.

The question is: Is there any chance that this formulas are forgotten to replaced with actual data at some point in PhpSpreadsheet's code? may be somewhere in renderBubbleChart() ?

P.S.:

I am not sure if auto scaling is required by your software. If it is not, is there a way we can turn auto scaling off when we pass our chart to you. Alternatively, is it possible for you to silently accept the fact that it's impossible and continue rendering without it?

This is not my software. We provide only composer wrapper for JpGraph library and some patches for latest php versions compatibility. So I can only help to understand reasons of this error. But there is no easy way to modify original JpGraph library.

Anyway lets try to understand reason of this error first. Then I'll think about fix for it. May be we can do some small patch to library sources.

f1mishutka commented 2 years ago

I tried to comment out autoscaling in library code to see what will happen. And there is another error message: Either X or Y data arrays contains non-numeric values. Check that the data is really specified as numeric data and not as strings. It is an error to specify data for example as '-2345.2' (using quotes).

Could you please help me to understand where data are taken from spreadsheet and provided to jpgraph for rendering? There is definitely should be some type conversion (may be in renderPlotScatter() but I'm no sure).

Attached is patched jpgraph version with autoscaling suppressed instead of raising exception for you to be able to do experiments with bubble charts.

vendor-mitoteam-jpgraph.zip

oleibman commented 2 years ago

Thanks for the quick analysis. You seem to be reaching the same conclusion as my original guess - the data is missing. When we read the chart, we don't actually calculate the data points - we just do enough to be able to replicate it (Excel itself fills in the missing data when needed as long as it has the addresses for the missing data). There's a lot more in your answer that I need to look at, but it sounds like this one may not be resolvable. (And I don't think that's a terrible result, just as long as I can document why it doesn't work.)

f1mishutka commented 2 years ago

Please let me know if I can help with something else.