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

How to use custom axis label format? Options · View
p.t.
#1 Posted : Tuesday, May 31, 2011 10:17:05 AM
Rank: Newbie

Groups: Registered

Joined: 5/26/2011
Posts: 8
Location: USA
Hi,

I'm trying to plot 3 data series, each contains 90 data points. I want to use custom label format on the X axis, and the X values start from 300 through 389. But there are two problems:

1. The X axis has way too many grid liines(see below). How can I control the spacing of grids?



2. I'm using ChartAxis.setFormat() to set up a custom format for labels. I want the X-asix value to start from 300, but in Format.format() method, the values I receive always start from 0. I used ChartAxis().setOrigin(300), but that doesn't help. What method should I use?

Following is how I did this:

Code:

ChartSeries series = new ChartSeries(name, ChartTypes.get("Line"));
seriesCollection.add(series);
// set up an array of 90 double values
series.getPoints().setData(newValues);
// I want X values to start from 300, but it doesn't work.
series.getXAxis().setOrigin(300); 
ChartAxis axis = chart.getAreas().get(0).getDefaultXAxis();
axis.getScale().setInterval(1d, IntervalType.Double);
// custom format
axis.setFormat(new MyDateFormat()); 

class MyDateFormat extends Format {
    public StringBuffer format(Object x, StringBuffer toAppendTo,
            FieldPosition pos) {
    // I want the value to start from 300, but it always
    // starts from 0. Why?
    Log.d("tag", "Value = {0}", d.doubleValue());
    return sb;
}



Thank you!
Baydalka Volodymyr
#2 Posted : Tuesday, May 31, 2011 11:40:58 AM
Rank: Developers Team


Groups: Registered, Administrators

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

1) Please, use method getPoint.addXY to setup points with custom X value. Example :
Code:

for(int i = 0; i < newValues.length; i ++)
  series.getPoints().addXY(300 + i, newValues[i]);


2) You set too small interval for labels - axis.getScale().setInterval(1d, IntervalType.Double);
3) ChartAxis.setOrigin method specifies the bottom value of area and column types. To change the axis range, please, use ChartAxis.getScale().setMinimum/setMaximum

Best regards,
Volodymyr Baydalka
Andriod development and support team
p.t.
#3 Posted : Wednesday, June 01, 2011 10:01:35 PM
Rank: Newbie

Groups: Registered

Joined: 5/26/2011
Posts: 8
Location: USA
That worked beautifully. Thanks!
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.