Moin,
mein Code sieht so aus
ich bekomme die Fehlermeldung Null Objekt bei hChart.Datas.Add(ChartDatas(z, [ma, mi])) in Public Sub rechnemaTemp()
gambas code
Public Sub rechnemaTemp()
Dim $hConn As New Connection
Dim hResult As Result
Dim query As String
Dim maxtag As Integer
Dim z As Integer
Dim ltmon As String
Dim ma As Variant
Dim mi As Variant
If (ComboBoxTmpMon.Index < 0) Then
maxtag = 1
Else
maxtag = ComboBoxTmpMon.Index
Endif
If (maxtag > 11) Then maxtag = 11
With $hConn
.Type = "sqlite3" ' ' wird im Original aus dem Form geholt.
.Host = "/home/" & user.Name & "/" & "mienimmen"' ohne Dateiname !"
.Name = "" & FMain.myordner & ".sqlite3"
End With
db.Debug = False
$hConn.Open
ltmon = ComboBoxTmpMon.Text
If ltmon = "" Then ltmon = "1"
For z = 1 To tar[maxtag]
Print "tag:" & z
' query = "SELECT MAX(CAST(feld2 AS REAL)) AS maxTemp FROM stockwaage WHERE mon = ? AND jahr = ?"
query = "SELECT MAX(feld2) AS maxTemp,MIN(feld2) AS minTemp FROM stockwaage WHERE mon = '" & ltmon & "' AND jahr = '" & ComboBox3.Text & "' and tag ='" & z & "'"
hResult = $hConn.Exec(query)
While (hResult.Available)
Print "max:" & hResult!maxTemp & "min:" & hResult!minTemp
ma = hResult!maxTemp
mi = hResult!minTemp
If ma = "" Then ma = "0"' nicht jeder Tag enthält Temp werte
If mi = "" Then mi = "0"
hChart.Datas.Add(ChartDatas(z, [ma, mi]))
hResult.MoveNext()
Wend
Next
$hConn.Close
GenerateChart()
End
Private Sub GenerateChart()
Dim hChartData1, hChartData2, hChartData3, hChartData4 As ChartDatas
Dim m1, m2, m3, m4 As ChartDatas
'-- Settings the function values of the single data series
'-- Einstellungen der Funktionswerte der einzelnen Datenreihen
' hChartData1 = ChartDatas("2018", [1.0, 2, 3, 4, 5, 4.2])
' hChartData2 = ChartDatas("2019", [1.2, 2.3, 3.4, 4.5, 5.3, 3.5])
' hChartData3 = ChartDatas("2020", [1.3, 2.4, 3.5, 4.2, 4.9, 3.8])
' hChartData4 = ChartDatas("2021", [1.1, 2.2, 3.1, 4.3, 4.6, 4])
' hChart.Datas = [hChartData1, hChartData2, hChartData3, hChartData4]
' hChart.Datas = [hChartData1]
' hChart.Datas.Add(ChartDatas("m1", [12, 5]))
' hChart[0].Text = "m1"
' hChart[0].values = [12, 0]
'hChart.Datas.
'-- Setting essential properties
'-- Festlegen wesentlicher Eigenschaften
hChart.SetStyle("Bar")
hChart.AutoScale = True
hChart.Border = True
'-- Chart-Legend
hChart.Legend.Position = Align.Right
hChart.Legend.Visible = True
hChart.Legend.Title = "Legend"
'-- Setting the arguments for the Legend
'-- Festlegen der Argumente für die Legende
hChart.Labels = ["A_12", "P_04", "H_53", "K_74", "P_92", "M_16"]
'-- Chart-Caption
'-- Diagramm-Beschriftung
hChart.Title.Text = "Temperaturen im Monat " & ComboBoxTmpMon.text
hChart.Title.Font.Name = "Monospace"
hChart.Title.Visible = True
'-- Specifying colors for the individual data rows instead of the default colors
'-- Festlegen von Farben für die einzelnen Datenzeilen anstelle der Standardfarben
hChart.Colors = [&hff6f00, &h800080, &h7da647, &hA0A0A0, &hFF3F3F, &h290099]
With hChart
.Style!Y_AutoScale = True
.Style!Y_Step = 1
.Style!Y_Font = Font["Monospace,+2"]
.Style!ShowValues = True
.Style!Y_Pattern = "0.0"
.Style!Y_Label = "Temperaturen"
'----------------------------------------------------------------------------------
.Style!X_Label = "Monate"
.Style!X_Font = Font["Arial,+2"]
'----------------------------------------------------------------------------------
.Style!Padding = 10
.Style!BarFont = Font["Monospace, 9"]
.Style!Border = False '
.Style!ShowArrows = True
.Style!ShowInterlines = True
.Style!InterlinesColor = Color.Lighter(Color.Blue)
.Style!BarWidth = 0.9
.Style!SeriesPadding = 1.3
End With
DrawingAreaTmp.Refresh()
End
Lg Dirk