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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:39:52+00:00 2026-06-12T22:39:52+00:00

i am drawing a bar chart and pie chart to represent the various application

  • 0

i am drawing a bar chart and pie chart to represent the various application names in it using the achartengine library.

When i instantiate CategorySeries object it requires a series title as :

CategorySeries series = new CategorySeries("title") //IN BAR CHART 
CategorySeries series = new CategorySeries("title") //IN PIE CHART 

Unlike Pie chart the applications name does not get inflated at the bottom of the bar chart
say, in case of pie chart its as follows :

(1) application 1

(2) application 2

(3) application … up to

(10) application 10.

But its not showing in case of bar char but instead its showing as :

(1) NUMBER OF APPLICATIONS —->>> (This is the series title i had
passed in as the parameter while
instantiating the object of CategorySeries)


PLEASE SUGGEST ME TO SHOW THE KEY OF BAR CHART ASWELL,I HAVE ATTACHED A CODE SNIPPET BELOW


if (c.getCount() > 0) {
                if (! mPieChart) {
                    series = new CategorySeries("NUMBER OF APPLICATIONS");
                    getActivity().startManagingCursor(c);
                    c.moveToPosition(-1);
                     //series.clear();
                    while (c.moveToNext()) {

                        recievedBytes = c.getLong(ApplicationDataCounterDao.CONTENT_RECEIVED_COLUMN);
                        sentBytes = c.getLong(ApplicationDataCounterDao.CONTENT_SENT_COLUMN);
                        totalBytes = (recievedBytes + sentBytes) / (1024 * 1024);
                        if (totalBytes > 0) {
                            applicationInfo
                                    .add(new ApplicationDataUsage(
                                            c.getString(ApplicationDataCounterDao.CONTENT_APPLICATION_NAME_COLUMN),
                                            Double.toString(totalBytes)));
                        }
                    }

                    int size = applicationInfo.size();
                    for (int i = 0; i < size; ++i) {
                        Log.v("BAR CHART", "data added are " + applicationInfo.get(i).mApplicationName);
                        double value = Double.parseDouble(applicationInfo
                                .get(i).mDataUsage);
                        series.add("BAR", value);

                    }

                    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();

                    dataset.addSeries(series.toXYSeries());
                    XYSeriesRenderer renderer = new XYSeriesRenderer();
                    renderer.setDisplayChartValues(true);
                    renderer.setChartValuesSpacing((float) 0.5);
                    renderer.setColor(Color.CYAN);

                    XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
                    mRenderer.setBarSpacing(0.5);
                    mRenderer.getBarSpacing();
                    mRenderer.setXTitle("Application Number");
                    mRenderer.setYTitle("Data Usage");
                    mRenderer.setAxesColor(Color.GREEN);
                    mRenderer.setZoomButtonsVisible(true);
                    mRenderer.setInScroll(true);
                    mRenderer.setLabelsColor(Color.RED);
                    mRenderer.addSeriesRenderer(renderer);

                    if (mChartViewBar == null) {
                        Log.v(LOG_TAG, "chart view is null");
                        mChartViewBar = ChartFactory
                                .getBarChartView(getActivity(), dataset,
                                        mRenderer, Type.DEFAULT);
                        mRenderer.setClickEnabled(true);
                        mRenderer.setSelectableBuffer(10);
                        mChartViewBar
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        SeriesSelection seriesSelection = mChartViewBar
                                                .getCurrentSeriesAndPoint();
                                        CategorySeries series22 =new CategorySeries("333");
                                        mChartViewBar.repaint();
                                        if (seriesSelection == null) {
                                            Toast.makeText(
                                                    getActivity(),
                                                    "No chart element was clicked",
                                                    Toast.LENGTH_SHORT).show();
                                        } else {
                                            Toast.makeText(
                                                    getActivity(),
                                                    "APPLICATION NAME : "
                                                            + series22.getTitle()
                                                            + 1
                                                            + " was clicked"
                                                            + " DATA USAGE : "
                                                            + seriesSelection
                                                                    .getXValue(),
                                                    Toast.LENGTH_SHORT).show();
                                        }
                                    }
                                });
                        mChartLayout.removeAllViews();
                        mChartLayout.addView(mChartViewBar, new LayoutParams(
                                LayoutParams.FILL_PARENT,
                                LayoutParams.FILL_PARENT));
                    } else {
                        mChartLayout.removeAllViews();
                        mChartLayout.addView(mChartViewBar, new LayoutParams(
                                LayoutParams.FILL_PARENT,
                                LayoutParams.FILL_PARENT));
                        mChartViewBar.repaint();
                    }
                } else if (mPieChart) {
                    CategorySeries seriesPie = new CategorySeries("Pie Graph");
                    getActivity().startManagingCursor(c);
                    c.moveToPosition(-1);
                    while (c.moveToNext()) {
                        long recievedBytes = c .getLong(ApplicationDataCounterDao.CONTENT_RECEIVED_COLUMN);
                        Long sentBytes = c.getLong(ApplicationDataCounterDao.CONTENT_SENT_COLUMN);
                        totalBytes = (recievedBytes + sentBytes)
                                / (1024 * 1024);
                        if (totalBytes > 0) {
                                applicationInfo
                                        .add(new ApplicationDataUsage(
                                                c.getString(ApplicationDataCounterDao.CONTENT_APPLICATION_NAME_COLUMN),
                                                Double.toString(totalBytes)));
                        }
                    }
                    int size = applicationInfo.size();
                    for (ApplicationDataUsage data_value : applicationInfo) {
                        Log.v("PIE CHART", "data added are " + data_value.mApplicationName);
                        double dataUsage = Double
                                .parseDouble(data_value.mDataUsage);
                        seriesPie.add(data_value.mApplicationName, dataUsage);
                    }

                    for (int i = 0; i < size; ++i) {
                        prepareColors();
                    }
                    DefaultRenderer renderer = new DefaultRenderer();
                    for (int fillColor : colorList) {
                        // Log.d("1111111111",
                        // "FILL COLOUR TILL SIZE OF COLORLIST");
                        SimpleSeriesRenderer r = new SimpleSeriesRenderer();
                        r.setColor(fillColor);
                        renderer.addSeriesRenderer(r);
                    }
                    renderer.setInScroll(true);
                    renderer.setChartTitle("APPLICATION WISE PIE CHART");
                    renderer.setChartTitleTextSize(20);
                    renderer.setApplyBackgroundColor(true);
                    renderer.setBackgroundColor(Color.BLACK);
                    renderer.setZoomButtonsVisible(true);

                    if (mChartViewPie == null) {
                        Log.v(LOG_TAG, "chat view is null");
                        // series.clear();
                        mChartViewPie = ChartFactory.getPieChartView(
                                getActivity(), seriesPie, renderer);
                        renderer.setClickEnabled(true);
                        renderer.setSelectableBuffer(10);
                        mChartViewPie
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        SeriesSelection seriesSelection = mChartViewPie
                                                .getCurrentSeriesAndPoint();
                                        mChartViewPie.repaint();
                                        if (seriesSelection == null) {
                                            ToastHelper.showToastMessage(
                                                    "No item was Clicked",
                                                    getActivity());
                                        } else {
                                            ToastHelper.showToastMessage(
                                                    "Application number "
                                                            + seriesSelection
                                                                    .getPointIndex()
                                                            + " was clicked and it's Data Usage is "
                                                            + seriesSelection
                                                                    .getValue(),
                                                    getActivity());
                                        }
                                    }
                                });
                        /*if (mChartViewBar != null) {
                            mChartLayout.removeView(mChartViewBar);
                        }
                        if (mChartViewPie != null) {
                            mChartLayout.removeView(mChartViewPie);
                        }*/
                        mChartLayout.addView(mChartViewPie, new LayoutParams(
                                LayoutParams.FILL_PARENT,
                                LayoutParams.FILL_PARENT));
                    } else {
                    /*  if (mChartViewBar != null) {
                            mChartLayout.removeView(mChartViewBar);
                        }
                        if (mChartViewPie != null) {
                            mChartLayout.removeView(mChartViewPie);
                        }*/
                        mChartLayout.removeAllViews();
                        mChartLayout.addView(mChartViewPie, new LayoutParams(
                                LayoutParams.FILL_PARENT,
                                LayoutParams.FILL_PARENT));
                        mChartViewPie.repaint();
                    }
                }
  • 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-12T22:39:57+00:00Added an answer on June 12, 2026 at 10:39 pm

    You are confusing the legend with the X axis labels. The BarChart is an XYChart which means it is getting both legend and x axis labels. The PieChart is not an XYChart, so it is not getting X axis and Y axis.

    The series titles go to the legend, as you mentioned.

    In the X axis the series values indexes go by default. However, you can hide the default labels and add your own custom ones:

    renderer.setXLabels(0);
    renderer.addXTextLabel(1, "label);
    renderer.addXTextLabel(2, "label);
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an application for various kinds of plot/chart drawing in Mathematica. Ultimately
We are developing an drawing application for iOS and android. I am using cubic
Part of a web application I'm developing requires me to create bar graphs to
I am drawing a bar chart like this jsfiddle code Now the data is
Problem I am drawing a bar chart with Core Plot . My implementation of
I am using reportlab to generate simple bar chart. the following is my code.
I'm drawing a BarChart with AChartEngine on Android. I made the chart horizontal by
Drawing very simple tables with little rectangles as icons for a simple bar chart:
I am using core-plot for drawing bar graphs. I have displayed date on x-axis.
Using Google maps API V3, specifically using the drawing tools (only the rectangle is

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.