Page 1 of 1

ColorLine is drawn on top of the annotation

Posted: Wed Mar 18, 2015 7:42 pm
by 17073287
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.

Re: ColorLine is drawn on top of the annotation

Posted: Thu Mar 19, 2015 11:25 am
by yeray
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 41904 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 41900 times

Re: ColorLine is drawn on top of the annotation

Posted: Thu Mar 19, 2015 1:17 pm
by 17073287
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?

Re: ColorLine is drawn on top of the annotation

Posted: Thu Mar 19, 2015 3:12 pm
by yeray
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.