ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Trouble with getXCoor
Posted by Cank on Oct-20-2011 18:51
Attachments:
Hi,

I try to draw a colored rectangle as you explain it on this thread :
http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&pattern=drawarea+zone&thread=1164720127.

I want to place my rectangle between the X coordinates of the higher and the lower point of my chart so my code is :

(in C#)
chart.layoutAxes();
int peakX = chart.getXCoor(peak);
int valleyX = chart.getXCoor(valley);
area.rect(peakX, chart.getYCoor(chart.yAxis().getMinValue()), valleyX, chart.getYCoor(chart.yAxis().getMaxValue()), 0xFFCC66, 0xFFCC66);

(where peak is the higher value and valley the lower)

I link the chart I get.

When I set a breakpoint in my code, I can see that chart.getXCoor(peak) returns "557" whereas on the chart the x coord for the peak is 571 ...

Why does chart.getXCoor(peak) not returns the good value ?

Many thanks.

Cank.
trouble.png

  Re: Trouble with getXCoor
Posted by Peter Kwan on Oct-21-2011 00:53
Hi Cank,

Actually, for your case, I suggest the much simplier method:

chart.xAxis().addZone(peak, valley, 0xFFCC66);

In your original code, the peakX and valleyX does not seem to correspond to the actual position in the chart. Without seeing the complete code and the exact value of peak and valley, it is hard to diagnose the problem. One possibility I can think of immediately is that the plot area has changed after the rectangle is drawn (eg. by using packPlotArea), so the coordinates computed are no longer valid.

Anyway, the Axis.addZone method mentioned above should meet what you need.

Hope this can help.

Regards
Peter Kwan

  Re: Trouble with getXCoor
Posted by Cank on Oct-27-2011 17:29
Attachments:
Hi,

Thanks for your answer.

Actually I didn't use Axis.addZone because the green and red lines are hidden by the zone.
That's why I draw a rectangle as you explain in the other thread.

Is there a way to keep the lines in front of the zone ?

Thanks,

Cank
chartidr.png

  Re: Trouble with getXCoor
Posted by Peter Kwan on Oct-28-2011 03:20
Hi Cank,

Are you using getDrawArea to get the background draw area, then use DrawArea.line to draw the line? Instead of using this method, you may use BaseChart.addLine to draw the line. This allows the z-order of the line to be controlled, and by default, the line will stay on top of all other layers (and the zone).

Hope this can help.

Regards
Peter Kwan