FusionCharts is a very cool cross-platform charting library – it offers huge variety of chart types and mind-blowing special effects. It also offers wide variety of chart rendering options both client- and server-side.
One such option is to render chart in an ASP.NET application.
FusionCharts.dll that you get with the package offers handy
FusionCharts.RenderChart method that generates all the client-side code you need to display a beautiful chart. Usually it is used something like this:
xLabel1.text = FusionCharts.RenderChart("FusionCharts/Pie2D.swf", "", sChartXmlData, sChartID, iChartWidth, iChartHeight, False, True)
xLabel1 is a Label or Literal control in your ASPX page and
FusionCharts.RenderChart is a function that accepts number of parameters, like chart type, chart XML data, dimensions etc.
It works very well until you want to render the chart inside of Microsoft Ajax UpdatePanel – then nothing works. This happens because
Let’s take a look at what output of
FusionCharts.RenderChart looks like:
We can. Microsoft’s ScriptManager that controls the UpdatePanel has a handy
But first – don’t forget to add the DIV container to your HTML markup inside of UpdatePanel – because it will not be generated automatically.
Line 1 generates client-side code for the chart, but instead of outputting it directly to the page stores it in a String variable.
Line 6 pushes this code to the client where it will be executed rendering chart inside of a DIV we specified above.
That’s it – no additional script references needed, no messy hookup – it just works. To make this approach a bit more universal instead of direct use of
Thanks for helping,that works.
But when I put 2 FusionChart in the same UpdatePanel.
Only show up first chart,did you have same problem?
@Owen, haven’t tried with 2, but in theory it should work. Have u tried just double the above approach: Put 2 differently named Divs inside of UpdatePanel, call “FusionCharts.RenderChart” twice with 2 different ChartIDs related to Divs.
Yes,I did try 2 different ChartIDs on using “FusionCharts.RenderChart” and related to Divs.I found out I have to combine all scripts(like your sJsCode ) and call “ScriptManager.RegisterStartupScript” together.