Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone hope you are ok i need help for creating asp.net control charts. I need to create two charts.

Chart 1 - Stacked column chart

I have 3 attributes status, date and saleAmount i need to create the chart to display the values like this x axis( months), y axis saleAmount and point to display the status and count it.

Chart 2 Stacked column chart

I have 2 attributes date and sum saleAmount i need to create the chart to display the values like this x axis( months), y axis saleAmount and point to display the different years for each month.

I tried to look everywhere but didnt find nothing in internet
the code what i created now is not right Please help

What I have tried:

C#
private void bind10()
    {
                //Fetch the Statistical data from database.
                string query = "SELECT status, DATEPART(Month, Date) as [Year], COUNT(weightedValue) as [Total]";
    query += " FROM SalesActivity INNER JOIN STATUS ON SalesActivity.Status_ID = STATUS.Status_ID  WHERE status IN ('Request for info', 'Quotation', 'Negotiating','Order Placed', 'Lost' )";
                query += " GROUP BY status, DATEPART(Month, Date)";
                DataTable dt = GetData(query);

    //Get the DISTINCT Countries.
    List<string> statuses = (from p in dt.AsEnumerable()
                              select p.Field<string>("status")).Distinct().ToList();

                //Loop through the Countries.
                foreach (string status in statuses)
                {

                    //Get the Year for each Country.
                    int[] x = (from p in dt.AsEnumerable()
                               where p.Field<string>("status") == status
                               orderby p.Field<int>("Year") ascending
                               select p.Field<int>("Year")).ToArray();

    //Get the Total of Orders for each Country.
    int[] y = (from p in dt.AsEnumerable()
               where p.Field<string>("status") == status
               orderby p.Field<int>("Year") ascending
               select p.Field<int>("Total")).ToArray();

    //Add Series to the Chart.
    Chart10.Series.Add(new Series(status));
                    Chart10.Series[status].IsValueShownAsLabel = true;
                    Chart10.Series[status].ChartType = SeriesChartType.StackedColumn;
                    Chart10.Series[status].Points.DataBindXY(x, y);

                    Chart10.Legends[0].Enabled = true;
                }
            }
Posted
Updated 16-Apr-18 5:31am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900