Giter Club home page Giter Club logo

jpgraph's People

Contributors

f1mishutka avatar pryx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

adolphgithub wtom

jpgraph's Issues

User font with absolute file path is not working

JpGraph always prepends font file path with dirname(__FILE__).'/fonts/' path. So it is impossible to use custom TTF fonts outside JpGraph sources folder.

Example:
$graph->SetUserFont1('/var/lib/my-fonts/font/Roboto-Regular.ttf');

Solution: do not prepend font file path if it already starts from root ('/').

Better Windows OS detection under Cygwin

I stumbled across this by accident, and it isn't all that important for PhpSpreadsheet since Cygwin Php is frozen at 7.3 and PhpSpreadsheet will soon stop supporting that release. But ...

In several places in jpgraph.php, it is coded:

if (strstr( PHP_OS, 'WIN' ) {

with the intent of differentiating Windows from other systems. Unfortunately, that coding has the effect of treating Cygwin as Windows, when it should be treated as other, and we consequently fail in Cygwin. These checks might just as easily be replaced with:

if (PHP_OS_FAMILY === 'Windows') {

Now we should succeed in Windows, Cygwin, or anywhere else.

Question About Image Size

Question About Image Sizes

This is a question; it is definitely not a bug report. A user sent us a spreadsheet which they tried to convert to Html, but it was missing the charts. There were several problems. The first was user error. The second was a bug in our software which I will fix (only 2 of the 3 charts made it to the Html). The third leads to my question.

According to Excel, the first chart is 3.05" high and 4.71" wide. The second chart is 2.62" high and 4.53" wide. The third is 2.62" high and 4.48" wide. I don't know where these values are stored in the xml. I think they are not part of the Chart object which we pass to the renderer. They may be part of the Drawing object (<xdr:to><xdr:colOff> etc.) which is not passed to the renderer, and which I haven't any idea how to convert to human terms.

When each of these charts is passed to the renderer, it returns a diagram which is 640px wide and 480px high. If one inch is 96 pixels, this is about 6.7" by 5", much larger than the original. This results in the diagrams in the html overlaying each other, so they wind up with pieces cut off. Is the renderer getting those values from something in the chart xml, or is it a default value? If it is a default, and I somehow figure out what the width and height ought to be, can I somehow specify those values to the renderer?
issue.3767m.3.zip

Deprecation error

Version 10.2.6
PHP Deprecated: Implicit conversion from float to int loses precision in .../jpgraph.php on line 4068

jpgraph/src/lib/jpgraph.php

Lines 4067 to 4069 in 9b2a355

if( isset($this->ticks_label[$i *(int)$m]) ) {
$label=$this->ticks_label[$i*$m];
}

Obviously fixed by adding another (int) cast, which seemed like overkill for a PR.

Many thanks for maintaining this library.

Implicit conversion from float 113.49999999999999 to int loses precision

Hi,
I try jpgraph with PHP 8.1 and when I want to display error
$e = new JpGraphException('not enough data to plot the graph!'); $e->Stroke();
error message show: Implicit conversion from float 113.49999999999999 to int loses precision
jpgraph_rgb.inc.php:562] imagecolorresolvealpha()
gd_image.inc.php:1128] RGB->Allocate()
jpgraph_errhandler.inc.php:305] Image->SetColor()
jpgraph_errhandler.inc.php:156] JpGraphErrObjectImg->Raise()

Php 8.2

Now that Php8.2 has reached RC stage, and now that your code seems to be ready for it, what are your plans for a formal release of your package v10.2 (currently available through Composer as RC only)?

Problems with Some PhpSpreadsheet Charts

PhpSpreadsheet is expanding the use of mitoteam/jpgraph in its test suite. It's mostly okay, but there are 2 problems. It could certainly be a PhpSpreadsheet problem, but Excel has no problem with the charts. Can you see anything that needs to be changed on your side, or can you suggest changes on our side, to eliminate the problems. Details are in the attached zip file.
stacked.zip

Warning Generating Pie3D

This is the second problem I'm seeing. I am certain it is completely unrelated to the first problem. In this case, the output chart is generated and looks pretty good, but there is a warning message while it is being created:

[13-Sep-2022 08:51:50 America/Los_Angeles] PHP Warning:  A non-numeric value encountered in C:\git\bubble2prb\vendor\mitoteam\jpgraph\src\lib\jpgraph_pie3d.php on line 656

I can send the rest of the stack trace if you need it (it's pretty long). We have a similar problem with an Exploded Pie3D chart, but I assume the explanation is the same in either case. I am attaching a zip file containing the new spreadsheet, the new Php script, and the output file. You can just put the spreadsheet and the script in the same directory I sent yesterday and run the script to see the problem. Please let me know if there's anything we might do to avoid the warning message.
pie3d.zip

Cannot Use Autoscaling

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.

Internal fonts not available when using code extracted from jpgraph-main.zip

Any attempts to use the built in fonts that JPGraph provides results in an error saying the the fonts are not available (see attached image). Simply removing the attempts to use the built in fonts allows the graph to be rendered correctly.

Code that does NOT work (this is example 3.0.3 from the "official" JPGraph package):

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
$ydata = array(17,3,'',10,7,'',3,19,9,7);
$width=350;
$height=250;
$graph = new Graph($width,$height);
$graph->clearTheme();
$graph->SetScale('intlin');
$graph->SetShadow();
$graph->SetMargin(40,20,20,40);
$graph->title->Set('NULL values');
$graph->xaxis->title->Set('x-title');
$graph->yaxis->title->Set('y-title');
$graph->yaxis->title->SetFont( FF_ARIAL , FS_BOLD, 9 );
$graph->xaxis->title->SetFont( FF_ARIAL , FS_BOLD, 9 );
$graph->yaxis->SetColor('blue');
$lineplot=new LinePlot($ydata);
$lineplot->SetColor( 'blue' );
$lineplot->SetWeight( 2 );   // Two pixel wide
$graph->Add($lineplot);
$graph->Stroke();

If you comment out the 2 SetFont lines the graph will render.

Screenshot 2022-03-07 114902

using with phpspreadsheet

phpoffice / phpspreadsheet documentation shows using jpgraph with it, but the old composer version is no longer supported and the built in jpgraph is quite old (no longer supported either).

So I installed this mitoteam/jpgraph package via composer thinking this would do the trick. In my php code I added the phpspreadsheet line:

use mitoteam\jpgraph\MtJpGraph
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraph::class);

But I am getting a Fatal Error on the Settings::setChartRenderer line - does anyone have any idea on how to get the two to work together? I am assuming I am not calling it correctly in the Settings command.

Please don't flame me on this. I know this isn't a mitoteam issue, but I am desperate to get this working as I have a deliverable to a client and I have been spinning my wheels on this for two days.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.