problem with png files

Share RGraph:   Share or Like RGraph on Facebook!

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Lorenzo on 29th July 2014
HI,
a month ago, more or less, I created some php files on my web space, using RGraph JS libreries. Each of these files, when run from my local browser, read the data from an external source and plot them in a chart. This chart is then saved as a .png file on my web space. The .png file is ten displayed on a web page. All this worked perfectly until yesterday. Today, the php files run correctly, but the file png are no longer stored on my web space. So, no more charts in the web page :-/ You can see the result here (see the empty charts scrolling down the page):

www.hamradioweb.org/solarhrw.htm

Any help, please ?

Thanks

Arturo

Posted by Richard on 29th July 2014
What's changed from when it was working? Have you or someone else upgraded or changed anything? There's nothing in the console - but there's an awful lot of network requests going on - most of which seem to be cancelled.

You'll find it hard to debug a page like that so start with a cutdown page that has just one chart and have that upload the image of the canvas by AJAX in the same way.

You can see that happening if you press CTRL+SHIFT+J in Chrome and go to the Network panel.


Richard
Posted by Lorenzo on 29th July 2014
Thanks Richard for the answer.
Anyway, the web page I linked above is not the problem. I can make a simple page with only one chart, but the result is exactly the same: empty chart :-/

It seems that the .png file is no longer correctly stored on my web space, so the web page containing the address of that file does show an empy chart. I have not updated or changed anything in the files. Simply today morning empty charts !
I have come to suspect that something has been changed on the server by the hosting service. I wrote to customer service and I'm waiting for the answer.

Arturo
Posted by Lorenzo on 29th July 2014
In the meantime I tried to load everything on a different web space (altervista.org), but the result is the same! Charts empty. I can not at this point to explain why everything worked fine until yesterday and today but no. >:-(
The code I used to create the file .png is this :


var image_data = canvas.toDataURL("image/png");
  $.post("save_chart_line.php", { src: image_data } );
         });
     }
  
     $filename = 'grafico_line.png';
     $src = $_POST['src'];
     $src = substr($src, strpos($src, ",") + 1);
     $decoded = base64_decode($src);
     $fp = fopen($filename,'wb');
     fwrite($fp, $decoded);
     fclose($fp);


Arturo
Posted by Richard on 29th July 2014
See what the image_data variable contains using: alert(image_data); Then you could also check that the file is being created. If not you could check the file permissions and stat debugging the PHP.


Richard
Posted by Lorenzo on 29th July 2014
It's incredible, until yesterdy everything was running well. Today I'm no longer able to see the file .png :-/
The file .png is being created, I'm sure, because I see it via ftp but it is too short, only 21 kB bytes compared to 85 kB until yesterday. I don't understand why :-/
Posted by Richard on 29th July 2014
Then your PHP might be the issue. Check that it's writing the data correctly - and that it has the right amount of data. You can use something like print() to view the data that it's trying to write - and you could measure its length with strlen().





Richard
Posted by Lorenzo on 30th July 2014
Nothing to do :-(
I tried to download phantomjs, it seems to work but only with one of the php pages containing my charts.
Please, in the next version of RGraph, can you add a funtion to create directly a png o jpg files of the charts ? Thanks in advance.

Arturo
Posted by Richard on 30th July 2014
You can't do that with JavaScript - the best you can do is POST the canvas via toDataUrl() back to the server - which is documented here:

www.rgraph.net/docs/integration-with-server-side-scripting.html#image





Richard
Posted by Lorenzo on 30th July 2014
In fact I used this way , toDataUrl(), but for a strange reason that I don't understand, it worked until a day ago. Then no more !?!
Anyway, just to see if I got it right, can I send you via email one of the php files containing the code to create the chart and save it as image ?

Arturo
Posted by Richard on 30th July 2014
The code at the URL works. But if you haven't changed the PHP that you're using it's unlikely to be that. Try logging PHP errors to a file to see if it's that.

Richard

Add a reply




« Back to message list