Tuesday, June 19, 2012

Animated Flash chart

  • http://www.fusioncharts.com/goodies/fusioncharts-free/
  • Follow the steps
    • It will download a file FusionChartsFree.zip
  • After extraction go to the path
    • FusionChartsFree\FusionChartsFree\Code\CSNET
  • Copy the folder FusionCharts to your root directory which contains .swf files
    • FusionChartsFree\FusionChartsFree\Code\CSNET\FusionCharts
  • Copy FusionCharts.cs to your App_Config from the path
    • FusionChartsFree\FusionChartsFree\Code\CSNET\App_Code
  • Create a literal control in your aspx page
    • <asp:Literal ID="FCLiteral" runat="server"></asp:Literal>
  • In the code behind, ddd the namespaces
    • using InfoSoftGlobal;
    • using System.Drawing;
private void LoadFusionChart(DataTable dt)
    {
        string strXML;
        //http://www.codeweblog.com/2010-03-10-4-fusioncharts-of-the-xml-tag-attributes/
        //https://www.ourrelationship.com/mod/mcfeedback/Fusion/Contents/ChartSS/XML_MSLine2D.html
        //http://forum.fusioncharts.com/topic/2018-bug-duplicate-y-axis-labels-with-decimalprecision0/

        //Generate the graph element
        strXML = "";
        //showPercentageValues='0' showLegend='0' rotateValues='1' showDivLineValue='1'

        Random randonGen = new Random();

        int width = 100;

        foreach (DataRow dr in dt.Rows)
        {
            Color randomColorName = Color.FromArgb(randonGen.Next(255), 
                randonGen.Next(255), randonGen.Next(255));
            String randomColor = ColorTranslator.ToHtml(randomColorName);

            strXML += "";
            strXML += "";

            width += 50;
        }

        //Finally, close  element
        strXML += "";

        //We should be careful about the swf file path
        FCLiteral.Text = FusionCharts.RenderChartHTML("../FusionCharts/FCF_Column3D.swf", "", strXML, 
            "myFirst", width.ToString(), "400", false); ;
    }

No comments: