android axis labels change position (move up)

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
NIS
Newbie
Newbie
Posts: 6
Joined: Thu Jan 17, 2013 12:00 am

android axis labels change position (move up)

Post by NIS » Mon Mar 25, 2013 11:06 am

hello,

I need move some labels on bottom axis above the axis line and some labels should stay below. But i didnt found solution, please help.

Or is there some handler for drawing series? because in monotouch-teechart-lib. i found handler but not in java lib.

Same problem with series Marks, i want set different arrow length for each mark in series :? .

Thanks.

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

Re: android axis labels change position (move up)

Post by Yeray » Tue Mar 26, 2013 4:09 pm

Hi,
NIS wrote:I need move some labels on bottom axis above the axis line and some labels should stay below. But i didnt found solution, please help.

Or is there some handler for drawing series? because in monotouch-teechart-lib. i found handler but not in java lib.
What event did you use in TeeChart MonoTouch (now TeeChart .NET for Xamarin.iOS)?
NIS wrote:Same problem with series Marks, i want set different arrow length for each mark in series :? .
Have you tried doing something similar to this?
http://www.teechart.net/support/viewtop ... 69&p=42391
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

NIS
Newbie
Newbie
Posts: 6
Joined: Thu Jan 17, 2013 12:00 am

Re: android axis labels change position (move up)

Post by NIS » Wed Mar 27, 2013 8:46 am

monotouch solution:

chart.Axes.Bottom.GetAxisDrawLabel += new Steema.TeeChart.GetAxisDrawLabelEventHandler(Bottom_GetAxisDrawLabel);

int count = 0;

void Bottom_GetAxisDrawLabel (object sender, Steema.TeeChart.GetAxisDrawLabelEventArgs e)
{
if ( values [count] > 0.0) {
e.Y = (int)(chart4.Axes.Left.CalcYPosValue(0.0)-8);
}else if ( values [count] < 0.0 || values [count] == 0.0) {
e.Y = (int)(chart4.Axes.Left.CalcYPosValue(0.0)-21);
}
count++;
if(count == values.Count) count = 0;
}

NIS
Newbie
Newbie
Posts: 6
Joined: Thu Jan 17, 2013 12:00 am

Re: android axis labels change position (move up)

Post by NIS » Wed Mar 27, 2013 12:06 pm

So,

thanks for your help, you solved my problem with marks.

And there is reason why i need move Label over the axis line.
:|

Image

NIS
Newbie
Newbie
Posts: 6
Joined: Thu Jan 17, 2013 12:00 am

Re: android axis labels change position (move up)

Post by NIS » Wed Mar 27, 2013 12:26 pm

(picture is in post over)
and i noticed that one more small problem is with ticks:

chart.getAxes().getBottom().getTicks().setLength(0);
chart.getAxes().getBottom().getTicks().setColor(Color.white);
chart.getAxes().getBottom().getTicks().setUsesVisible(false);
chart.getAxes().getBottom().getTicks().setVisible(false);

chart.getAxes().getBottom().getTicksInner().setLength(0);
chart.getAxes().getBottom().getTicksInner().setColor(Color.white);
chart.getAxes().getBottom().getTicksInner().setUsesVisible(false);
chart.getAxes().getBottom().getTicksInner().setVisible(false);

-> nothink works
(
but maybe problem can be that i have added into custom labels:
chart.getAxes().getBottom().getCustomLabels().add( 0.0, "12/12" );
)

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

Re: android axis labels change position (move up)

Post by Yeray » Wed Mar 27, 2013 2:30 pm

Hi,

The only way I can think to work around this is to hide those labels that correspond to negative values with the AxisLabelResolver. And you could use the same event to manually draw the labels where you want.
Something like this:

Code: Select all

		tChart1.setAxisLabelResolver(new AxisLabelAdapter() {
			
			@Override
			public String getLabel(Axis axis, ISeries s, int valueIndex, String labelText) {
				if (axis == tChart1.getAxes().getBottom()) {
					if (valueIndex == -1) {
						for (valueIndex=0; valueIndex<tChart1.getSeries(0).getCount(); valueIndex++) {
							if (tChart1.getSeries(0).getXValues().getValue(valueIndex) == Double.parseDouble(labelText)) {
								if (tChart1.getSeries(0).getYValues().getValue(valueIndex) < 0) {
									int x = axis.calcPosValue(tChart1.getSeries(0).getXValues().getValue(valueIndex)) - (tChart1.getGraphics3D().textWidth(labelText) / 2);
									int y = tChart1.getChart().getChartRect().getBottom() - 15;
									tChart1.getGraphics3D().textOut(x, y, labelText);
									return "";
								}
							}
						}
					}
				}
				
				return labelText;
			}
		});
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