Progster -

Coincidentally, I had a short article that was almost ready, and that I was 
going to post to AmibrokerU soon.  This is a common problem, but workarounds 
depend on how you define the problem.  You defined it as -

"How to draw a chart just once"

One might wish for AB to have a native approach to bypass the recalc and 
repaint of a chart pane.  My guess is that this is problematic and maybe 
undesirable for a couple of reasons.  So, let's change the problem definition -

"How to speed up a chart when there is no change"

One obvious answer is to cache the result of the lengthy calculations, and read 
those results when a recalc is not needed for a redraw.  In pre - 5.24 
versions, this can be accomplished with AddToComposite().  With 5.24, it is 
much easier, and even quicker, with static arrays.

You might see if you can use this approach in your situation.  If you can, but 
this is not enough to get started, I'll try to complete the article and post 
late today.

-- Bruce

P.S. Minor gripe - I wish that Tomasz would release 5.30 soon.  It will have a 
number of useful, and even necessary, features from the Beta's, and it is 
easier and more acceptable to tell user's of code to upgrade to the latest 
release.


--- In [email protected], "progster01" <progs...@...> wrote:
>
> Hi.
> 
> I'm working a new-to-me corner of the AB universe lately, and I'm having an 
> issue that I don't yet know a solution for.  Perhaps someone else has been 
> here before and can point me in the right direction.
> 
> I've created a complex chart that requires alot of CPU to calculate and draw.
> 
> Using _TRACE() I can see that the chart code is executing approximately once 
> per second.  The effect of this is to tie up the CPU.
> 
> The nature of this chart is such that I only need to draw it once and I am 
> not interested in updating it a) on every tick, or b) every second.
> 
> IOW, I'd basically be satisfied to draw this chart once when I apply the AFL 
> to the pane.  (Secondarily, I might want to add a manual refresh button, but 
> that's beside the point at the moment.)
> 
> I have tried to put the entire code in a Status() condition like so:
> 
> RequestTimedRefresh( 20, onlyvisible = True ) ;               //      trying 
> to reduce CPU load, but this does not stop the "regular" refresh
> 
> RAS = Status( "redrawaction" ) ; // 1 if a timed refresh, else 0
> if( RAS == 1 ){
>    <Complex code here>
> }
> 
> The goal here is to prevent any "automatic" refreshes, and allow me to 
> specify a (much less frequent) TimedRefresh.
> 
> What I observe to happen in this case is that the chart paints (quickly) at 
> the TimedRefresh frequency, then disappears (goes blank, to the background 
> color) until the next TimedRefresh.
> 
> So, I'm currently stuck at either seeing the chart and paying the price for 
> constant refreshes, or having a flashing/disappearing chart which is useless 
> (but cheap!).
> 
> Thus the question, in a nutshell:
> 
>    How to Draw a Chart Just Once?
> 
> (and not have it disappear on you).
> 
> Thanks to anyone who can shed some light on this for me!
>


Reply via email to