I have a database with a table MarkPoints. From this table I need 7 fields to bring to my chart (Date, X,Y,Z,MX which is (StartX-X), MY which is(StartY-Y) ,MZ which is (StartZ-Z) in cm).
This table has many records let's say 20.000.
And I have many MarkPoints max 10 min 5 in every TAChart.
I draw 5 charts at once and every chart has at the bottom axis the date of every record.
So to sum up I have 6 Charts X 5 PointMarks in every Chart X 20.000 records in every MarkPoint . Which means 600.000 points to draw.
I start with every point as I bring it from the Query and I draw that point to all Charts and after that I continue with the rest points.
For example let's say that I have point1, point2...point5. I start with point1 and I draw the (Date bottom axis -X in cm in the left axis) X diagram first, after that the (Date to the bottom axis / Y in cm to the left axis) Y diagram,....Z diagram,....MZ diagram. After that it comes point 2, point 3, point 4 and point 5.
The problem is that it takes to much time. I mean about 7 to 10 minutes!!!Is that logical???Shouldn't it be faster?The thing is that I have tested it to two laptops one fast enough and one much more slower. The speed hasn't change too much. Maybe one or two minutes at most.
(1st laptop: core i7, 16GB RAM, SSD 250GB // 2nd laptop: centrino duo, 4GB RAM, HARD DISK 5.200rpm)
The routine that I use to draw the first MarkPoint is the following:
1)I call the SQL Query(firebird 2.5) to bring the Data:ViewChartQuery.SQL.Text:='SELECT X, Y, Z, MX, MY, MZ, MYDATE FROM POINTMARKS WHERE POINTMARKS .pointid = :chartpointid AND AND MYDATE >= :FILTERSTARTDATE AND MYDATE <= :FILTERENDDATE ORDER BY MYDATE ASC';
2)After that I bring all these data to arrays. I create six arrays (as many as my fields are) where I collect my data. type
TMark = record
x: Tfloat;
y: Tfloat;
end;
MarksArray = array of TMark ;
ArrayX,ArrayY,...,ArrayMZ : array of MarksArray;
...
procedure TViewChartsfrm.FillMarksArrays;
var
i: integer;
begin
for i := 0 to ViewChartQuery.RecordCount - 1 do
begin
if not VarIsNull(ViewChartQuery.FieldByName('X').Value) then
begin
SetLength(ArrayX, Length(MeasArrayX) + 1);
ArrayX[High(ArrayX)].x := ViewChartQuery.FieldByName('MYDATE').AsDateTime;
ArrayX[High(ArrayX)].y := ViewChartQuery.FieldByName('X').AsFloat;
end;
if not VarIsNull(ViewChartQuery.FieldByName('Y').Value) then
begin
SetLength(ArrayY, Length(ArrayY) + 1);
ArrayY[High(ArrayY)].x := ViewChartQuery.FieldByName('MYDATE').AsDateTime;
ArrayY[High(ArrayY)].y := ViewChartQuery.FieldByName('Y').AsFloat;
end;
......
if not VarIsNull(ViewChartQuery.FieldByName('MZ').Value) then
begin
SetLength(ArrayMZ, Length(ArrayMZ) + 1);
ArrayMZ[High(ArrayMZ)].x := ViewChartQuery.FieldByName('MYDATE').AsDateTime;
ArrayMZ[High(ArrayMZ)].y := ViewChartQuery.FieldByName('MZ').AsFloat;
end;
if i < ViewChartQuery.RecordCount then
ViewChartQuery.Next;
end;
3)After filling the arrays I draw as usual...
for i := Low(ArrayX) to High(ArrayX) do
begin
xdate := ArrayX[i].x;
yfromx := ArrayX[i].y;
lineX.AddXY(xdate , yfromx , 'Pointname:' + focusChartPointName + ', X(datetime):' + FormatDateTime('dd/mm/yy hh:nn', xdate ) + ', Y(mm):');
end;
....
for i := Low(ArrayMZ) to High(ArrayMZ) do
begin
MZdate := ArrayMZ[i].x;
yfromMZ := ArrayMZ[i].y;
lineMZ.AddXY(MZdate , yfromMZ , 'Pointname:' + focusChartPointName + ', X(datetime):' + FormatDateTime('dd/mm/yy hh:nn', MZdate ) + ', Y(mm):');
end;
I use arrays as in same cases I pass them through filters like Moving Average(where the user defines the number of measurements of the filter).
The drawing speed without filter and with filter(moving average) is almost the same which means the filter isn't responsible for the speed.
Maybe the drawing speed is normal to such ammount of data or maybe this can be faster.
Thanks in advance