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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:25:18+00:00 2026-06-05T02:25:18+00:00

I want to draw a bar chart which contains five individual bars – I

  • 0

I want to draw a bar chart which contains five individual bars – I have used Achartengine.
I am able to display all five bars in the same color but I want to differentiate one bar with a different color, but I cant display more than one color. Please show me how to display different colors.
My code…

         values.add(new double[] {21,56,33,10,20});         
        int[] colors = new int[] { Color.rgb(227, 121, 15) };
        XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
        setChartSettings(renderer, "", "", "", 0,5, 0,100, Color.WHITE, Color.WHITE);
        renderer.setXLabels(8);
        renderer.setYLabels(10);
        renderer.setDisplayChartValues(true);
       mChartView= ChartFactory.getBarChartView(context, buildBarDataset(titles, values), renderer,
            Type.DEFAULT);
        layout.addView(mChartView, 350, 500);
  • 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-05T02:25:20+00:00Added an answer on June 5, 2026 at 2:25 am

    Can be achieved by extending the SimpleSeriesRenderer and BarChart classes. Here is my solution for RangeBarChart (all thanks to gilenodm, wish I had some reputation to upvote your answer):

    import org.achartengine.renderer.SimpleSeriesRenderer;
    public class AdvancedSeriesRenderer extends SimpleSeriesRenderer
    {
        private int []  colors;
    
        public void AdvancedSeriesRenderer ()
        {
        }
    
        public int getColor ( int position )
        {
            return colors[position];
        }
    }
    
    import org.achartengine.chart.RangeBarChart;
    import org.achartengine.model.XYMultipleSeriesDataset;
    import org.achartengine.renderer.SimpleSeriesRenderer;
    import org.achartengine.renderer.XYMultipleSeriesRenderer;
    import android.graphics.Canvas;
    import android.graphics.Paint;
    import android.graphics.Paint.Style;
    
    public class AdvancedRangeBarChart extends RangeBarChart
    {
        private int []  barChartColors;
    
        public AdvancedRangeBarChart ( XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type )
        {
            super ( dataset, renderer, type );
        }
    
        public void setColors ( int [] colorsIn )
        {
            barChartColors = colorsIn;
        }
    
        @Override
        public void drawSeries ( Canvas canvas, Paint paint, float [] points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex )
        {
            int seriesNr = mDataset.getSeriesCount ();
            int length = points.length;
            paint.setStyle ( Style.FILL );
            float halfDiffX = getHalfDiffX ( points, length, seriesNr );
            int start = 0;
            if ( startIndex > 0 )
            {
                start = 2;
            }
            for ( int i = start; i < length; i += 4 )
            {
                int colorIndex = (int) ( i / 4 ) % barChartColors.length;
                paint.setColor ( barChartColors[colorIndex] );
                if ( points.length > i + 3 )
                {
                    float xMin = points[i];
                    float yMin = points[i + 1];
                    // xMin = xMax
                    float xMax = points[i + 2];
                    float yMax = points[i + 3];
                    drawBar ( canvas, xMin, yMin, xMax, yMax, halfDiffX, seriesNr, seriesIndex, paint );
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to draw horizontal stacked bar chart which will have two section. Is
i want to display the results of students scores in a multi-vertical bar chart
HELLO ALL i want to draw bar chart for my app and i feel
I want to create a class library which is able to draw pie or
I have a custom view (android) which draws a custom progress bar. I want
I want to draw this in my view to draw this line, I have
Want to draw an UIImageView which has an CGImage, and the UIImageView has alpha
I want to draw UIButton in following shape : I have cut the image,
I am using zedgraph to draw bar chart in my vb.net project. The bar
I'm developing an animated column bar chart and i having some trouble. The bars

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.