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