So the question is why is it displaying data in decimals that do not make sense, here's a screenshot
Here's the console output:
fVal: 1| fTime: 06:00:00
fVal: 1| fTime: 08:00:00
fVal: 1| fTime: 09:00:00
fVal: 1| fTime: 10:00:00
fVal: 1| fTime: 12:00:00
fVal: 2| fTime: 13:00:00
fVal: 2| fTime: 18:00:00
As you can see the values are not decimals. But when plotted on the chart it shows as a decimal. Things I have tried:
Here's my code:
Private Sub initSeriesData_Hourly() 'Count how many documents in a day is processed(globally)
Dim dataList As List(Of TimeSpan) = datasetHourly()
Dim dtList As New List(Of DateTime)
If Not dataList Is Nothing Then
For x As Integer = 0 To dataList.Count - 1
Dim dt As DateTime = New DateTime() + dataList.Item(x)
dtList.Add(dt)
Next
End If
Dim dataList_Count = countDateTime(dtList)
chart_ProcessedDocuments.RefreshData()
Dim pDoc_Series_1 As Series = chart_ProcessedDocuments.Series("Processed Documents(Hourly)")
If Not dataList_Count Is Nothing Then
Dim val As New List(Of Integer)
Dim time_ As New List(Of TimeSpan)
For hourData As Integer = 0 To dataList_Count.Count - 1
Dim timeSpanSplit = dataList_Count.Item(hourData).Split("|")
time_.Add(TimeSpan.Parse(timeSpanSplit(0)))
val.Add(timeSpanSplit(1))
Console.WriteLine(timeSpanSplit(0) + "|" + timeSpanSplit(1))
Next
'Dim pointscount = 24
'Dim pointsList As New List(Of SeriesPoint)
Dim fTime_List As New List(Of TimeSpan)
Dim fVal_List As New List(Of Integer)
For i As Integer = 0 To 23
Dim intTime As TimeSpan = TimeSpan.FromHours(i) 'Converts integer to timespan format
Dim fVal As Integer
Dim fTime As TimeSpan
If time_.Count > 0 Then
For j As Integer = 0 To time_.Count - 1
If intTime = time_(j) Then
fVal = val(j)
fTime = intTime
Console.WriteLine("fVal: " + fVal.ToString + "| fTime: " + fTime.ToString)
Else
fVal = 0
fTime = intTime
End If
fTime_List.Add(fTime)
fVal_List.Add(fVal)
Next
End If
Next
If fVal_List.Count > 0 Then
For length = 0 To fVal_List.Count - 1
Dim pointPlot As New SeriesPoint(fTime_List.Item(length), fVal_List.Item(length))
pDoc_Series_1.Points.Add(pointPlot)
Next
End If
Else
End If
End Sub
Sorry the code doesn't look good as I have been trying to solve the issue for 2 days now.
Found out that the loop is going over 24 and every iteration past that somehow reduces/divides the plotted value.
Changed the loop to this:
For index_0 As Integer = 0 To cTime_List.Count - 1
For index_1 As Integer = 0 To time_.Count - 1
If cTime_List.Item(index_0) = time_.Item(index_1) Then
Dim oldVal = cVal_List.Item(index_0)
cVal_List.Item(index_0) = val.Item(index_1)
Console.WriteLine(cTime_List.Item(index_0).ToString + "=" + time_.Item(index_1).ToString)
Console.WriteLine(oldVal.ToString + "<->" + val.Item(index_1).ToString)
End If
Next
'Console.WriteLine(index_0)
Dim pointPlot_1 As New SeriesPoint(cTime_List.Item(index_0), (cVal_List.Item(index_0)))
pDoc_Series_1.Points.Add(pointPlot_1)
Next