Page 1 of 1

When to call tchart.Refresh()

Posted: Wed Nov 19, 2008 2:50 am
by 9787981
Hi NarcĂ­s.

You have the most knowledge of the type of application I've built, and I'm hoping you can provide some guidance on the issue I'm facing.

Essentially with all the customizations we've built, multiple custom axes, custom Legend positioning, custom and dynamic panel margin sizing based on best fit requirements and label font sizes, etc, etc, sometimes we can get into a situation where some of the chart components don't line up, and won't line up until the next event (that calls .Refresh()) occurs.

For example if we have 2 custom x-axis then sometimes the y and x axes won't line up at their origin, say until the data for the series associated with the second custom x-axis arrives. This leaves the chart looking a little disjoint until it cleans/realigns itself when the next .Refresh() based event occurs.

Is there a mechanism or best practice that you can suggest, where .Refresh() can be called (without causing infinit recursion), so that the various chart bits are always gauranteed to be lined up?

I don't want to introduce something like an internal timer that calls .Refresh() every second or so, because this is wasteful and may cause CPU issues when many of our chart objects are concurrently active.

thanks,
Ben.

Posted: Wed Nov 19, 2008 9:01 am
by narcis
Hi Ben,

I'd try using it just after or before (depending on what's necessary) the code that does such customizations. However be very careful not using it in the AfterDraw and similar events to fall into an endless loop.