Click here to Skip to main content
15,346,659 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have tried to display table column values as bar chart representation.

i have to set the x axis value as last seven days from current day
(ie) if current day is 21-05-2022, i have to set upto 15-05-2022.


my code shows the table values in bar chart.
but how can i set dates in x axis.?
please help!

What I have tried:

SQLQuery = "SELECT CONVERT(DATE,TransDate) AS Dates,SUM(CASE WHEN TStatus = 'IW' THEN 1 ELSE 0 END) AS Check_In,SUM(CASE WHEN TStatus = 'OW' THEN 1 ELSE 0 END) AS Check_Out FROM Transactions WHERE CONVERT(DATE, TransDate) >= DATEADD(day, -7, GETDATE()) GROUP BY CONVERT(DATE, TransDate) ORDER BY CONVERT(DATE, TransDate)";


            DataSet ds = new DataSet();
            objBO.QueryType = SQLQuery.ToString();
            ds = objBAL.GetSearch(objBO);

            if (ds.Tables[0].Rows.Count != 0)
            {

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    
                    gvProduct.AutoGenerateColumns = true;
                    gvProduct.DataSource = ds.Tables[0];

                    gvProduct.DataBindings.ToString();
                }

            }
            else
            {
                MessageBox.Show("error");
            }
            chartefficiency.Series[0].XValueMember = "Check_In";
            chartefficiency.Series[0].YValueMembers = "Check_In";

            chartefficiency.Series[1].XValueMember = "Check_Out";
            chartefficiency.Series[1].YValueMembers = "Check_Out";
Posted

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