2
Reply

tell me the code for chart implementation in asp.net..

siva G

siva G

13y
4.4k
0
Reply

    using System;

    using System.Data;

    using System.Configuration;

    using System.Collections;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Web.UI.HtmlControls;

    using System.IO;

    using System.Data;

    using System.Data.SqlClient;

    namespace piechart10

    {

    public partial class _Default : System.Web.UI.Page

    {

    SqlConnection con = new SqlConnection("Data Source=D4TELLIANT\\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=db1;");

    SqlCommand cmd, cmd1;

    String quer, qu;

    protected void Page_Load(object sender, EventArgs e)

    {

    if (!IsPostBack)

    {

    con.Open();

    qu = "delete from piee2";

    cmd1 = new SqlCommand(qu, con);

    cmd1.ExecuteNonQuery();

    con.Close();

    driinf();

    int i;

    con.Open();

    try

    {

    for (i = 0; i <= ListBox1.Items.Count; i++)

    {

    quer = "insert into piee2 values('" + ListBox1.Items[i] + "','" + ListBox2.Items[i] + "')";

    cmd = new SqlCommand(quer, con);

    cmd.ExecuteNonQuery();

    }

    }

    catch (Exception)

    {

    }

    Response.Write("updated");

    con.Close();

    CreateChart();

    }

    }

     

    public void driinf()

    {

    DriveInfo[] di = DriveInfo.GetDrives();

    foreach (DriveInfo item in di)

    {

    ListBox1.Items.Add(item.Name);

    ListBox2.Items.Add(item.TotalSize.ToString());

    }

    }

    private void CreateChart()

    {

    con.Open();

    SqlDataAdapter da = new SqlDataAdapter("select dirname,size from piee2", con);

    DataSet ds = new DataSet();

    da.Fill(ds, "piee2");

    DataTable dt = new DataTable();

    DataColumn dc = new DataColumn();

    dc.ColumnName = "dirname";

    dc.ColumnName = "size";

    dt.Columns.Add(dc);

    ds.Tables.Add(dt);

    Chart1.Visible = true;

    Chart1.DataSource = ds;

    Chart1.Series["Series1"].XValueMember = "dirname";

    Chart1.Series["Series1"].YValueMembers = "size";

    Chart1.DataBind();

    Chart1.Legends.Add("legend1");

    Chart1.Series["Series1"]["PointWidth"] = "0.4";

    Chart1.Series["Series1"].IsValueShownAsLabel = true;

    Chart1.Series["Series1"]["PieLabelStyle"] = "right";

    Chart1.Series["Series1"]["DrawingStyle"] = "rectangle";

    con.Close();

    ListBox1.Visible = false;

    ListBox2.Visible = false;

    }

    }

    }

    you have to use third party feature for that you can download DLL for that from web and implement it.