Page 1 of 1

Custom Labels problem

Posted: Mon Feb 27, 2012 4:09 pm
by 10047857
Hi

Another simple question - I am adding custom labels to the right axis of a chart I have created. The left axis is displaying rainfall in millimeters and the right hand axis is displaying the values in inches. I copied your example from the demo program and it works fine but not the first time it displays. It works fine the second and subsequent times I use it.

I call the procedure after I have plotted the graph and set the extents of the axis. I have tried placing a chart.refresh or chart.update before calling my addlabels procedure but with no luck. When I add a break point inside the procedure I notice that properties such as chart.Axes.Right.Maximum have zero values when they should have much higher ones. I use this value to work out how many values I need to plot labels for. Can you suggest a solution?

Bruce.

Re: Custom Labels problem

Posted: Mon Feb 27, 2012 4:21 pm
by 10047857
Hi

I think the problem is that I should be adding custom labels using the OnAfterDraw event and not after I have just filled them.

Bruce.

Re: Custom Labels problem

Posted: Tue Feb 28, 2012 4:13 pm
by yeray
Hi Bruce,
Metman wrote:I think the problem is that I should be adding custom labels using the OnAfterDraw event and not after I have just filled them.
Right, it will probably be something like that. Note that some properties need the chart to have finished the drawing process to have valid values. If you are using some of these properties, you could force a chart repaint before using them.
The OnAfterDraw event could be a solution, but note using it may not be the most efficient solution.
Instead of that, you could call the Draw() method to force the chart repaint, and then place your custom labels once.