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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:52:44+00:00 2026-05-27T22:52:44+00:00

I’m using AChartEngine to display averages across several days (2 months if possible). I’d

  • 0

I’m using AChartEngine to display averages across several days (2 months if possible). I’d like to provide a comparison between one individual and a group. At this point, I’m working on how to provide dates across the x-axis (ie, 12/15/2011 or Dec. 11, 2011 or even 12/15, Dec. 15).

I’m not sure how to do this in AchartEngine; the documentation is a little hard for me to follow without pictures (sorry). I’d like something like this: Using AChartEngine library for graphs, not able to get value for diffrent x-axis value

Here’s my code:

private void setupHistoryChart() {    
        XYMultipleSeriesRenderer renderer = getBarDemoRenderer();
        setChartSettings(renderer);
        Intent intent = ChartFactory.getBarChartIntent(this, getBarDemoDataset(), renderer, Type.DEFAULT);
        startActivity(intent);
    }

     public XYMultipleSeriesRenderer getBarDemoRenderer() {
         XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
         renderer.setAxisTitleTextSize(15);
         renderer.setChartTitleTextSize(18);
         renderer.setLabelsTextSize(12);
         renderer.setLegendTextSize(15);
         renderer.setMargins(new int[] {20, 30, 15, 0});
         SimpleSeriesRenderer r = new SimpleSeriesRenderer();
         r.setColor(Color.BLUE);
         renderer.addSeriesRenderer(r);

         return renderer;
       }

     private void setChartSettings(XYMultipleSeriesRenderer renderer) {   
         renderer.setChartTitle("History");
         renderer.setChartTitleTextSize((float) 14.0);
         renderer.setXTitle("Day");
         renderer.setXLabelsAlign(Align.LEFT);
         renderer.setYLabelsAlign(Align.LEFT);
         renderer.setBarSpacing(0.5);
         renderer.setZoomEnabled(true);
         renderer.setZoomRate(0.2f);
         renderer.setYTitle("Unit)");
         renderer.setXAxisMin(1.0);

         if(AppStatus.mDayMap.size() == 0){
             renderer.setXAxisMax(3.0);
             renderer.setYAxisMax(10.0);
         }else{
             renderer.setXAxisMax(AppStatus.mDayMap.size());
             // Get the max Integer out of myMap
             Map.Entry<String, Integer> maxEntry = null;

             for (Map.Entry<String, Integer> entry : AppStatus.mDayMap.entrySet())
             {
                 if (maxEntry == null || entry.getValue().compareTo(maxEntry.getValue()) > 0)
                 {
                     maxEntry = entry;
                 }
             }
             renderer.setYAxisMax(maxEntry.getValue()/1000 + maxEntry.getValue()/1000);
         }
         renderer.setYAxisMin(0);
       }

     private XYMultipleSeriesDataset getBarDemoDataset() {
         XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
         HashMap<String, Integer> myMap = AppStatus.mDayMap;
         CategorySeries series = new CategorySeries ("Your History " + 1);
         try{

             if(AppStatus.mDayMap.size() == 0){
                 series.add(3.0);
                 series.add(10.0);
                 dataset.addSeries(series.toXYSeries());
             }else{
                 Log.v(LOG_TAG, "Size of Map = " + myMap.size());
                 float sum = (float) 0.0;
                 if(myMap.size() > 0){
                     Iterator it = myMap.entrySet().iterator();
                     float j= (float)0.0;
                     for (int i = 0; i < 1 /*2*/; i++) {
                       //CategorySeries series = new CategorySeries("Your History " + (i + 1));
                       while(it.hasNext()){
                           Map.Entry pairs = (Map.Entry)it.next();
                           sum = sum + (float) (1.0 + j);
                           series.add((((Integer) pairs.getValue()).doubleValue())/1000); 
                       }
                       dataset.addSeries(series.toXYSeries());
                     }
                 }
             }

         }catch(IllegalArgumentException e){
             Log.e(LOG_TAG, "IllegalArgumentException " + e.toString());
             series.add(3.0);
             series.add(10.0);
             dataset.addSeries(series.toXYSeries());
         }

         return dataset;
       }

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-05-27T22:52:44+00:00Added an answer on May 27, 2026 at 10:52 pm

    You can set custom text for the X axis labels:

    renderer.addXTextLabel(x, text);
    renderer.setXLabels(0);
    

    In order to have multiple color bars in the bar chart, you will have to add multiple series.

    There are some instructions here on how to download and run the demo application which includes a lot of good code to demonstrate the AChartEngine usage.

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

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace

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.