Jump to content
Software FX Community

Chart FX newbie - how to stream .NET object


Recommended Posts

Greetings from Seattle.  I am new to Chart FX, and am working with the ASP.NET product for Visual Studio 2005.  I understand that in the 6.2 version it is possible to create an ASPX page that has no HTML template (no design-time tag), but simply uses the GetHtmlData( ) method to write a response stream.  This has some obvious benefits.  For intance, any web page anywhere (not necessarily a .NET web page) could have its own content, but then also include an <IMG> tag wherein the src property pointed to the ASPX page.  The GetHtmlData method can then set the MIME type of the response to "Png" or "JPEG" or whatever and send the chart to this web page.

I understand that the new object model allows us to do something similar with the RenderToStream( ) method, and in fact I have gotten this to work, as long as the charts I send are image type charts.

My question now is this:  Suppose we want to do something similar, but instead of sending an image, we want to use RenderToStream to send the rich ".NET" type object.  Our goal is:

1. serve charts to web pages that are developed outside of .NET, and only require them to include some sort of a placeholder tag such as an <IMG> tag or something else, to represent the location of the chart, and point the src attribute of that tag to our ASPX page (or perhaps an ASHX, or whatever).

2. Have the response stream that is returned by our managed code return the rich ".NET" object with a toolbar, and full interactive capability, etc.  We can guarantee that all users have the .NET 2.0 framework and IE 6 or later.

3. We want to write directly to the response stream so that no image or other files need to be created and cached on the server.  We don't want to have to implement any clean up.  And we don't want the web page that will contain the final chart to need a <chartfx:Chart> tag.

Is this possible?  Or can the .NET object only interact with a design-time <chartfx:Chart> tag that is included directly in the ASPX page?  If it is possible to do what we want, then what sort of TAG would be necessary in the calling web page? 

Does the rich .NET object REQUIRE that temporary files be cached on the server?  Is there any way to avoid this?

 Failing this, what would be the next best solution, that would provide the most "interactivity" to the user, but not require a <chartfx:Chart> tag at design time?  Mapped images appear to be another possibility, but how do they compare to the .NET object in functionality?

Thanks very much in advance for any response!

Lawrence Davies

Development Team Lead, Seattle Public Utilities

Link to comment
Share on other sites

1) Yes you can do this, however if you have an <IMG> tag then you have to produce an image, if you want to produce a .NET object then you must have an <OBJECT> tag corresponding to Chart FX's .NET IE Client Control.

2) As long as you create the <OBJECT> tag, your are good to go.

3) Yes, you can have the charts streamed directly to the client without any temporary files. However, in Chart FX for VS 2005 we include the PSS Service, a Windows Service that handles all the Chart content and manages temporary files, offers security and supports web farms. The chart doesn't need to be part of an ASP.NET Page in order for PSS to work.

For interactive AJAX charts (not .NET Client) and handling server-side events, you need to have the chart as part of an ASP.NET web page as this relies on the ASP.NET ViewState and Callback mechanisms to work. Nothing is ever required at design time, you can do everything from code, including adding the chart to the page's control tree. This is no diferent than any other Web Forms control.

Link to comment
Share on other sites

  • 3 months later...

Here is the situation:

We have 2 web projects - let's call it as client and Server.

Client calls server page with an image ID, server creates an instance of Chart, talks to DB to get chart and series properties, generates the chart and renders as Image/.Net format. This whole process happens in the pageload of server page.

In the client page, I am using the following line of code to call server:

(string) strChartServerURL = strChartServerURL &

"?ImageId=" & strImageId  - this is the server URL, where page is generated and rendered as Image/.NET format

I am using <img  src="strChartServerURL"  height="400" width="500"> if I needed a static image [ie: when I use "Chart.RenderFormat as "image" and RenderToStream() ]. This is working fine.

Now, I want to display that chart as a .NET component in my client app. I used the following code and this works fine. But the problem is I must know correct .js file to use with <srcript src="/ChartFX70/Temp/<###.js>></script> tag. 

How do I know this .JS file dynamically? (or) Is there a better way to do this ?

Here is the code I am using to form the object tag in the code behind:

content.Append("<object codetype=""application/octet-stream"" id=""Chart1"" ")


" classid=""/chartfx70/download/ChartFX.NetIEClient.dll#ChartFX.NetIEClient.Chart"" standby=""Downloading Chart FX control please wait ..."" ")content.Append("></OBJECT> ")


"<br />")content.Append("<script src=""/ChartFX70/Temp/CFT0817_1130311428C.js"" ")


"></script> ")content.Append("<script> ") content.Append("cfx_replaceChart1();</script> ")


"<br />")


Am I doing it right? Am I passing all the parameters to the OBJECT tag? If not, please let me know what/how to assign parameters?


Link to comment
Share on other sites

No. This is wrong.

/ChartFX70/Temp/CFT0817_1130311428C.js is a java script file that was generated at some point for one particular chart, this file is temporary and will eventually be deleted.

You need to simply add the <object> tag as like you are doing here but add the DataPath param. This param must point to the url that returns the stream (looks like strChartServerURL). For example:

content.Append("<object codetype=""application/octet-stream"" id=""Chart1"" ")

content.Append(" classid=""/chartfx70/download/ChartFX.NetIEClient.dll#ChartFX.NetIEClient.Chart"" standby=""Downloading Chart FX control please wait ..."" ")

content.Append(string.Format("<param name=\"DataPath\" value=\"{0}\"/>",strChartServerURL));


"</OBJECT>");http://support.softwarefx.com/ShowArticle.aspx?Type=KB&Product=CfxNet70&Source=http://support.softwarefx.com/kb/762/2/003.htm?_r=1), this code has to be executed inthe client instead of in the server. This is what CFT0817_1130311428C.js does. If you look inside you will see that it adds the <object> tag to the document using JavaScript. You will have to do something similar if you want to bypass the click.
Link to comment
Share on other sites

  • 4 years later...


This topic is now archived and is closed to further replies.

  • Create New...