real (web chart) example of using data from database in a single method.
i think the preparation of data is the most difficult part.
Public Sub Chart(start As DateTime, interval As DateInterval, minmax As Boolean)
System.DebugLog CurrentMethodName
Chart1.RemoveAllDatasets
Chart1.RemoveAllLabels
Chart2.RemoveAllDatasets
Chart2.RemoveAllLabels
'------------------------------------------
Var db As New Module1.DB
Call db.Connect
Var d2 As DateTime = start
Var d1 As DateTime = d2 - interval 'zurück
// Second set of data
Var data1() As Double
Var data2() As Double
Var data3() As Double
Var data4() As Double
Var data5() As Double
Var data6() As Double
Var data7() As Double
For d As Integer = 1 To Chart1.Width / 24.0
Chart1.AddLabel d1.ToString(DateTime.FormatStyles.Medium,DateTime.FormatStyles.Short)
Chart2.AddLabel d1.ToString(DateTime.FormatStyles.Medium,DateTime.FormatStyles.Short)
Var s1 As Double = d1.SecondsFrom1970
Var s2 As Double = d2.SecondsFrom1970
Var rows As RowSet = db.SelectSQL("Select avg(VTIst) as VTIst, max(VTIst) as VTIstMax, min(VTIst) as VTIstMin, avg(VTSoll) as VTSoll, avg(AussenTemperatur) as AussenTemperatur, min(AussenTemperatur) as AussenTemperaturMin, max(AussenTemperatur) as AussenTemperaturMax From Zustand Where DateTime >=? and DateTime <= ?",s1,s2)
While Not rows.AfterLastRow
data1.Add(rows.Column("VTSoll").DoubleValue)
data2.Add(rows.Column("VTIst").DoubleValue)
data3.Add(rows.Column("AussenTemperatur").DoubleValue)
data4.Add(rows.Column("AussenTemperaturMin").DoubleValue)
data5.Add(rows.Column("AussenTemperaturMax").DoubleValue)
data6.Add(rows.Column("VTIstMax").DoubleValue)
data7.Add(rows.Column("VTIstMin").DoubleValue)
rows.MoveToNextRow
Wend
d1 = d1 - interval
d2 = d2 - interval
Next
'------------------------------------------
Var myset1 As New WebChartLinearDataset("VT Soll °C", &cFF0000, False, data1)
myset1.ChartType = WebChartLinearDataset.ChartTypes.Line
Chart1.AddDataset(myset1)
Var myset2 As New WebChartLinearDataset("VT Ist °C", &cFF0000, True, data2)
myset2.ChartType = WebChartLinearDataset.ChartTypes.Line
Chart1.AddDataset(myset2)
If minmax = True Then
Var myset6 As New WebChartLinearDataset("VT Ist Max °C", &c808080, False, data6)
myset6.ChartType = WebChartLinearDataset.ChartTypes.Line
Chart1.AddDataset(myset6)
Var myset7 As New WebChartLinearDataset("VT Ist Min °C", &c808080, False, data7)
myset7.ChartType = WebChartLinearDataset.ChartTypes.Line
Chart1.AddDataset(myset7)
End If
Var myset3 As New WebChartLinearDataset("Aussen °C", &c404040, False, data3)
myset3.ChartType = WebChartLinearDataset.ChartTypes.Line
Chart2.AddDataset(myset3)
If minmax = True Then
Var myset4 As New WebChartLinearDataset("Aussen °C Min.", &c808080, False, data4)
myset4.ChartType = WebChartLinearDataset.ChartTypes.Line
Chart2.AddDataset(myset4)
Var myset5 As New WebChartLinearDataset("Aussen °C Max.", &c808080, False, data5)
myset5.ChartType = WebChartLinearDataset.ChartTypes.Line
Chart2.AddDataset(myset5)
End If
'------------------------------------------
db.Close
'------------------------------------------
End Sub
interval box
SelectInterval.RemoveAllRows
SelectInterval.AddRow("5 Min.",New DateInterval(0, 0, 0, 0, 5))
SelectInterval.AddRow("15 Min.",New DateInterval(0, 0, 0, 0, 15))
SelectInterval.AddRow("30 Min.",New DateInterval(0, 0, 0, 0, 30))
SelectInterval.AddRow("1 Std.",New DateInterval(0, 0, 0, 1))
SelectInterval.AddRow("2 Std.",New DateInterval(0, 0, 0, 2))
SelectInterval.AddRow("4 Std.",New DateInterval(0, 0, 0, 4))
SelectInterval.AddRow("1 Tag",New DateInterval(0, 0, 0, 24))
SelectInterval.AddRow("7 Tage (Woche)",New DateInterval(0, 0, 0, 24.0 * 7.0))
SelectInterval.AddRow("4,3 x 7 Tage (Monat)",New DateInterval(0, 0, 0, 24.0 * 7.0 * 4.3))
SelectInterval.SelectedRowIndex = 5