Control X-axis markup in date data graphs

0

I have records in the database and a graph where I can preview them. The graph is data x Voltage in volts.

When I have few records in the table the graph shows exactly the date recorded in the bank on the X axis, but over the time I add more records the graph grows and stops marking all the date records where there was a voltage variation .

I am putting an image of how the chart is:

Thischartistaking50entriesfrommybankwithdifferenttimesandvoltagevalues.

IwouldlikeawaytoimproveandbeabletobettercontroltheX-axispoints,perhapsmakingthemappearevery10minutesforexample.

Belowisthecodethatgeneratesthegraphics:

SqlConnectioncon=newSqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringSQL"].ConnectionString);
    con.Open();
    SqlCommand cmd = new SqlCommand("SELECT Log.ValorEntrada, Log.DataHoraEvento, Log.NumeroEntrada FROM Log INNER JOIN Equipamento ON Log.IDEquipamento = Equipamento.IDEquipamento INNER JOIN EntradaEstado ON Equipamento.IDEquipamento = EntradaEstado.IDEquipamento INNER JOIN Entrada ON EntradaEstado.IDEntrada = Entrada.IDEntrada WHERE Log.NumeroEntrada = N'" + descricao.SelectedItem.Value + "' AND Log.ValorEntrada IS NOT NULL AND DATEDIFF(day, Log.DataHoraEvento, GETDATE()) = 1 AND EntradaEstado.IDEquipamento = N'" + equip.Text + "' AND Entrada.Descricao = N'" + descricao.SelectedItem.Text + "' ORDER BY DataHoraEvento ASC");
    cmd.Connection = con;
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataTable dt = new DataTable();
    da.Fill(dt);

    if (dt.Rows.Count > 0)
    {
        Chart2.DataSource = dt;

        if (descricao.SelectedItem.Text == "Corrente da bomba de graxa")
        {
            Chart2.ChartAreas["ChartArea1"].AxisY.Title = "Corrente (A)";
        }
        else
        {

            Chart2.ChartAreas["ChartArea1"].AxisY.Title = "Tensão (V)";
        }

        Title title = Chart2.Titles.Add("Gráfico do dia: " + DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy"));
        title.ForeColor = System.Drawing.Color.DarkBlue;
        title.Font = new System.Drawing.Font("Arial", 12, System.Drawing.FontStyle.Bold);




        Chart2.ChartAreas["ChartArea1"].AxisX.Title = "Hora";
        Chart2.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "HH:mm:ss";
        Chart2.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = System.Drawing.Color.DarkGray;
        Chart2.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot;
        Chart2.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = System.Drawing.Color.DarkGray;
        Chart2.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot;


        Chart2.Series["Series1"].XValueType = ChartValueType.DateTime;
        Chart2.Series["Series1"].BorderWidth = 2;
        Chart2.Series["Series1"].XValueMember = "DataHoraEvento";
        Chart2.Series["Series1"].YValueMembers = "ValorEntrada";
        Chart2.Series["Series1"].IsXValueIndexed = true;

        Chart2.Width = 1200;
        Chart2.Height = 400;

        Chart2.DataBind();
        con.Close();
    
asked by anonymous 10.08.2017 / 21:52

0 answers