xiaokui

saving images

Recommended Posts

hi there,

is there any way to display a chart using Fusion Charts and then save it as an image like a jpg or gif?

when you right click on a graph, options appear such as print etc...

is there ever any plans to include a 'save as' option?

damien.

Share this post


Link to post
Share on other sites

FusionCharts is rendered on the client side using Adobe Flash Player. Essentially, FusionCharts is a set of .swf files, which when requested by the users, downloads on his/her machine, reads the XML data and then plots the chart.

Owing to limitation of Flash Player itself, which doesnt allow saving the end output of the chart as image, FusionCharts too is bounded by the same limitations. As such, you cannot directly save the charts as bitmap/image/PDF.

Indirect ways of saving chart image are:

- You can third party tools like www.flashcapture.com to take one-click screenshots of the generated charts and then use it.

- You can use PDF Print drivers like www.pdf995.com to save the chart as PDF (by capturing it from Print Stream of your Operating System).

Share this post


Link to post
Share on other sites

thats not right. there is a way you can generate jpg files in flash!

 

 

 

check out the following sites:

 

 

 

http://www.sephiroth.it/tutorials/flashPHP/print_screen/

 

on the end of the side you have print button in a flash movie and then you get a jpg file

 

 

 

http://www.quasimondo.com/archives/000572.php

 

here you can draw something and then get a jpg of it

 

 

 

 

 

it would be perfect if you can render a jpg on the webserver itself!! i need this function because i want to export the chart at serverside to a pdf file. but pdfs can only display image files!

Share this post


Link to post
Share on other sites

Hi,

 

 

 

We're doing the client side image saving functionality implementation and it will be a part of the next release.

 

 

 

As for server side generation, I'm afraid that's not yet feasible, as the charts are generated at client side.

Share this post


Link to post
Share on other sites

Starting FusionCharts v3.0.5, you can now export your charts as images. You may read more on it at:

 

 

 

http://www.fusioncharts.com/docs/Contents/SAIOverview.html

 

http://www.fusioncharts.com/docs/Contents/SAISetting.html

 

 

 

A live demo is at http://www.fusioncharts.com/GalleryChart.asp?id=1 - just right click on the chart and select "Save as Image".

Share this post


Link to post
Share on other sites

Great work there ! Implemented it straight away and have a question.

 

the Pie3D in download package 3.0.5 is Version 3.0.4 (:) itself.

 

now i cannot save image on this chart (all others i use work well) the link to save the image is in the right-click menu though.

 

maybe its related to the version not being 3.0.5 in any way?

 

 

 

link to testpage

 

 

 

thanks, thomas

Edited by Guest

Share this post


Link to post
Share on other sites

Thomas,

 

 

 

v3.0.4 (:) of pie/doughnut supports image saving. It's an internal versioning number that we have flagged for bug tracking.

Share this post


Link to post
Share on other sites

Chart saving is a great addition, thanks so much!

 

 

 

I would like to reiterate the questions above:

 

 

 

 

1. are you able to start saving the image process via javascript??

 

2. when i start via javascript is it possible to hide the "Image generating.." dialog?

 

 

 

 

Is there a way (or could there be) to request the image version. IE. If I wanted to (dynamically / automatically) create a print version with static images, so I wanted the image to show up not the flash version?

 

 

 

Also is there a way to pass additional arguments to the save script? IE. a filename?

 

 

 

These two things would be amazing.

Share this post


Link to post
Share on other sites

In my web application, I want to be able to export my data. I have a table of data and below it - fusion chart. Now, I want to export those into Excel or PDF. I can export the table data into Excel or PDF fine, but is it possible to export the chart/graph image into the Excel or PDF as well?

Share this post


Link to post
Share on other sites

Wouldn't it be easy to register a new external interface (just like setDataURL and setDataXML), say sendImageToClient, to facilitate the save image function to javascript? This way, it would be easy to add an save image button to an html page. I would greatly appriciate this functionality :).

Share this post


Link to post
Share on other sites

I'm using FusionCharts with Ruby on Rails and this new feature is great... unfortunately there doesn't seem to be the server side component for this yet in Rails. From anyone who has coded this in the other languages, do you think this lightweight PNG gem would be able to handle the chart data?

 

 

 

http://rubyforge.org/frs/shownotes.php?group_id=1513&release_id=10680

 

 

 

Or are we better off looking at RMagick?

 

 

 

http://rmagick.rubyforge.org

 

 

 

~Thanks

Share this post


Link to post
Share on other sites

Hi,

 

 

 

You'll have to chalk out similar code using RMagik, as you basically need a server side image generation script, which takes in pixel values and renders a JPEG out of that.

Share this post


Link to post
Share on other sites
ArkITechT (1/8/2008)

 

Is there a way (or could there be) to request the image version. IE. If I wanted to (dynamically / automatically) create a print version with static images, so I wanted the image to show up not the flash version?

 

 

 

 

I agree.

 

To be able to trigger the Image creation and create a print view of pages using one or more charts would inrcrincrease products already very high quality even further.

 

I am sure more users would find this feature very useful.

 

 

 

Thanks for a very good product.

 

 

 

// Henrik

Share this post


Link to post
Share on other sites

This export to image feature is really good.

 

Being able to trigger the export to image programatically, either by javascript or on the xml itself, would make it great.

 

 

 

Tkx a lot for a great component,

 

Tiago Sim

Share this post


Link to post
Share on other sites

Hi,

 

 

 

I'm interested also in the server side saving of the chart's image. Same as one of the previous posts, I would need to do an export in a pdf file of web pages that should include also the images of the flash charts that are embedded in that page.

 

Is there any solution for this? Did anybody try something like this within a Java/JSP or similar Java environment?

 

 

 

Thanks in advance,

 

John.

Share this post


Link to post
Share on other sites

If you're cool with PNGs, here's some Ruby code to take the FusionCharts data and return it as a PNG. Please let me know if you find any bugs in it, but it's been working well for me so far. I have this saved in my controllers as graph_controller.rb

 

 

 


# * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

# * FusionChartsSave for Ruby on Rails (Jan 21 2008)

# * Requires PNG gem from http://seattlerb.rubyforge.org/

# * PNG is an almost-pure-ruby PNG library. 

# * 

# * sudo gem install -y png

# * 

# * The default location for the imageSaveURL would be:

# * imageSaveURL='/graph/imagesave'

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

require 'png'



class GraphController < ApplicationController



def imagesave

 #### Prevent Memory abuse

 maxwidth  = 1024

 maxheight = 1024



 width   = params[:width].to_i

 height  = params[:height].to_i

 bgcolor = params[:bgcolor]

 cdata   = params[:data]



 if width > maxwidth

return nil

 end

 if height > maxheight

return nil

 end



 if bgcolor.nil?

bgcolor = PNG::Color::Background

 else

bgcolor = PNG::Color.from "0x#{bgcolor.rjust(6,'0')}FF"

 end



 canvas = PNG::Canvas.new width, height, bgcolor



 # Keep count of which row we are on in our loop. Start on the top and draw down.

 ycount = height - 1



 rows = cdata.split(";") 



 rows.each do |row|

### Reset the count for each new row

ri = 0



pixels = row.split(",") 

pixels.each do |pixel|

	c,r = pixel.split("_")



	if c.length > 0 

		x = 0

		mycolor = PNG::Color.from "0x#{c.rjust(6,'0')}FF"

		while x < r.to_i

			#point function will prevent drawing outside of canvas

			canvas.point(ri + x, ycount, mycolor)

			x += 1

		end

	end



	ri += r.to_i

end



#Move down to the next row

ycount -= 1

 end



 png = PNG.new canvas

 send_data(png.to_blob, {:type => "content-type:image/png", :stream => true, :filename => "FusionCharts.png"})



end



end

Share this post


Link to post
Share on other sites

Hi, Are you able to help?

I am trying to save a chart and when I click on the "Save as Image" option on the chart, it runs through the sequence "Capturing Data" until it reaches 100% but then the browser goes on to display the "Image Saving" file (eg. FusionChartsSave.aspx) I set the URL to?

I have tried different image saving files with no success.

An example of what appears in the browser if I use FusionChartsSave.aspx...

<%@ Page Inherits="FusionChartsSave" Src="FusionChartsSave.cs" Debug="true" validateRequest="false" %>
There seems to be an error with the "validaterequest" field.
I think Fusionchart is a great tool and would really appreciate any help.
Thanks in advance. James

Share this post


Link to post
Share on other sites

Hi,

 

 

 

I'm trying to use the posted Ruby code, but I'm having trouble getting RubyInline to work on my windows machine. Is there anyone who can help

 

 

 

me get this code working on a windows machine? ie. maybe a walk-through of how you got it working.

Share this post


Link to post
Share on other sites

i have the same problem as yumi001

 

 

 

But then I changed the file from .aspx to .jsp. Now I can save the image, but it looks like crap. For example the Xaxisname isn't displayed.

 

 

 

How do u solve this?

Share this post


Link to post
Share on other sites

Some more information regarding the PNG/Ruby implementation would be great. I was wondering how you are calling the action in that controller and where the params are coming from, especially the 'cdata' object with all the pixelvalues.

could you maybe elaborate on how you go from a FusionChart to this piece of Ruby code?

Share this post


Link to post
Share on other sites

hello folks

 

 

 

there are so many people out there which have the same problem: render image file from swf on the server.

 

 

 

i found a way to do this!!! i will implement it in the next few days and will share my work with you.

 

 

 

hold on some days :)

Share this post


Link to post
Share on other sites

Here's some more info on the Rails fix.

First, I updated my "imageSaveURL" to be this:

 imageSaveURL='/graph/imagesave'

This should be wherever you're currently writing out your "<chart ..>" tag (mine happens to be in a app/model/graph.rb file we wrote... but it's probably more correctly a view feature, whatever)

As long as you're using the updated FusionChart, when you right click your flash graph and tell it to save, the flash object POSTs data to the graph/imagesave page (app/controllers/graph.rb). It will send a "data" paramter with all the image information. That's what I'm loading into "cdata" near the top (along with the other POST parameters being sent from the Flash object).

cdata = params[:data]

Outside of that, it's pretty much a coversion of the PHP code from FusionCharts. I've only tried this on Linux boxes with Rails (1.2.x) so I'm not sure if there's any strange Windows issues (I've read Ruby Inline for windows requires a compiler to be installed, which could be a pain... http://www.thewebfellas.com/blog/2007/12/2/imagescience-and-rubyinline-on-windows ). The PNG gem requires Ruby Inline which is why you need this. The alternative would be to rewrite the script to use RMagick... which can be a pain to install on unix systems (and why I went with the PNG gem, but that sounds like it might be simple to install on Windows).

 

I did notice a bit of an issue when I deployed this into production. If your rails process is not running as root (which it shouldn't be for security reasons), you might get an error about permissions writing to "/root/.ruby_inline". The PNG plugin uses Ruby Inline which needs to write some object files out when it runs (and compiles its C code/objects).  Here's the way I fixed it by explictly setting the HOME env variable. My rails process runs as the user "mongrel". Change that line as needed below, but I placed this in a file config/initializers/ruby_inline.rb with the line:

ENV['HOME'] = "/home/mongrel" if ENV['RAILS_ENV'] == 'production'

Share this post


Link to post
Share on other sites

Christian,

 

 

 

Have you done any work on the "render image file from swf on the server." issue? I'm using PHP on the server and I also would like to save the JPG file on the server to be used in a PDF. Please update us on your progress - thanks!!!

 

 

 

FusionCharts Development Team, this would be a very desirable feature to add. SaveAs is nice, but saving to a server is something that real applications can use. I see more and more "on the fly" PDF creation out there in financial applications that would benefit from the slick looking charts from your package. The problem is that none of the Flash charting packages out there allow saving images to the server. It seems as though there are ways to do this as demonstrated by the Ruby/Rails developer in this forum and by Christian who says he knows how as well. Please consider adding this feature or at least publish the PHP/server side code to do it in this forum.

 

 

 

Thanks!!

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