whitespace COMPANY whitespace SERVICES whitespace PRODUCTS whitespace PURCHASE whitespace SUPPORT whitespace CONTACTS whitespace Home whitespace Contact Us whitespace Site Map whitespace
whitespace
SUPPORT
whitespace
FORUM
whitespace
FAQS
whitespace
SUBSCRIPTION
whitespace
REQUEST ON-LINE
whitespace
whitespace

Technical Support Forum

Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
thedigitalsean  
#1 Posted : Thursday, August 4, 2011 12:35:48 AM(UTC)
thedigitalsean
Rank: Newbie

Groups: Registered
Joined: 11/2/2010(UTC)
Posts: 5

I have an application that allows for the user to insert a point into a line. For this, I use
Code:
mSeries.getPoints().addXY(x,y)

on my series. This works fine, but later on my application needs to go through the data in order along the X-axis to process it. The only way I know to do this is with a for loop through the indexes I get with
Code:
mSeries.getPoints().get(index)


Unfortunately, it looks like addXY() adds new points at the last index instead of inserting it and then updating the indexes. Is there a way to do this automatically, or is this something I will need to manually in my code?

Also, my application will allow for deleting points, do the indexes get updated in this case?

Thanks,
Sean
Baydalka Volodymyr  
#2 Posted : Thursday, August 4, 2011 2:39:13 PM(UTC)
Baydalka Volodymyr
Rank: Member

Groups: Registered
Joined: 7/28/2009(UTC)
Posts: 447
Man

Hi,

X value is not the index of point. There may be several points with the same X value. If you need to find point by X value, there is best-performance way -

Code:
int index = Collections.binarySearch(series.getPointsCache(), new Double(xValue), new Comparator()
{
	public int compare(Object arg0, Object arg1) 
	{
		double d1 = arg0 instanceof Double ? ((Double)arg0).doubleValue() : ((ChartPoint)arg0).getX(); 
		double d2 = arg1 instanceof Double ? ((Double)arg1).doubleValue() : ((ChartPoint)arg1).getX();

		return Double.compare(d1, d2);
	}			
});


Best regards,
Volodymyr Baydalka
Andriod development and support team
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Company | Services | Practices | Technologies | Career | Contacts | Privacy
© 2005-2017 ArtfulBits. All rights reserved.