Hi guys,
I have a problem when generating a chart from the objGraph.Application.
DataSheet using MSChart8(s. code):
The graph ist updated and therefore drawn everytime I update the DataSheet.
Since there isa lot of data
inserted into the DataSheet, this causes performance issues.
Any ideas ?
thx and best regards,
wwwpete
Dim RS As DAO.Recordset
Dim DateString, StartDate, SQL, UserName As String
Dim Feld() As Double 'enthält die Quantilsdaten
Dim UQuantile, EQuantile As Double
Dim i, j, tmp, NumberOfData As Long
Dim myGraph As Object
Dim objDS As Object
'Greife auf Datenblatt
Set objDS = ObjGraph.Application.DataSheet
objDS.Cells.Clear
'Spaltentitel setzen
objDS.Cells(1, 1) = "Quantile"
objDS.Cells(1, 2) = "Q2"
objDS.Cells(1, 3) = "UQuantile"
SQL = "SELECT * FROM ...;"
Set RS = CurrentDb().OpenRecordset(SQL, dbOpenSnapshot)
i = 0
Do While Not RS.EOF
ReDim Preserve Feld(i)
Feld(i) = RS("Quantile")
RS.MoveNext
i = i + 1
Loop
'Bestimme die Stichprobengrösse
NumberOfData = i
tmp = 0
For i = 0 To NumberOfData - 1
'Wahrscheinlichkeit bei U(0,1) ZV
UQuantile = (i + 1) / NumberOfData
'Bestimme die Anzahl der Quantile in der Stichprobe, die kleiner
als UQuantile sind.
If tmp -1 Then
j = tmp
Else
j = 0
End If
Do While (j < NumberOfData)
If Feld(j) UQuantile Then
Exit Do
End If
j = j + 1
Loop
tmp = j - 1
'empiriche Wahrscheinlichkeit aus Stichprobe
EQuantile = j / NumberOfData
'Schreibe Datensatz in Tabelle
objDS.Cells(i + 2, 1) = Feld(i)
objDS.Cells(i + 2, 2) = UQuantile
objDS.Cells(i + 2, 3) = Feld(i)
Next i
End If
'Schreibe Punkte (0,0) und (1,1) in Tabelle (für besser Darstellung).
objDS.Cells(NumberOfData + 2, 1) = 1
objDS.Cells(NumberOfData + 2, 3) = 1
objDS.Cells(NumberOfData + 3, 1) = 0
objDS.Cells(NumberOfData + 3, 3) = 0
Set objDS = Nothing
DoEvents
ObjGraph.Application.PlotBy = xlRows
ObjGraph.Application.PlotBy = xlColumns
ObjGraph.Refresh
Set ObjGraph = Nothing