0

I wish to create a chart using microsoft visual studio 2010 but I do not know how to do it. Tried googling for answer but none of them is for 3 tier.

This is my code for the Data Access Layer

    public List<AdvertisementDAL> displayChart()
    {
        List<AdvertisementDAL> dal = new List<AdvertisementDAL>();
        string sql = "Select * From AdvertisementRecord";
        SqlConnection conn = new SqlConnection(_connStr);
        SqlCommand cmd = new SqlCommand(sql, conn);
        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            _recordID = int.Parse(dr["RecordID"].ToString());
            _recordDate = dr["RecordDate"].ToString();
            _noOfClick = int.Parse(dr["NoOfClick"].ToString());
            _noOfView = int.Parse(dr["NoOfView"].ToString());
            _advertisementID = int.Parse(dr["FK_AdvertisementID"].ToString());
            dal.Add(new AdvertisementDAL(_recordID, _recordDate, _noOfClick, _noOfView, _advertisementID));
        }
        conn.Close();
        dr.Close();
        dr.Dispose();
        return dal;
    }
}

This is my Business Logic Layer

    public List<AdvertisementDAL> pieChart()
    {
        AdvertisementDAL dal = new AdvertisementDAL();
        List<AdvertisementDAL> dll = new List<AdvertisementDAL>();
        dll = dal.displayChart();
        return dll;
    }

This is my Presentation Layer(All I know is bind the data together)

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            AdvertisementBLL bll = new AdvertisementBLL();
            Chart1.DataSource = bll.pieChart();
            Chart1.DataBind();
        }
    }

I guess I'm stuck in Presentation layer any help? The bar will look something like this

user1861753
  • 91
  • 1
  • 3
  • 11
  • you need to specify what do you want to show on x-axis and on y-axis, menas the name of properties. – शेखर Dec 25 '12 at 07:10
  • On my X axis it will be number 1-100 On my Y Axis it will be the recordDate. On the bar chart, It have 2 bar chart 1 is NoOfClick and another 1 will be noOfView – user1861753 Dec 25 '12 at 07:14

1 Answers1

0

You can use like this

// Set series members names for the X and Y values 
chart1.Series["Series 1"].XValueMember = "porpery1"; 
chart1.Series["Series 1"].YValueMembers = "property 2"; 
// Data bind to the selected data source 
chart1.DataBind(); 

More reading source

I think here is a good example you can go through this link
http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx
http://documentation.devexpress.com/#XtraCharts/CustomDocument7787
http://www.codeproject.com/Articles/117998/A-look-inside-the-ASP-NET-Charting-conlrol

शेखर
  • 17,412
  • 13
  • 61
  • 117
  • http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspxhttp://documentation.devexpress.com/#XtraCharts/CustomDocument7787 the website doesn't exist – user1861753 Dec 25 '12 at 07:22
  • Hi, I still do not understand a single thing from the codeproject.com. maybe you can help me out? – user1861753 Dec 25 '12 at 07:23