Count Values in a chart

102 Views Asked by At

i'm creating charts connected to my database using the following code,

        string query= "SELECT codprojeto, n_formandos FROM  projetos";

        if(a.open_connection() == true)
        {
            MySqlCommand cmd = new MySqlCommand(query, a.connection);
            MySqlDataReader dataReader= cmd.ExecuteReader();

            if(dataReader.HasRows)
            {
                DataTable dt= new DataTable();
                dt.Load(dataReader);
                chart1.DataSource= dt;

                chart1.Series[0].XValueMember = "n_formandos";
                chart1.Series[0].YValueMembers = "codprojeto";
                chart1.Series[0].IsXValueIndexed = false;
                chart1.Series[0].IsValueShownAsLabel = true;  
                chart1.Series[0].ChartType = SeriesChartType.Column;
                chart1.DataBind();


            }

            dataReader.Close();
            a.close_connection();
        }

The thing is i would like to count the number of "n_formandos" for each "codprojeto" and i'm not finding any ideas how to.

this is what i have,

https://i.stack.imgur.com/GmeGi.jpg

0

There are 0 best solutions below