Board index » delphi » TChart how to beginUpdate and EndUpdate

TChart how to beginUpdate and EndUpdate


2007-02-03 12:32:54 AM
delphi125
In TStringList.
it can call BeginUpdate before doing lots of updates and then calling
EndUpdate to apply the updates at 1 time.
I want to do the same for TChart's series.
It is too slow now when I add points to multiple series.
Is it possible?
Dennis
 
 

Re:TChart how to beginUpdate and EndUpdate

Hi Dennis,
You can keep the series length, and just update the values. So don't use
Clear and then multiple Adds. Only do that once at the beginning, then next
time use the Series' Count property, and set your values like
MySeries.XValues[i] := <some x value>
MySeries.YValues[i] := <some y value>
This is faster, because the array under the hood doesn't have to be
reallocated the whole time.
Nils
"Dennis Poon" <XXXX@XXXXX.COM>schreef in bericht
Quote
In TStringList.
it can call BeginUpdate before doing lots of updates and then calling
EndUpdate to apply the updates at 1 time.

I want to do the same for TChart's series.
It is too slow now when I add points to multiple series.
Is it possible?

Dennis

 

Re:TChart how to beginUpdate and EndUpdate

Thanks for your reply.
But it is not very useful because I have 8 series in the chart that will add
new points at the same time once a second.
Looks like TChart redraws the chart after I add point to EACH series i.e.
Tchart repaint 8 times a second instead of just 1 after I add points to 8
series at the same time.
I draw overriding the TChart.Draw(Canvas : TCanvas; const Rect :
TRect);override;
But it does not help. It is only called once after all series are
repainted. :-(
Any help? I really want a BeginUpdate and EndUpdate method for TChart.
The charts are for stock prices which changes very very quickly. Needs to
be done fast and light on the CPU.
Dennis
"Nils Haeck" <XXXX@XXXXX.COM>writes
Quote
Hi Dennis,

You can keep the series length, and just update the values. So don't use
Clear and then multiple Adds. Only do that once at the beginning, then
next time use the Series' Count property, and set your values like

MySeries.XValues[i] := <some x value>
MySeries.YValues[i] := <some y value>

This is faster, because the array under the hood doesn't have to be
reallocated the whole time.

Nils

"Dennis Poon" <XXXX@XXXXX.COM>schreef in bericht
news:45c36776$XXXX@XXXXX.COM...
>In TStringList.
>it can call BeginUpdate before doing lots of updates and then calling
>EndUpdate to apply the updates at 1 time.
>
>I want to do the same for TChart's series.
>It is too slow now when I add points to multiple series.
>Is it possible?
>
>Dennis
>


 

Re:TChart how to beginUpdate and EndUpdate

Denis - I wonder if LockWindow Update would help :_
LockWindowUpdate(thewindowhandle) - to lock
LockWindowUpdate(0) - to unlock
Ron
"Dennis Poon" <XXXX@XXXXX.COM>writes
Quote
Thanks for your reply.
But it is not very useful because I have 8 series in the chart that will
add new points at the same time once a second.
Looks like TChart redraws the chart after I add point to EACH series i.e.
Tchart repaint 8 times a second instead of just 1 after I add points to 8
series at the same time.


I draw overriding the TChart.Draw(Canvas : TCanvas; const Rect :
TRect);override;
But it does not help. It is only called once after all series are
repainted. :-(

Any help? I really want a BeginUpdate and EndUpdate method for TChart.

The charts are for stock prices which changes very very quickly. Needs to
be done fast and light on the CPU.

Dennis

"Nils Haeck" <XXXX@XXXXX.COM>writes
news:45c47bba$XXXX@XXXXX.COM...
>Hi Dennis,
>
>You can keep the series length, and just update the values. So don't use
>Clear and then multiple Adds. Only do that once at the beginning, then
>next time use the Series' Count property, and set your values like
>
>MySeries.XValues[i] := <some x value>
>MySeries.YValues[i] := <some y value>
>
>This is faster, because the array under the hood doesn't have to be
>reallocated the whole time.
>
>Nils
>
>"Dennis Poon" <XXXX@XXXXX.COM>schreef in bericht
>news:45c36776$XXXX@XXXXX.COM...
>>In TStringList.
>>it can call BeginUpdate before doing lots of updates and then calling
>>EndUpdate to apply the updates at 1 time.
>>
>>I want to do the same for TChart's series.
>>It is too slow now when I add points to multiple series.
>>Is it possible?
>>
>>Dennis
>>
>
>


 

Re:TChart how to beginUpdate and EndUpdate

Dennis Poon writes:
| Thanks for your reply.
| But it is not very useful because I have 8 series in the chart that
| will add new points at the same time once a second.
| Looks like TChart redraws the chart after I add point to EACH series
| i.e. Tchart repaint 8 times a second instead of just 1 after I add
| points to 8 series at the same time.
You could try using the TCustomTeePanel.AutoRepaint property, e.g.
Setting AutoRepaint to False will not refresh the Chart display until we
manually
call the Chart1.Repaint method.
Chart1.AutoRepaint := False;
try
Chart1.Gradient.Color:=clBlue;
...
Series1.Add( 123, 'Hello world', clRed );
...
finally
Chart1.AutoRepaint := True;
end;
--
Christopher Ireland
"Certainly nothing is unnatural that is not physically impossible."
Richard Brinsley Sheridan