Dynamic manipulation of an image
FusionCharts Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Dynamic manipulation of an image Expand / Collapse
Author
Message
Posted 4/28/2008 5:51:42 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 5/1/2008 7:39:56 AM
Posts: 12, Visits: 33
Hi,

The Save as Image feature works great.

I need to invoke the image creation in a nother way (it should be eliminated from the user)

Can I do this on the server side?

Can I set the target pathame for the image?

thanks alot

Jo 

Post #5974
Posted 4/28/2008 6:22:42 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Moderators
Last Login: Today @ 8:31:36 AM
Posts: 763, Visits: 1,214
Hi,

You can tweak your image saving code to save image to a server side folder with out user inteference. But, the chart needs to be rendered once at client side. Once that is done you can use JavaScript FC_Rendered() function to call the saveAsImage() function to send data to server side image saving script where you can save the chart to a file in the server's directory. For this you would need to modify the image saving code not to flush the image create to the resposne stream. Rather save the image.

In php you would need to comment some line and add the destination filename :

// JPEG Header
//header('Content-type:image/jpeg');
// Force download box if not IE
//header('Content-Disposition: attachment; filename="FusionCharts.jpg"');

// JPEG Output with 100 quality
imagejpeg($chart, "ThePathToImage.jpeg", 100);

In JSP it would be :

//response.setContentType("image/jpeg");
//response.addHeader("Content-Disposition", "attachment; filename=\"FusionCharts.jpg\"");
//OutputStream os = response.getOutputStream();
ImageIO.write(chart, "jpeg", new File("PathToSave.jpg")
//os.close();

This way you can modify your ASP.NET code and other codes too.

Regards,

Sudipto Choudhury
FusionCharts Team

Post #5976
Posted 4/28/2008 9:04:13 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 5/1/2008 7:39:56 AM
Posts: 12, Visits: 33
thanks,

According to documentation I can add the following to a jsp file:

<SCRIPT LANGUAGE="JavaScript">
      function saveChart(){
         //Get chart from its ID
         var chartToPrint = getChartFromId("chart1Id");
         chartToPrint.saveAsImage();
      }

      </SCRIPT>
.. and it should be enough,

but it doesnt, it stopps at saveAsImage()

Should I add the FC_Rendered()? where?

If I dont want to mess with the jpg location, can I leave the content of FusionChartsSave.jsp as is?

upgrading from ver 2.3 to ver3 should i change FusionCharts.js?

Thanks for your help

Jo

Post #5983
Posted 4/28/2008 11:44:53 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 5/15/2008 10:23:51 PM
Posts: 11, Visits: 29
In addition you need to add the registerJS flag to the new Chart constructor. It is the last parameter if you look at the sample chart creation logic. This will then trigger the FC_rendered event.
Post #5993
Posted 4/29/2008 8:10:00 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 5/1/2008 7:39:56 AM
Posts: 12, Visits: 33
Hi,

I have done all the followings, still,

savaAsImage() doesnt work (I have put alerts before and after).

Can you think of a reason why this function doesnt work?

Thanks

Jo 

Post #6000
Posted 4/29/2008 8:48:11 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 5/1/2008 7:39:56 AM
Posts: 12, Visits: 33
Hi again,

I'm using an xml (build in advanced) to render the FC

myChart.setDataURL(xmlURL);
myChart.render(xmlURL);

maybe this is the reasong the saveAsImage() doent work?

Post #6002
Posted 4/29/2008 8:57:08 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 5/15/2008 10:23:51 PM
Posts: 11, Visits: 29
It doesn't matter whether you use DataURL or DataXML. Make sure the chartd id and div id where you are embedding the chart are not the same. In the head section of your html add the following function


function FC_Rendered(DOMId) {
alert(DOMId);
//getChartFromId(DOMId).saveAsImage();
}


Then embed the following in the body of your html, not the last parameter in the new FusionCharts constructor below is 1 which registers the chart with the JS


var chart = new FusionCharts("Charts/MSBar3D.swf", "chartid", "400", "300", "0", "1");
chart.setDataURL("Data/chart.xml");
chart.render("chartdiv");
Post #6003
Posted 4/30/2008 1:37:51 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 5/1/2008 7:39:56 AM
Posts: 12, Visits: 33
Guys,

It works great but now after loading the chart, I see this progress bar and after the image is automaticaly saved I get a blank page instead of the chart.

Can I eliminate this progress bar?

Why do I get a blank page?

Thanks guys again

Jo

Post #6017
Posted 4/30/2008 5:20:26 AM
Supreme Being

Supreme BeingSupreme Being