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 Search | Active Topics | Log In | Register

plotting from left to right along x-axis Options · View
sathish
#1 Posted : Monday, June 28, 2010 5:13:55 AM
Rank: Member

Groups: Registered

Joined: 5/23/2010
Posts: 18
Hi,

I am plotting values continuously (Adding points to ChartPointCollection one at a time) along x-axis. But the values are coming from right to left. But I want to plot from left to right. How can we achieve this using ChartPointCollection or there any other methods available.


Regards,

Sathish
Baydalka Volodymyr
#2 Posted : Tuesday, June 29, 2010 12:31:14 PM
Rank: Developers Team


Groups: Registered, Administrators

Joined: 7/28/2009
Posts: 447
Hi,

Do you set the correct X value? Please, provide your code that you use to add points.

Best regards,
Volodymyr Baydalka
Andriod development and support team
sathish
#3 Posted : Wednesday, June 30, 2010 11:45:44 AM
Rank: Member

Groups: Registered

Joined: 5/23/2010
Posts: 18
Baydalka Volodymyr wrote:
Hi,

Do you set the correct X value? Please, provide your code that you use to add points.

Best regards,


Please find the code and other problem is if the data values are starting with zero chart is not drawing until nonzero values shown up




public class RealtimeChart extends Activity
{
private final static int ABOUT_ITEM_ID = 1;

// #region Nested types
class AddPointTask implements Runnable
{
// #region Members
private ChartPointCollection m_targetCollection;
private Random m_randomValuesGenerator;
private int m_pointsCounter;
private final int m_maxPoints = 50;
private final long m_dellay = 100;
// #endregion

// #region Constructor
public AddPointTask(ChartSeries series)
{
m_randomValuesGenerator = new Random();
m_targetCollection = series.getPoints();
}
// #endregion

// #region Public methods
public void run()
{
ChartPoint point = new ChartPoint(m_pointsCounter++,
m_randomValuesGenerator.nextInt(100));
m_targetCollection.add(point);

if(m_pointsCounter > m_maxPoints)
{
m_targetCollection.removeAt(0);
}

m_handler.postDelayed(this, m_dellay);
}
// #endregion
}
// #endregion

// #region Members
private Handler m_handler = new Handler();
// #endregion

// #region Public methods
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ChartView chartView = (ChartView)findViewById(R.id.chartView);

ChartSeries series = new ChartSeries("FastLineSeries",
ChartTypes.FastLine);

chartView.getSeries().add(series);
ChartArea area = new ChartArea();
area.getDefaultXAxis().getScale().setMargin(
ChartAxisScale.MARGIN_NONE);
chartView.getAreas().add(area);
// Because java's Timer class behaves incorrectly,
// using following workaround.
m_handler.postDelayed(new AddPointTask(series), 0);
}
}




Best Regards,

Sathish.
Baydalka Volodymyr
#4 Posted : Wednesday, June 30, 2010 1:43:46 PM
Rank: Developers Team


Groups: Registered, Administrators

Joined: 7/28/2009
Posts: 447
Hi,

Please, use next code to invert the X axis.

Code:
area.getDefaultXAxis().setInverted(true);


Best regards,
Volodymyr Baydalka
Andriod development and support team
sathish
#5 Posted : Wednesday, June 30, 2010 1:54:48 PM
Rank: Member

Groups: Registered

Joined: 5/23/2010
Posts: 18
Baydalka Volodymyr wrote:
Hi,

Please, use next code to invert the X axis.

Code:
area.getDefaultXAxis().setInverted(true);


Best regards,


Hi,

1) Thanks. Its solved the problem of drawing from right to left. But the graph is starting at middle of the chart. Is there any method to set it draw from leftmost of the x-axis.

2) Other problem is if the values in the collection are starting from zero then graph is not drawing until nonzero values comes to the collection.

Please Help me in this issues.

Best Regards,
Sathish
Baydalka Volodymyr
#6 Posted : Thursday, July 01, 2010 3:46:08 PM
Rank: Developers Team


Groups: Registered, Administrators

Joined: 7/28/2009
Posts: 447
Hi,

1) Try to change axis range manually (example : area.getDefaultXAxis().getScale().setRange(min,max))
2) Please, provide the expected behavior (screenshots, etc..)

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-2016 ArtfulBits. All rights reserved.