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 9284707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:58:15+00:00 2026-06-18T18:58:15+00:00

I have this issue with the xlabels in aChartEngine when there is one value

  • 0

I have this issue with the xlabels in aChartEngine when there is one value in an ArrayList. I generate my own XLabels for a line chart, but when there is one data array value, i get an unwanted TimeStamp on top of my generated XLabels.

my Code:

private XYMultipleSeriesDataset getDemoDataset() {

        Calendar cal = Calendar.getInstance();
        Date date = new Date();

        date_value = new String[list.size()];
        value_value = new String[list.size()];

        for(int k = 0; k < list.size(); k++){
            date_value[k] = list.get(k).get(DATE);
            value_value[k] = list.get(k).get(VALUE);
        }


        TimeSeries series = new TimeSeries("Line Graph");

        for(int j=0; j < date_value.length; j++) {


                series.add(formatter.stringToDate(date_value[j]), Integer.parseInt());

                }   

            XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
                 dataset.addSeries(series);
         return dataset;
         }

setChartSetting:

private void setChartSetting(XYMultipleSeriesRenderer renderer){
        renderer.setXRoundedLabels(true);
        renderer.setXTitle("DATES");
        renderer.setYTitle(kpiname);
        renderer.setApplyBackgroundColor(true);
        renderer.setFitLegend(false);
        renderer.setAxesColor(Color.DKGRAY);
        renderer.setShowGrid(true);
        renderer.setZoomEnabled(false);
        renderer.setXLabels(0);
        renderer.setYLabels(10);
        renderer.setZoomEnabled(false, false);
        renderer.setPanEnabled(false, false);





        //String[] date_value = new String[list.size()];
        //String[] value_value = new String[list.size()];

        if(list.isEmpty() || list.size() == 0 || list == null ){
            return;
        } 

        if(name.equals(RECOVERED) || name.equals(CONVERSION)){
            largest_size = (int)Double.parseDouble(value_value[0]);
        }else{
               if(!(value_value.length == 0)){
               largest_size = Integer.parseInt(value_value[0]);
              }else{
                  return;
              }
        }

        //used to determine the maximum value for the y-axis
        for(int x =0; x < value_value.length; x++){

                if(Integer.parseInt(value_value[x]) > largest_size){
                    largest_size = Integer.parseInt(value_value[x]);
                }   
            }

        renderer.setYAxisMax((double)largest_size);
        renderer.setYAxisMin(0);

        int value_size = value_value.length;
        int m = 0;
        //int add =  value_size/10;
        int add =  largest_size/10;

        /*instance variables for setting the labels on the X-Axis based on weather the values in the array are
         * more than 10 items or less*/


        double d;
        Long l;
        Long l1;
        double d1;

        if(date_value.length <= 1){

          int last = date_value.length;
          int mod = 0;
              //int add_mod = Math.round(last/10);
              int add_mod = (int)Math.round((double)Math.round(last));

                l = Long.valueOf(formatter.stringToDateReport(date_value[0]).getTime());
                d = l.doubleValue();
                   /*tried this to see if i can remove the timestamp*/
                //renderer.addXTextLabel(0.0, "");
                //renderer.removeXTextLabel(0.0); 
                //renderer.clearXTextLabels();
                renderer.addXTextLabel(d, date_value[0]);

        }


            else if(date_value.length < 10){    


            for(int i = 0; i < date_value.length; i++){

                  if(i >= date_value.length){
                      break;
                  }

            l = Long.valueOf(formatter.stringToDateReport(date_value[i]).getTime());
            d = l.doubleValue();
            renderer.addXTextLabel(d, date_value[i]);

           }

        } else if(date_value.length >= 10){

              int last = date_value.length;
              //int last = 28;
              //Log.d(TAG, "last is " + last);      
              int mod = 0;
              //int add_mod = Math.round(last/10);
              int add_mod = (int)Math.round((double)Math.round(last) /10);  // do this to get the decimal value with a double and then round to get nearset whole with int

              for(int i =0; i < date_value.length; i++){

                  if(mod >= date_value.length){
                      break;
                  }


                  l1 = Long.valueOf(formatter.stringToDateReport(date_value[mod]).getTime());
                  d1 = l1.doubleValue();

                  renderer.addXTextLabel(d1, date_value[mod]); 
                  mod+=add_mod;
              }
        }

    } 
}

and then:

chartView = ChartFactory.getLineChartView(context, getDemoDataset(), setChartSettings(renderer));

When there are multiple values, it plots the graph well with my custom XLabels(format is MMM-yyyy), but when there is only one value in the ArrayList, it generates thats time stamp.

here is an image:

enter image description here

  • 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-06-18T18:58:16+00:00Added an answer on June 18, 2026 at 6:58 pm

    This was a bug, indeed. You can download a version including a fix for it feature here.

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

Sidebar

Related Questions

i have this issue working but i would like to know if there is
I already have this issue but I cannot remember how to solved it. (I
I have this common issue of 'new line' in php-csv which is making me
I have this issue with Core Data. I am creating a core-data-based application, for
I have this issue i am writing a array to a file but when
I have this issue, but I don't know how to solve this: I have
I have this issue with the KendoUI Column Chart. I have a set of
I have this issue. I have a database of images in Core Data. I
I have an issue with graphing data within wxPython - this code below works
I have been reading lots of posts about this issue but I couldnt reach

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.