Exporting Image to Server Disk not working

Recommended Posts





I have followed all directions for exporting image to server disk for Ruby on Rails, as seen in the documentation and the "Readme.txt" found in the exporter folder for RoR.




I can't get any of the image-exporting code to execute.






Here's what I have:






/app/controllers/Fusioncharts => fc_exporter_controller.rb, fc_exporter_img_controller.rb, fc_exporter_pdf_controller.rb


/lib/fusioncharts/exporter => error_handler.rb, error_messages.rb, generator.rb, properties.rb, save_helper.rb


/app/views/fc_exporter => error.html.erb




THE XML IN MY CONTROLLER (code won't show, follow link to pastie):




MY VIEW (with callback JavaScript):












FusionCharts v3.1 (developer license)


RMagick 2.9.0 and it's dependencies


Rails 2.1.0 and it's dependencies






I also have puts statements, e.g.


puts "fc_exporter => index"


for every action, and for every file in the /app/controllers/Fusioncharts directory. This is so I can look at the console and see if any of the code is being executed, and none of it is being executed.




A PNG image of the chart should be stored in the /public/images/charts directory -- but it's not!




The chart otherwise shows up on the page perfectly.




If I right-click on the chart and select 'Save as PNG' the "capturing data" progress bar shows and appears to complete, but no image is being stored in /public/images/charts. The image might have been stored elsewhere, but I was unable to find it.






What am I missing? Thanks in advance!!







Share this post

Link to post
Share on other sites


First up, I would like to thank you for posting an elaborate and clear question, with all the relevant code!

Perfect forum user, I should say. Thank you. :)

To post the code in this forum, you have to enclose the code within [ code ] [ /code ] ( without the spaces ) .

Moving to the problem at hand, I could not spot any problem with the configuration or the code.

Could you please check the following:

1. RMagick works for a simple code from their examples

2. ImageMagick opens images

3 Whether download is working. Change exportAction='download' in the xml and see what happens.

Lets proceed based on the results of these checks.

Srividya :)

Share this post

Link to post
Share on other sites

Voila! I did happen to get an image saved to the server disk. For some reason, Rails got confused and couldn't find fc_exporter.rb, so I just plugged in the full path and it worked.




However, the image was not produced automatically. I had to right-click and select "Save as PNG".




Please tell me it is possible for the image to produced without having to manually click on "Save as PNG". There must be a way, with the web anything is possible.




If this is not possible, I'm afraid FusionCharts is not for me. Do you think they would give a refund? I've only had the license for about 3 days. This is 200$ we spent for the sole purpose of server-side image rendering of the chart.




If it is possible to render the image without user interaction, please enlighten me.




And by the way, RHTML is not visible in the forum when I use the [ code ] IFCode shortcut. I think some of the Ruby code didn't show either. It just shows up as blank space. I prefer anyway because of its nice color schemes and formatting.






At any rate, I much appreciate the help. :)




~ fiend

Edited by Guest

Share this post

Link to post
Share on other sites


You can use javascript to do the work for you.

As soon as the chart is rendered, in the javascript function ( FC_Rendered is the callback function, please see  ), you can begin the export of the chart.

To initiate export from javascript, you would use code similar to the following:

   var chartObject = getChartFromId('myChart');
	if( chartObject.hasRendered() ) chartObject.exportChart();

Please refer to:

So the user does not have to manually right click and export the chart.

Hope this is what you are looking for. :)


Edited by Guest

Share this post

Link to post
Share on other sites

Thank you so much for the help! I am on the right track now, it appears as though the chart is auto-exported after it is rendered via JavaScript, yet I am running into a problem when the image is "drawn".




I put many console output "puts" statement to find the trail of execution. Right after RMagick does it work, in the file "/lib/fusioncharts/exporter/generator.rb", the trail of execution gets caught in a loop at the bottom of the "get_image" action. Evidently an infinite loop occurs when


is called, which my IDE reports is the Ruby method RDoc::diagram.draw. However, the object "draw" was created with the line

draw =

which leads me to believe the "draw" action is actually part of RMagick.




Backtracking, I reverted my code back to how it was with the render_chart_html method, and tried right-clicking on the chart and selecting "Save as PNG", which worked perfectly before. Now it is doing just as I said, it gets locked up in an infinite loop, and the image is never actually saved. Looking at the running processes, Ruby starts using up more and more resources, and the only way to stop it is to stop the server. The browser, as it often does in this situation, does not halt and report an infinite loop.




Not sure what happened, the original render_chart_html method was working fine before.




I ran the tests on RMagick and ImageMagick with some sample code, and both appear to be working fine. I restarted my PC and that did not fix it either.




My code, I believe, is just as it was before in my last post in this thread.






Any idea what this could be?




Thanks again for all the help!




~ fiend






PS. the 'd' characters following the double colon '::' with RMagick::draw and RDoc::diagram should actually be a capitalized 'D' character. Even with the [ code ] IFCode shortcut, it turns ":: D" (without space) into ::) The [ code ] shortcut doesn't really do much! :)

Edited by Guest

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now