ColorLine is drawn on top of the annotation

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Dennis
Newbie
Newbie
Posts: 4
Joined: Fri Mar 13, 2015 12:00 am

ColorLine is drawn on top of the annotation

Post by Dennis » Wed Mar 18, 2015 7:42 pm

Hi.

Using Java for Android v3.2015.0108

I have several Annotations on my chart. When I'm adding ColorLines that correspond to the bottom axis, I have an issue that these ColorLines are drawn on top of the annotations.

Is there any solution how to draw ColorLines behind annotations? I was looking for something like z-order for annotations' shapes and ColorLines but found nothing.

Yeray
Site Admin
Site Admin
Posts: 9509
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: ColorLine is drawn on top of the annotation

Post by Yeray » Thu Mar 19, 2015 11:25 am

Hi Dennis,

The order of adding the tools on the chart determines the drawing order.
Adding an Annotation, then adding a ColorLine and then adding a second Annotation gives this:

Code: Select all

		tChart1.getAspect().setView3D(false);
		tChart1.getLegend().setVisible(false);
		
		Points points1 = new Points(tChart1.getChart()); 
		points1.fillSampleValues();
		
		Annotation annot1 = new Annotation(tChart1.getChart());
		annot1.setText("This is annotation 1");
		annot1.getShape().setCustomPosition(true);
		annot1.setLeft(150);
		annot1.setTop(100);
		
		ColorLine colorLine1 = new ColorLine(tChart1.getChart());
		colorLine1.setAxis(tChart1.getAxes().getBottom());
		colorLine1.setValue(10);
		
		Annotation annot2 = new Annotation(tChart1.getChart());
		annot2.setText("This is annotation 2");
		annot2.getShape().setCustomPosition(true);
		annot2.setLeft(150);
		annot2.setTop(150);
2015-03-19_1219.png
2015-03-19_1219.png (3.34 KiB) Viewed 26126 times
But you can reorder the tools in the list:

Code: Select all

		//reorder
		Tool tmp = tChart1.getTools().getTool(2);
		tChart1.getTools().setTool(2, tChart1.getTools().getTool(0));
		tChart1.getTools().setTool(0, tmp);
2015-03-19_1220.png
2015-03-19_1220.png (2.59 KiB) Viewed 26122 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Dennis
Newbie
Newbie
Posts: 4
Joined: Fri Mar 13, 2015 12:00 am

Re: ColorLine is drawn on top of the annotation

Post by Dennis » Thu Mar 19, 2015 1:17 pm

Thank you, Yeray.

I guessed that the order of adding tools can infuence on the result. But the question is that I have to redraw color lines each time when chart painted, and annotations are created only once on startup.
I'm using ColorLine to highlight some grid lines (with a different color and line style). And the grid always changes as the data is loaded to the chart (I have realtime chart). I guess that recreate annotations for every time when data loaded is not the best solution... So probably you can provide any other options how to draw color lines behind the annotation?

Yeray
Site Admin
Site Admin
Posts: 9509
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: ColorLine is drawn on top of the annotation

Post by Yeray » Thu Mar 19, 2015 3:12 pm

Hello,

You can also set the ColorLines to be always drawn before the series (and also before the other tools like the Annotation tool) with DrawBehind:

Code: Select all

		ColorLine colorLine1 = new ColorLine(tChart1.getChart());
		colorLine1.setAxis(tChart1.getAxes().getBottom());
		colorLine1.setValue(10);
		colorLine1.setDrawBehind(true);
However, I'm not sure if this will fit your requirements.
If you still find problems with it, please try to arrange a simple example project we can run as-is to reproduce the situation here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply