Page 1 of 1

Custom line drawing

Posted: Fri Mar 23, 2012 7:59 pm
by 17461950
Hello,

I would like to draw several horizontal lines (parallel to the bottom/up axis), that denote some boundary values. These lines should start at the left axis' X and end at right axis X, at given height Y (but without right axis being shown). Unfortunately when Right axis is not shown, its getPosition() method returns 0, so it is unusable. Another thing that I tried is to use leftAxis' getPosition()+charts.Width(), but I couldn't find the correct Width method, that will return only the width within the chart (i.e. between right and left axes). Another thing I would like to do is to apply some clipping, so that when user pans on the chart, these horizontal lines are not drawn when they lie outside the chart area locked between the left/right/top/bottom axes.

this is what I do, with series set to use VerticalAxis.BOTH. This works, but I actually do not want to have Right axis shown.

IGraphics3D g3d = getChart().getGraphics3D();

for (int i=0;i<horiz_lines.length;i++) {
Point s = new Point(getChart().getAxes().getLeft().getPosition(), getChart().getAxes().getLeft().calcPosValue(horiz_lines));
Point e = new Point(getChart().getAxes().getRight().getPosition(), getChart().getAxes().getLeft().calcPosValue(horiz_lines));
g3d.moveTo(s);
g3d.lineTo(e,0);
}

Re: Custom line drawing

Posted: Mon Mar 26, 2012 8:28 am
by narcis
Hi pvasilev,
Unfortunately when Right axis is not shown, its getPosition() method returns 0, so it is unusable.
You can use bottom axis EndPosition instead:

Code: Select all

            tChart1.getAxes().getBottom().getEndPosition();
Bottom axis StartPosition and EndPosition will also provide horizontal coordinates for the start and end of the bottom axis.
Another thing I would like to do is to apply some clipping, so that when user pans on the chart, these horizontal lines are not drawn when they lie outside the chart area locked between the left/right/top/bottom axes.
Yes, this is possible. You should set clipping regions in the OnBeforeDrawChart event and clear them in the OnAfterDraw event. Something similar to what's done in OpaqueZonesDemo.java in the Swing demo at the Examples\Swing\Features\src\features\axes folder.

Re: Custom line drawing

Posted: Tue Mar 27, 2012 9:11 am
by 17461950
Hi Narcis,

thanks for your prompt reply. I will check and report back should any problems arise.