Custom line drawing

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
pvasilev
Newbie
Newbie
Posts: 4
Joined: Mon Mar 12, 2012 12:00 am

Custom line drawing

Post by pvasilev » Fri Mar 23, 2012 7:59 pm

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);
}

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Custom line drawing

Post by Narcís » Mon Mar 26, 2012 8:28 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

pvasilev
Newbie
Newbie
Posts: 4
Joined: Mon Mar 12, 2012 12:00 am

Re: Custom line drawing

Post by pvasilev » Tue Mar 27, 2012 9:11 am

Hi Narcis,

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

Post Reply