Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7248409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:08:04+00:00 2026-05-28T22:08:04+00:00

I use actually the AndroidPlot library to use a simple chart in my android

  • 0

I use actually the AndroidPlot library to use a simple chart in my android project but I don’t know how i can change the values of domain zone.

More specific, this line:

mySimpleXYPlot.setDomainValueFormat(new DecimalFormat("#"));

In the web site said that i can use another formats and its true, but if I use for example:

SimpleDateFormat("dd-MM-yyyy")

In the chart appears “31-12-1969” in all domain values.

Somebody know how I can change that date? or use another format (like String)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:08:04+00:00Added an answer on May 28, 2026 at 10:08 pm

    Late answer, but maybe will be useful to other people.

    I also had a hard time with this issue, especially since I am Java beginner.
    I implemented a custom formatter. Seems a bit ugly solution but it works. Idea is the following:

    • take only Y axis for values, and leave X axis as indexes into an array (as Androidplot tutorial suggests, use using ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value)
    • each time your data changes, you need to pass to the Plot a new formatter with your new data for X axis

    Here are some code snippets.

    First is the class which transforms array index to a custom label String:

    public class MyIndexFormat extends Format {
    
        public String[] Labels = null;
    
            @Override
            public StringBuffer format(Object obj, 
                    StringBuffer toAppendTo, 
                    FieldPosition pos) {
    
                // try turning value to index because it comes from indexes
                // but if is too far from index, ignore it - it is a tick between indexes
                float fl = ((Number)obj).floatValue();
                int index = Math.round(fl);
                if(Labels == null || Labels.length <= index ||
                        Math.abs(fl - index) > 0.1)
                    return new StringBuffer("");    
    
                return new StringBuffer(Labels[index]); 
            }
    

    And here is how I attach it to the Plot:

    MyIndexFormat mif = new MyIndexFormat ();
    mif.Labels = // TODO: fill the array with your custom labels
    
    // attach index->string formatter to the plot instance
    pricesPlot.getGraphWidget().setDomainValueFormat(mif); 
    

    This trick works also for dynamic updates.

    NOTICE: Androidplot seems to have problems with drawing horizontal lines, so if your data has the same Y values, you might get strange results, I already asked for help on this issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to actually use this wrapper, but the problem is i don't
I actually use a combination of OS X, Linux and Windows, but Windows is
Can someone give an example of a good time to actually use unsafe and
I'm trying to add simple login page to ASP.NET MVC app. I actually use
2 Questions actually: I know i must use Stored Procedures as much as Possible,
My project actually use XML files to define flow of the application. I like
I'm intending to use the Ms-RL for a project on CodePlex, but I'm not
Is there any way that I can actually use the cookies from a cookie
I use the boost lexical_cast library for parsing text data into numeric values quite
Does anyone know how you can use Django's templatetags in view? I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.