Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //For a head start we have kept the example simple
        //You can use complex code to render chart taking data streaming from
        //database etc.

        // Initialize chart - Radar Chart with the JSON string
        Chart sales = new Chart("candlestick", "myChart", "700", "350", "jsonurl", "../Data/MasterPageData.json");
        // Render the chart
        Literal1.Text = sales.Render();
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // This page demonstrates the ease of generating charts using FusionCharts.
        // For this chart, we've used a pre-defined DrillDownSSData.json (contained in /Data/ folder)
        // Ideally, you would NOT use a physical data file. Instead you'll have
        // your own ASP.NET scripts virtually relay the JSON / XML data document.
        // For a head-start, we've kept this example very simple.

        // Initialize chart - Column 3D Chart with data from Data/DrillDownSSData.json
        Chart sales = new Chart("column2d", "myChart", "600", "350", "jsonurl", "../Data/DrillDownSSData.json");
        // Render the chart
        Literal1.Text = sales.Render();
    }
Пример #3
0
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            // This page demonstrates the ease of generating charts using FusionCharts.
            // For this chart, we've used a pre-defined Data.xml (contained in /Data/ folder)
            // Ideally, you would NOT use a physical data file. Instead you'll have
            // your own ASP.NET scripts virtually relay the JSON / XML data document.
            // For a head-start, we've kept this example very simple.

            // Initialize chart - Column 3D Chart with data from Data/Data.json
            Chart sales = new Chart("column3d", "myChart", "600", "350", "xmlurl", "../../Data/Data.xml");

            // Render the chart
            ViewData["Message"] = sales.Render();
            return View();
        }
Пример #4
0
    /// <summary>
    /// show first blank Column2D chart
    /// </summary>
    public void showColumnChart()
    {
        // blank chart element
        string strXML = "<chart></chart>";

        // create Column2D chart and srore it to output string
           // string outPut = FusionCharts.RenderChart("../FusionCharts/Column2D.swf?ChartNoDataText=Please click on a pie slice to view detailed data.", "", strXML, "chart3", "440", "350", false, false);

        Chart sales = new Chart("column2d.swf", "myChart3", "440", "350", "xml", strXML.ToString());

        string outPut = sales.Render();

        // clear the Panel
        Panel1.Controls.Clear();
        // Add output to Panel
        Panel1.Controls.Add(new LiteralControl(outPut));
    }
Пример #5
0
    /// <summary>
    /// Show Pie Chart on first load
    /// </summary>
    public void showPieChart()
    {
        if (!IsPostBack)
        {
            // SQL Query for Factory wise Total Quantity
            string strSQL = "select a.FactoryId,a.FactoryName,sum(b.Quantity) as TotQ from Factory_Master a,Factory_Output b where a.FactoryId=b.FactoryID group by a.FactoryId,a.FactoryName";

            // Connect DataBase and create data reader
            DbConn oRs = new DbConn(strSQL);
            // create strXML for XML
            StringBuilder strXML = new StringBuilder();
            // Add chart element
            strXML.AppendFormat("<chart slicingDistance='0' caption='Factory wise Production' subcaption='Total Production in Units' formatNumberScale='0' pieSliceDepth='25'>");
            // fetch data reader
            while (oRs.ReadData.Read())
            {
                // create link to javascript  function for ajax post back call
                string link = "javascript:updateChart(" + oRs.ReadData["FactoryId"].ToString() + ")";

                //add set element
                strXML.AppendFormat("<set label='{0}' value='{1}' link='{2}' />", oRs.ReadData["FactoryName"].ToString(), oRs.ReadData["TotQ"].ToString(), link);
            }

            // close data reader
            oRs.ReadData.Close();

            // close chart element
            strXML.Append("</chart>");

            // create pie chart and store it to output string
            Chart sales = new Chart("pie3d", "myChart1", "440", "350", "xml", strXML.ToString());
            string outPut = sales.Render();

            // write the output string
            Response.Write(outPut);
        }
    }
Пример #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Chart sales = new Chart();
            sales.SetChartParameter(Chart.ChartParameter.chartId, "myChart");
            string param = sales.GetChartParameter(Chart.ChartParameter.chartId);

            // Setting chart type to Column 3D chart
            sales.SetChartParameter(Chart.ChartParameter.chartType, "column3d");

            // Setting chart width to 500px
            sales.SetChartParameter(Chart.ChartParameter.chartWidth, "600");

            // Setting chart height to 400px
            sales.SetChartParameter(Chart.ChartParameter.chartHeight, "350");

            // Setting chart data as XML URL
            sales.SetData("Data/Data.aspx", Chart.DataFormat.xmlurl);

            Label1.Text = sales.Render();

        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //In this example, we plot a multi series chart from data contained
        //in an array. The array will have three columns - first one for data label (product)
        //and the next two for data values. The first data value column would store sales information
        //for current year and the second one for previous year.

        //Let//s store the sales data for 6 products in our array. We also store
        //the name of products.
        object[,] arrData = new object[6, 3];
        //Store Name of Products
        arrData[0, 0] = "Product A";
        arrData[1, 0] = "Product B";
        arrData[2, 0] = "Product C";
        arrData[3, 0] = "Product D";
        arrData[4, 0] = "Product E";
        arrData[5, 0] = "Product F";
        //Store sales data for current year
        arrData[0, 1] = 567500;
        arrData[1, 1] = 815300;
        arrData[2, 1] = 556800;
        arrData[3, 1] = 734500;
        arrData[4, 1] = 676800;
        arrData[5, 1] = 648500;
        //Store sales data for previous year
        arrData[0, 2] = 367300;
        arrData[1, 2] = 584500;
        arrData[2, 2] = 754000;
        arrData[3, 2] = 456300;
        arrData[4, 2] = 754500;
        arrData[5, 2] = 437600;

        //Now, we need to convert this data into multi-series JSON.
        //We convert using string concatenation.
        //jsonData - Stores the entire JSON string
        //categories - Stores pertial  for the <categories> and child <category> elements
        //currentYear - Stores XML for current year's sales
        //previousYear - Stores XML for previous year's sales
        StringBuilder jsonData = new StringBuilder();
        StringBuilder categories = new StringBuilder();
        StringBuilder currentYear = new StringBuilder();
        StringBuilder previousYear = new StringBuilder();

        //Initialize chart object of the JSON
        jsonData.Append("{" +
            "'chart': {"+
            // add chart level attrubutes
                "'caption': 'Sales by Product'," +
                "'numberPrefix': '$',"+
                "'formatNumberScale': '1'," +
                "'placeValuesInside': '1'," +
                "'decimals': '0'" +
            "},");

        //Initial string part of categories element - necessary to generate a multi-series chart
        categories.Append("'categories': [" +
            "{" +
                "'category': [");

        //Initial string part of dataset elements
        currentYear.Append("{" +
                    // dataset level attributes
                    "'seriesname': 'Current Year'," +
                    "'data': [");
        previousYear.Append("{" +
                    // dataset level attributes
                    "'seriesname': 'Previous Year'," +
                    "'data': [");

        //Iterate through the data
        for (int i = 0; i < arrData.GetLength(0); i++)
        {
            if (i > 0)
            {
                categories.Append(",");
                currentYear.Append(",");
                previousYear.Append(",");
            }
            //Append individual category to strCategories
            categories.AppendFormat("{{" +
                    // category level attributes
                    "'label': '{0}'" +
                "}}", arrData[i, 0]);
            //Add individual data to both the datasets
            currentYear.AppendFormat("{{" +
                    // data level attributes
                    "'value': '{0}'" +
                "}}", arrData[i, 1]);
            previousYear.AppendFormat("{{" +
                    // data level attributes
                    "'value': '{0}'" +
                "}}", arrData[i, 2]);
        }

        //Closing part of the categories object
        categories.Append("]" +
                "}" +
            "],");

        ////Closing part of individual dataset object
        currentYear.Append("]" +
                "},");
        previousYear.Append("]" +
                "}");

        //Assemble the entire XML now
        jsonData.Append(categories.ToString());
        jsonData.Append("'dataset': [");
        jsonData.Append(currentYear.ToString());
        jsonData.Append(previousYear.ToString());
        jsonData.Append("]" +
                "}");

        // Initialize chart - Column 3D Chart with data from Data/Data.json
        Chart sales = new Chart("msline", "myChart", "600", "350", "json", jsonData.ToString());
        // Render the chart
        Literal1.Text = sales.Render();
    }
    protected void ddlexcellst_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            if (ddlexcellst.SelectedIndex == 0) {
                Label2.Visible = true;
            }
            else
            {
                Label2.Visible = false;
                OAuth2Parameters parameters_lst = oauthcredentials();
                GOAuth2RequestFactory requestFactory =
                     new GOAuth2RequestFactory(null, "Fusion-SpreadSheet", parameters_lst);
                SpreadsheetsService service = new SpreadsheetsService("Fusion-SpreadSheet");
                service.RequestFactory = requestFactory;

                service.RequestFactory = requestFactory;

                // TODO: Authorize the service object for a specific user (see other sections)

                // Instantiate a SpreadsheetQuery object to retrieve spreadsheets.
                SpreadsheetQuery query = new SpreadsheetQuery();

                // Make a request to the API and get all spreadsheets.
                SpreadsheetFeed feed = service.Query(query);

                if (feed.Entries.Count == 0)
                {
                    // TODO: There were no spreadsheets, act accordingly.
                }

                // TODO: Choose a spreadsheet more intelligently based on your
                // app's needs.
                SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[Convert.ToInt32(ddlexcellst.SelectedIndex) - 1];
                //Response.Write(spreadsheet.Title.Text + "\n");

                // Get the first worksheet of the first spreadsheet.
                // TODO: Choose a worksheet more intelligently based on your
                // app's needs.
                WorksheetFeed wsFeed = spreadsheet.Worksheets;
                WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];

                // Define the URL to request the list feed of the worksheet.
                AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

                // Fetch the list feed of the worksheet.

                ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
                listQuery.StartIndex = 0;
                ListFeed listFeed = service.Query(listQuery);

                // Iterate through each row, printing its cell values.

                List<category> chart_categories = new List<category>();
                ChartModels result = new ChartModels();
                categories final_categories = new categories();
                List<categories> list_categories = new List<categories>();
                List<dataset> collect_dataset = new List<dataset>();
                foreach (ListEntry row in listFeed.Entries)
                {
                    // Print the first column's cell value
                    TableRow tr = new TableRow();
                    //  Response.Write(row.Title.Text + "\n");
                    // Iterate over the remaining columns, and print each cell value
                    dataset final_dataset = new dataset();
                    List<data> collect_data = new List<data>();
                    foreach (ListEntry.Custom element in row.Elements)
                    {
                        if (row.Title.Text == "Row: 2")
                        {
                            category chart_category = new category();
                            chart_category.label = element.Value.ToString();
                            chart_categories.Add(chart_category);
                        }
                        else
                        {
                            data data_value = new data();
                            final_dataset.seriesname = row.Title.Text;
                            int n;
                            bool isNumeric = int.TryParse(element.Value, out n);
                            if (isNumeric)
                            {
                                data_value.value = element.Value.ToString();
                                collect_data.Add(data_value);
                            }
                        }
                        // Response.Write(element.Value + "\n");

                        TableCell tc = new TableCell();
                        if (row.Title.Text == "Row: 2")
                        {
                            tc.Text = "";
                        }
                        else
                            tc.Text = element.Value;
                        tr.Cells.Add(tc);
                    }
                    Table1.Rows.Add(tr);
                    if (collect_data.Count != 0)
                    {
                        final_dataset.data = collect_data;
                        collect_dataset.Add(final_dataset);
                    }
                }
                final_categories.category = chart_categories;
                result.dataset = collect_dataset;
                list_categories.Add(final_categories);
                result.categories = list_categories;

                JavaScriptSerializer js = new JavaScriptSerializer();
                string res = js.Serialize(result);
                string chartjson = JsonConvert.SerializeObject(result.categories);

                StringBuilder strJson = new StringBuilder();

                strJson.Append("{" +
                        "'chart': {" +
                              "'caption': 'Quarterly revenue'," +
                              "'subCaption':'Last year'," +
                              "'xAxisName':'Quarter (Click to drill down)'," +
                              "'subcaptionFontColor':'#0075c2'," +
                              "'numberPrefix': '$'," +
                              "'formatNumberScale': '1'," +
                              "'placeValuesInside': '1'," +
                              "'decimals': '0'" +
                                   "},");
                strJson.Append("'categories':");

                strJson.Append(chartjson);
                strJson.Append(",");
                strJson.Append("'dataset':");
                string chartdatajson = JsonConvert.SerializeObject(result.dataset);
                strJson.Append(chartdatajson);
                strJson.Append("}");

                // Initialize the chart.
                Chart sales = new Chart("mscolumn3d", "myChart", "600", "350", "json", strJson.ToString());

                // Render the chart.
                Label1.Text = sales.Render();
            }
        }
        catch (Exception)
        {
            Response.Redirect("Default.aspx");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //In this example, we plot a Combination chart from data contained
        //in an array. The array will have three columns - first one for Quarter Name
        //second one for sales figure and third one for quantity.

        object[,] arrData = new object[4, 3];
        //Store Quarter Name
        arrData[0, 0] = "Quarter 1";
        arrData[1, 0] = "Quarter 2";
        arrData[2, 0] = "Quarter 3";
        arrData[3, 0] = "Quarter 4";
        //Store revenue data
        arrData[0, 1] = 576000;
        arrData[1, 1] = 448000;
        arrData[2, 1] = 956000;
        arrData[3, 1] = 734000;
        //Store Quantity
        arrData[0, 2] = 576;
        arrData[1, 2] = 448;
        arrData[2, 2] = 956;
        arrData[3, 2] = 734;

        //Now, we need to convert this data into combination XML.
        //We convert using string concatenation.
        //strXML - Stores the entire XML
        //strCategories - Stores XML for the <categories> and child <category> elements
        //strDataRev - Stores XML for current year's sales
        //strDataQty - Stores XML for previous year's sales

        StringBuilder strXML=new StringBuilder();
        StringBuilder strCategories = new StringBuilder();
        StringBuilder strDataRev=new StringBuilder();
        StringBuilder strDataQty=new StringBuilder();

        //Initialize <chart> element
        strXML.Append("<chart palette='4' caption='Product A - Sales Details' PYAxisName='Revenue' SYAxisName='Quantity (in Units)' numberPrefix='$' formatNumberScale='0' showValues='0' decimals='0' >");

        //Initialize <categories> element - necessary to generate a multi-series chart
        strCategories.Append("<categories>");

        //Initiate <dataset> elements
        strDataRev.Append("<dataset seriesName='Revenue'>");
        strDataQty.Append("<dataset seriesName='Quantity' parentYAxis='S'>");

        //Iterate through the data
        for (int i = 0; i < arrData.GetLength(0); i++)
        {
            //Append <category name='...' /> to strCategories
            strCategories.AppendFormat("<category name='{0}' />",arrData[i, 0]);
            //Add <set value='...' /> to both the datasets
            strDataRev.AppendFormat("<set value='{0}' />",arrData[i, 1]);
            strDataQty.AppendFormat("<set value='{0}' />",arrData[i, 2]);
        }

        //Close <categories> element
        strCategories.Append("</categories>");

        //Close <dataset> elements
        strDataRev.Append("</dataset>");
        strDataQty.Append("</dataset>");

        //Assemble the entire XML now
        strXML.Append(strCategories.ToString());
        strXML.Append(strDataRev.ToString());
        strXML.Append(strDataQty.ToString());
        strXML.Append("</chart>");

        // Initialize chart - Column 3D Chart with data from Data/Data.json
        Chart sales = new Chart("mscombidy2d", "myChart", "600", "350", "xml", strXML.ToString());
        // Render the chart
        Literal1.Text = sales.Render();
    }
Пример #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // The data to plot the sample dual-y combination chart is contained in the
        // `arrData` 2D array having six rows and three columns.

        // Each row contains the sales data for product A for each quarter.

        // The first column stores the labels to be rendered for each quarter,

        // the second column stores the revenue generated, and

        // the third column stores the no. of units sold in each quarter.

        object[,] arrData = new object[4, 3];

        //Store the labels for each quarter.
        arrData[0, 0] = "Quarter 1";
        arrData[1, 0] = "Quarter 2";
        arrData[2, 0] = "Quarter 3";
        arrData[3, 0] = "Quarter 4";

        //Store revenue data for each quarter.
        arrData[0, 1] = 576000;
        arrData[1, 1] = 448000;
        arrData[2, 1] = 956000;
        arrData[3, 1] = 734000;

        //Store quantity details for each quarter.
        arrData[0, 2] = 576;
        arrData[1, 2] = 448;
        arrData[2, 2] = 956;
        arrData[3, 2] = 734;

        // Use string concatenation to convert the data in the `arrData` array into XML data for the
        // combination chart.

        //Create objects of the `StringBuilder` class are created to

        //store the converted XML strings.

        // Define the the `strXML` object

        //to store the entire chart data as an XML string.
        StringBuilder strXML = new StringBuilder();

        // Define the `strCategories` object
        //to store the labels for each quarter, converted to XML strings.

        StringBuilder strCategories = new StringBuilder();

        //Define the `strDataRev` and the `strDataQty` objects

        // to store the revenue and quantity data, respectively, for product A.
        StringBuilder strDataRev = new StringBuilder();
        StringBuilder strDataQty = new StringBuilder();

        //Initialize the <chart> element. Define the chart-level attributes and
        // append them as strings to the `strXML` object.

        strXML.Append("<chart palette='4' caption='Product A - Sales Details' PYAxisName='Revenue' SYAxisName='Quantity (in Units)' numberPrefix='$' formatNumberScale='0' showValues='0' decimals='0' theme='fint' exportEnabled='1'  exportAtClient= '0' exportAction='Save' exportFileName ='ExportDemo' exportHandler='FusionCharts/ExportHandlers/ASP_Net/FCExporter.aspx' >");

        //Initialize the <categories> element.
        strCategories.Append("<categories>");

        //Initiate the <dataset> elements for the revenue and quantity data.
        strDataRev.Append("<dataset seriesName='Revenue'>");
        strDataQty.Append("<dataset seriesName='Quantity' parentYAxis='S'>");

        //Iterate through the data in the `arrData` array
        for (int i = 0; i < arrData.GetLength(0); i++)
        {
            //Append <category name='...' /> to `strCategories`
            strCategories.AppendFormat("<category name='{0}' />", arrData[i, 0]);
            //AppendAdd <set value='...' /> to both the datasets.
            strDataRev.AppendFormat("<set value='{0}' />", arrData[i, 1]);
            strDataQty.AppendFormat("<set value='{0}' />", arrData[i, 2]);
        }

        //Close the `<categories>` element..
        strCategories.Append("</categories>");

        //Close the `<dataset>` element for the revenue and quantity datasets.
        strDataRev.Append("</dataset>");
        strDataQty.Append("</dataset>");

        //Append the complete chart data converted to a string to the the `strXML` object.
        strXML.Append(strCategories.ToString());
        strXML.Append(strDataRev.ToString());
        strXML.Append(strDataQty.ToString());
        strXML.Append("</chart>");

        // Initialize the chart.
        Chart sales = new Chart("mscombidy2d", "myChart", "600", "350", "xml", strXML.ToString());

        // Render the chart.
        label1.Text = sales.Render();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        /*******
         *
         *
         * Uncomment this block to use the Data String method.
         * You will also need to change the parameters of the RenderChart() method accordingly.
         *
         *

        // Construct the connection string to interface with the SQL Server Database
        string connStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Fusion Charts\Documents\Visual Studio 2010\WebSites\FusionChartsXT_with_ASPNET\App_Data\FusionChartsDB.mdf;Integrated Security=True;User Instance=True";

        // Initialize the string which would contain the chart data in XML format
        StringBuilder xmlStr = new StringBuilder();

        // Provide the relevant customization attributes to the chart
        xmlStr.Append("<chart caption='Total Revenue' palette='3' showValues='0' numberPrefix='$' useRoundEdges='1'>");

        // Create a SQLConnection object
        using (SqlConnection conn = new SqlConnection(connStr))
        {
            // Establish the connection with the database
            conn.Open();

            // Construct and execute SQL query which would return the total amount of sales for each year
            SqlCommand query = new SqlCommand("SELECT SUM(FC_OrderDetails.UnitPrice * FC_OrderDetails.Quantity) AS AMOUNT, YEAR(FC_Orders.OrderDate) AS yr FROM FC_Orders INNER JOIN FC_OrderDetails ON FC_OrderDetails.OrderID = FC_Orders.OrderID GROUP BY YEAR(FC_Orders.OrderDate) ORDER BY YEAR(FC_Orders.OrderDate)", conn);

            // Begin iterating through the result set
            SqlDataReader rst = query.ExecuteReader();

            while (rst.Read())
            {
                // Construct the chart data in XML format
                xmlStr.AppendFormat("<set label='{0}' value='{1}'/>", rst["yr"].ToString(), rst["AMOUNT"].ToString());
            }

            // End the XML string
            xmlStr.Append("</chart>");

            // Close the result set Reader object and the Connection object
            rst.Close();
            conn.Close();
        */
        // Call the RenderChart method, pass the correct parameters, and write the return value to the Literal tag
        Label label1 = (Label)FindControl("label1");
        Label label2 = (Label)FindControl("label2");

        Application["Name"] = label1.Text;
        Application["Name2"] = label2.Text;

        Literal chart_from_db = (Literal)FindControl("chart_from_db");

        Chart sales = new Chart("msline", "myChart", "1024", "720", "xmlurl", Server.UrlEncode("DataProviderField.aspx"));

        chart_from_db.Text = sales.Render();
           /* chart_from_db.Text = FusionCharts.RenderChart(
                "FusionChartsXT/Column2D.swf", // Path to chart's SWF
                Server.UrlEncode("DataProvider.aspx"), // Page which returns chart data
                "", // String containing the chart data. Leave blank when using Data URL.
                "annual_revenue",   // Unique chart ID
                "640", "340",       // Width & Height of chart
                false,              // Disable Debug Mode
                true);              // Register with JavaScript object
        */
    }
Пример #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Create the `xmlData` StringBuilder object to store the data fetched
        //from the database as a string.
        StringBuilder xmlData = new StringBuilder();

        // Initialize the chart-level attributes and append them to the
        //`xmlData` StringBuilder object.

        xmlData.Append("<chart caption='Factory Output report' subCaption='By Quantity' showBorder='1' formatNumberScale='0' rotatelabels='1' showvalues='0'>");

        // Initialize the `<categories>` element.
        xmlData.AppendFormat("<categories>");

        // Every date between January 01, 2003 and January 20, 2003 is entered thrice
        // in the **datepro** field in the **FactoryDB **database.

        // The dates will be shown as category labels on the x-axis of the chart.

        // Because we need to show each date only once, use the `select` query
        // with the `distinct` keyword to fetch only one instance of each date from the database.

        // Store the output of the `select` query in the `factoryQuery` string variable.

        string factoryQuery = "select distinct format(date,'dd/mm/yyyy') as dd from Gas_Total_Production_Field";

        // Establish the database connection.
        DbConn oRs = new DbConn(factoryQuery);

        // Iterate through the data in the `factoryQuery` variable and add the dates as

        // labels to the `<category>` element.

        // Append this data to the `xmlData` object.
        while (oRs.ReadData.Read())
        {
            xmlData.AppendFormat("<category label='{0}'/>", oRs.ReadData["dd"].ToString());
        }

        //Close the database connection.
        oRs.ReadData.Close();

        //Close the `<catgories>` element.
        xmlData.AppendFormat("</categories>");

        //Fetch all details for the three factories from the **Factory_Master** table
        // and store the result in the `factoryquery2` variable.

        string factoryquery2 = "select distinct phe23 from Gas_Total_Production_Field";

        //Establish the database connection..
        DbConn oRs1 = new DbConn(factoryquery2);

        // Iterate through the results in the `factoryquery2` variable to fetch the
        // factory name and factory id.

        while (oRs1.ReadData.Read())
        {
            // Append the factory name as the value for the `seriesName` attribute.
            xmlData.AppendFormat("<dataset seriesName='{0}'>", oRs1.ReadData["phe23"]);

            // Based on the factory id, fetch the quantity produced by each factory on each day
            // from the factory_output table.

            // Store the results in the `factoryquery3` string object.

            string factoryquery3 = "select quantity from factory_output where factoryid=" + oRs1.ReadData["factoryid"].ToString();

            //Establish the database connection.
            DbConn oRs2 = new DbConn(factoryquery3);

            // Iterate through the results in the `factoryquery3` object and fetch the quantity details
            // for each factory.

            // Append the quantity details as the the value for the `<set>` element.

        //            while (oRs2.ReadData.Read())
        //            {
        //                xmlData.AppendFormat("<set value='{0}'/>", oRs2.ReadData[0].ToString());
        //            }

            // Close the database connection.
            oRs2.ReadData.Close();

            // Close the `<dataset>` element.
            xmlData.AppendFormat("</dataset>");
        }

        // Close the database connection.
        oRs1.ReadData.Close();

        // Close the `<chart>` element.
        xmlData.AppendFormat("</chart>");

        // Initialize the chart.
        Chart factoryOutput = new Chart("msline", "myChart", "600", "350", "xml", xmlData.ToString());

        // Render the chart.
        Literal Literal1 = (Literal)FindControl("Literal1");
        Literal1.Text = factoryOutput.Render();
    }
Пример #13
0
    /// <summary>
    /// update FusionCharts and gridview with as per selected factory name
    /// </summary>
    private void updateChart()
    {
        //Get factory details depending on FactoryID from selected Radio Button
        string strSQL = "select DatePro, Quantity from Factory_Output where FactoryId=" + RadioButtonList1.SelectedValue.ToString() + " order by DatePro";

        //Create data reader to bind data with GridView
        DbConn rs = new DbConn(strSQL);
        //Fillup gridview with data from datareader
        GridView1.DataSource = rs.ReadData;
        // binding the data
        GridView1.DataBind();

        //Create database connection to get data for chart
        DbConn oRs = new DbConn(strSQL);

        //Create FusionCharts XML
        StringBuilder strXML = new StringBuilder();

        //Create chart element
        strXML.AppendFormat("<chart caption='Factory {0}' showborder='0' bgcolor='FFFFFF' bgalpha='100' subcaption='Daily Production' xAxisName='Day' yAxisName='Units' rotateLabels='1'  placeValuesInside='1' rotateValues='1' >", RadioButtonList1.SelectedValue.ToString());

        //Iterate through database
        while (oRs.ReadData.Read())
        {
            //Create set element
            //Also set date into d/M format
            strXML.AppendFormat("<set label='{0}' value='{1}' />", Convert.ToDateTime(oRs.ReadData["DatePro"]).ToString("d/M"), oRs.ReadData["Quantity"].ToString());
        }

        //Close chart element
        strXML.Append("</chart>");

        //outPut will store the HTML of the chart rendered as string
        string outPut = "";

        //When the page is loaded for the first time, we call RenderChart() method to avoid IE's 'Click here to Acrtivate...' message
        Chart sales = new Chart("column2d", "myChart", "440", "350", "xml", strXML.ToString());
        outPut = sales.Render();

        //Clear panel which will contain the chart
        Panel1.Controls.Clear();

        //Add Litaral control to Panel which adds the chart from outPut string
        Panel1.Controls.Add(new LiteralControl(outPut));

        // close Data Reader
        oRs.ReadData.Close();
    }
Пример #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // This page demonstrates the ease of generating charts with exporting feature.
        // To enable export feature just set "exportEnabled" attrubute as "1"
        // Now from the webpage click on the export button of the the chart to get the exported image of the chart.
        // For more export related attributes refer to FusionCharts docs
        //jsonData - Stores the entire JSON string
        StringBuilder jsonData = new StringBuilder();

        jsonData.Append( "{" +
        "    'chart': {" +
        "        'caption': 'Radar Chart'," +
        // Add export enabling attribute
        "        'ExportEnabled': '1'" +
        "    }," +
        "    'categories': [" +
        "        {" +
        "            'category': [" +
        "                {" +
        "                    'label': 'Index 1'" +
        "                }," +
        "                {" +
        "                    'label': 'Index 2'" +
        "                }," +
        "                {" +
        "                    'label': 'Index 3'" +
        "                }," +
        "                {" +
        "                    'label': 'Index 4'" +
        "                }," +
        "                {" +
        "                    'label': 'Index 5'" +
        "                }," +
        "                {" +
        "                    'label': 'Index 6'" +
        "                }," +
        "                {" +
        "                    'label': 'Index 7'" +
        "                }," +
        "                {" +
        "                    'label': 'Index 8'" +
        "                }," +
        "                {" +
        "                    'label': 'Index 9'" +
        "                }," +
        "                {" +
        "                    'label': 'Index 10'" +
        "                }," +
        "                {" +
        "                    'label': 'Index 11'" +
        "                }" +
        "            ]" +
        "        }" +
        "    ]," +
        "    'dataset': [" +
        "        {" +
        "            'seriesname': 'Series 1'," +
        "            'data': [" +
        "                {" +
        "                    'value': '9'" +
        "                }," +
        "                {" +
        "                    'value': '9'" +
        "                }," +
        "                {" +
        "                    'value': '9'" +
        "                }," +
        "                {" +
        "                    'value': '7'" +
        "                }," +
        "                {" +
        "                    'value': '8'" +
        "                }," +
        "                {" +
        "                    'value': '8'" +
        "                }," +
        "                {" +
        "                    'value': '9'" +
        "                }," +
        "                {" +
        "                    'value': '9'" +
        "                }," +
        "                {" +
        "                    'value': '9'" +
        "                }," +
        "                {" +
        "                    'value': '7'" +
        "                }," +
        "                {" +
        "                    'value': '8'" +
        "                }" +
        "            ]" +
        "        }," +
        "        {" +
        "            'seriesname': 'Series 2'," +
        "            'data': [" +
        "                {" +
        "                    'value': '5'" +
        "                }," +
        "                {" +
        "                    'value': '3'" +
        "                }," +
        "                {" +
        "                    'value': '2'" +
        "                }," +
        "                {" +
        "                    'value': '4'" +
        "                }," +
        "                {" +
        "                    'value': '5'" +
        "                }," +
        "                {" +
        "                    'value': '9'" +
        "                }," +
        "                {" +
        "                    'value': '5'" +
        "                }," +
        "                {" +
        "                    'value': '3'" +
        "                }," +
        "                {" +
        "                    'value': '2'" +
        "                }," +
        "                {" +
        "                    'value': '4'" +
        "                }," +
        "                {" +
        "                    'value': '5'" +
        "                }" +
        "            ]" +
        "        }" +
        "    ]" +
        "}");

        // Initialize chart - Radar Chart with the JSON string
         Chart sales = new Chart("radar", "myChart", "600", "350", "json", jsonData.ToString());
        // Render the chart
        Literal1.Text = sales.Render();
    }
Пример #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Create the `jsonData` StringBuilder object to store the data fetched
        //from the database as a string.
        StringBuilder jsonData = new StringBuilder();

        bool ReqDatasetComma = false, ReqComma = false;

        // Initialize the chart-level attributes and append them to the
        //`jsonData` StringBuilder object.
        jsonData.Append("{" +
            "'chart': {"+
            // add chart level attrubutes
                "'caption': 'Factory Output report'," +
                "'subCaption': 'By Quantity',"+
                "'formatNumberScale': '0'," +
                "'rotatelabels': '1'," +
                "'showvalues': '0'," +
                "'showBorder': '1'" +
            "},");

        // Initialize the Categories object.
        jsonData.Append("'categories': [" +
            "{" +
                "'category': [");

        // Every date between January 01, 2003 and January 20, 2003 is entered thrice
        // in the datepro field in the FactoryDB database.
        // The dates will be shown as category labels on the x-axis of the chart.
        // Because we need to show each date only once, use the `select` query
        // with the `distinct` keyword to fetch only one instance of each date from the database.
        // Store the output of the `select` query in the `factoryQuery` string variable.
        string factoryQuery = "select distinct format(datepro,'dd/mm/yyyy') as dd from factory_output";

        // Establish the database connection.
        DbConn oRs = new DbConn(factoryQuery);

        // Iterate through the data in the `factoryQuery` variable and add the dates as
        // labels to the category object.
        // Append this data to the `jsonData` object.
        while (oRs.ReadData.Read())
        {
            if (ReqComma) {
                jsonData.Append(",");
            }
            else {
                ReqComma = true;
            }

            jsonData.AppendFormat("{{" +
                    // category level attributes
                    "'label': '{0}'" +
                "}}", oRs.ReadData["dd"].ToString());
        }

        //Close the database connection.
        oRs.ReadData.Close();

        //Close the catgories object.
        jsonData.Append("]" +
                "}" +
            "],");

        // Initialize the Dataset object.
        jsonData.Append("'dataset': [");

        //Fetch all details for the three factories from the Factory_Master table
        // and store the result in the `factoryquery2` variable.
        string factoryquery2 = "select * from factory_master";

        //Establish the database connection.
        DbConn oRs1 = new DbConn(factoryquery2);

        // Iterate through the results in the `factoryquery2` variable to fetch the
        // factory  name and factory id.
        while (oRs1.ReadData.Read())
        {
            if (ReqDatasetComma) {
                jsonData.Append(",");
            }
            else {
                ReqDatasetComma = true;
            }
            // Append the factory name as the value for the `seriesName` attribute.
            jsonData.AppendFormat("{{" +
                    // dataset level attributes
                    "'seriesname': '{0}'," +
                    "'data': [", oRs1.ReadData["factoryname"].ToString());

            // Based on the factory id, fetch the quantity produced by each factory on each day
            // from the factory_output table.
            // Store the results in the `factoryquery3` string object.
            string factoryquery3 = "select quantity from factory_output where factoryid=" + oRs1.ReadData["factoryid"].ToString();

            //Establish the database connection.
            DbConn oRs2 = new DbConn(factoryquery3);

            ReqComma = false;

            // Iterate through the results in the `factoryquery3` object and fetch the quantity details
            // for each factory.
            // Append the quantity details as the the value for the `<set>` element.
            while (oRs2.ReadData.Read())
            {
                if (ReqComma) {
                    jsonData.Append(",");
                }
                else {
                    ReqComma = true;
                }

                jsonData.AppendFormat("{{" +
                    // data set attributes
                    "'value': '{0}'" +
                "}}", oRs2.ReadData[0].ToString());
            }

            // Close the database connection.
            oRs2.ReadData.Close();

            // Close individual dataset object.
            jsonData.Append("]" +
                "}");
        }

        // Close the database connection.
        oRs1.ReadData.Close();

        // Close the JSON object.
        jsonData.Append("]" +
            "}");

        // Initialize chart - MSLine Chart data pulling from database
        Chart factoryOutput = new Chart("msline", "myChart", "600", "350", "json", jsonData.ToString());
        // Render the chart
        Literal1.Text = factoryOutput.Render();
    }
Пример #16
0
    /// <summary>
    /// drillDown to show Column2D chart
    /// </summary>
    /// <param name="FacID">Factory Id</param>
    private void drillDown(string FacID)
    {
        //SQL Query for Factory Details for the factory Id passed as parameter
        string strSQL = "select  a.FactoryId,a.FactoryName,b.DatePro,b.Quantity from Factory_Master a,Factory_Output b where a.FactoryId=b.FactoryID and a.FactoryId=" + FacID + " order by b.DatePro";

        // Create data reader
        DbConn oRs = new DbConn(strSQL);

        //strXML for storing XML
        StringBuilder strXML = new StringBuilder();

        //Add Chart element
        strXML.AppendFormat("<chart caption='Factory wise Production' subcaption='Factory {0} : Daily Production' xAxisName='Day' yAxisName='Units' rotateLabels='1' bgAlpha='100' bgColor='ffffff' showBorder='0' showvalues='0' yAxisMaxValue='200'>", FacID);
        //Iterate through database
        while (oRs.ReadData.Read())
        {
            // add set element
            strXML.AppendFormat("<set label='{0}' value='{1}' />", Convert.ToDateTime(oRs.ReadData["DatePro"]).ToString("d/M"), oRs.ReadData["Quantity"].ToString());

        }
        // close data reader
        oRs.ReadData.Close();

        // close chart element
        strXML.Append("</chart>");

        // create Column2D chart and srore it to output string
        Chart sales = new Chart("column2d", "myChart2", "440", "350", "xml", strXML.ToString());
        string outPut = sales.Render();

        // clear the Panel
        Panel1.Controls.Clear();
        //Add chart to the panel
        Panel1.Controls.Add(new LiteralControl(outPut));
    }