I want to plot a graph where in the X axis should appear the name of some production lines, and in the Y axis the total time the lines were stopped (E.G: 110:43:00h) but i'm having some problems. Here's my code:
Dim cmd As New MySqlCommand
Chart2.Series.Add("Stops")
Try
ConnectDatabase()
With cmd
.Connection = conn
.CommandText = "SELECT X as lines, time_format(SEC_TO_TIME(SUM(abs(TIME_TO_SEC(timediff(Y, Z))))),'%H:%i:%s') AS SUM FROM M, N WHERE a = b GROUP BY P"
End With
Dim objReader As MySqlDataReader = cmd.ExecuteReader
While objReader.Read
Chart2.Series("Stops").Points.AddXY(objReader("lines").ToString, objReader("SUM").ToString)
End While
Catch ex As Exception
If ex.InnerException IsNot Nothing Then
MsgBox(ex.InnerException)
End If
End Try
DisconnectDatabase()
The MySQL query is correct, and i can see the X axis correctly, but in the Y axis nothing appears, and it doesn't plot anything. Can you please help? What am i doing wrong?
There's a print of how SUM looks like:
Thanks.
UPDATE: Problem solved. In the select query i just select the data in Hours.