I want to create box plot chart based on data from datatable. I am able to create column chart dynamically from datatable, but I want to create box plot chart and not column chart.

This is my codes:

Aspx file:

<asp:Chart ID="Chart1" runat="server">






Cs file:

 public void BindChart()
        DataTable tg = new DataTable();
        DataRow dr;
        tg.Columns.Add(new DataColumn("DATE"));
        tg.Columns.Add(new DataColumn("CODE"));
        tg.Columns.Add(new DataColumn("PERSON_NAME"));
        tg.Columns.Add(new DataColumn("STATUS"));
        tg.Columns.Add(new DataColumn("HOBBIES"));
        tg.Columns.Add(new DataColumn("SCORE"));
        tg.Columns.Add(new DataColumn("ITEM"));
        tg.Columns.Add(new DataColumn("QUANTITY"));
        tg.Columns.Add(new DataColumn("TYPE"));
        tg.Columns.Add(new DataColumn("RATING"));
        tg.Columns.Add(new DataColumn("PRODUCT"));
        foreach (GridViewRow gvr in GridView1.Rows)
            if (gvr.Cells[3].Text == "Regular")
                dr = tg.NewRow();
                dr["DATE"] = gvr.Cells[0].Text;
                dr["CODE"] = gvr.Cells[1].Text;
                dr["PERSON_NAME"] = gvr.Cells[2].Text;
                dr["STATUS"] = gvr.Cells[3].Text;
                dr["HOBBIES"] = gvr.Cells[4].Text;
                dr["SCORE"] = gvr.Cells[5].Text;
                dr["ITEM"] = gvr.Cells[6].Text;
                dr["QUANTITY"] = gvr.Cells[7].Text;
                dr["TYPE"] = gvr.Cells[8].Text;
                dr["RATING"] = gvr.Cells[9].Text;
                dr["PRODUCT"] = gvr.Cells[10].Text;

        Chart1.DataSource = tg;
        Chart1.Width = 600;
        Chart1.Height = 350;
        //create series
        Series serie1 = new Series();
        serie1.Name = "Serie1";
        serie1.ChartType = SeriesChartType.BoxPlot;
        serie1.IsValueShownAsLabel = true;
        serie1.XValueMember = "PRODUCT";
        serie1.YValueMembers = "ITEM";

        string Title = (tg.Rows[0]["Status"].ToString());
        //create chartareas...
        ChartArea ca = new ChartArea();
        ca.Name = "ChartArea1";
        ca.AxisX = new Axis();
        ca.AxisY = new Axis();
        Chart1.Visible = true;

Question: Based on my codes, I can create column chart dynamically from datatable. How could I create box plot chart dynamically from datatable?

Appreciate if someone could help me on this. Thank a lot!!

Related posts

Recent Viewed