title: Scroll bar set on Bar chart in android using achartengine
body: <p>In my project i have to display the bar chart for 30 days with daily net amount. While view of bar chart activity the X-axis labels were collapsed and <strong>all are</strong> *<em>shown</em>* without any spacing. While i clicked the zoom buttons that time the views are expanded and we can see the bar with their corresponding x-axis labels. I need to show the bar chart on expanded view on the time of activity started.</p>
  
  <h2>Coding for display the Bar Chart:</h2>
  
  <pre><code>     XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
          renderer.setAxisTitleTextSize(16);
          renderer.setChartTitleTextSize(20);
          renderer.setLabelsTextSize(15);
          renderer. setLegendTextSize(15);
  //     renderer.setInScroll(true);
          //renderer.setMargins(new int[]{10,10,10,0});
          int length = colors.length;
          for (int j = 0; j &lt; length; j++) {
            SimpleSeriesRenderer r = new SimpleSeriesRenderer();
            r.setColor(colors[j]);
            renderer.addSeriesRenderer(r);
          }
          if(flag==1)
       renderer.setChartTitle("Monthly Basis");
          if(flag==0)
               renderer.setChartTitle("Weekly Basis");
          if(flag==2)
               renderer.setChartTitle("Yearly Basis");
      renderer.setXTitle("Date");
      renderer.setYTitle("NetAmount");
  
      renderer.setXAxisMin(0);
  
      //renderer
      renderer.setYAxisMin(100);
     // renderer.setYAxisMax(35000);
      renderer.setAxesColor(Color.GRAY);
      renderer.setLabelsColor(Color.LTGRAY);
            renderer.setXLabels(0);
            //renderer.setYLabels(31);
              renderer.setDisplayChartValues(true);
              renderer.setXLabelsAlign(Align.LEFT);
              renderer.setYLabelsAlign(Align.RIGHT);
            if(flag==0 || flag==1)
            {
               for(int axis=1;axis&lt;=31;axis++)
              {
                  String d;
                  d=String.valueOf(axis);
                  renderer.addTextLabel(axis,d);
  
              }
            }
            else
            {
                renderer.setXAxisMin(2005);
                for(int axis=2005;axis&lt;=2011;axis++)
                  {
                      String d;
                      d=String.valueOf(axis);
                      renderer.addTextLabel(axis,d);
  
                  }
  
               // renderer.setXLabels(4);
            }
               //renderer.setPanEnabled(false,false);
               //renderer.setZoomEnabled(false,false);
             // renderer.setPanLimits(new double[] { 0, 32, -10, 40 });
            // renderer.setZoomLimits(new double[] { 0, 32, -10, 40 });
              renderer.setZoomRate(3.0f);
              renderer.setBarSpacing(0.25);
              //renderer.set(new  double[] {0,30,100,35000});
              //Intent in;
  
              List&lt;double[]&gt; xvalues = new ArrayList&lt;double[]&gt;();
  
              int count=1,j=0;
             if(flag==0 || flag==1)
             {
              double xdata[]=new double[31];
              while(count&lt;32)
              {
  
              xdata[j]=count;
              count++;
              j++;
  
              }
              xvalues.add(xdata);
             }
             if(flag==2)
             {
              double xdata[]=new double[7];
              count=2005;
              while(j&lt;7)
              {
  
              xdata[j]=count;
              count++;
              j++;
  
              }
              xvalues.add(xdata);
             }
  
  
            //  return ChartFactory.getBarChartIntent(context, buildBarDataset(titles,xvalues,values), renderer,
              //    Type.DEFAULT);
              mchart=ChartFactory.getBarChartView(context,buildBarDataset(titles,xvalues,values), renderer, Type.STACKED);
              //LinearLayout layout = (LinearLayout) findViewById(R.id.chart1);
              layout.addView(mchart);
              mchart.repaint();
  
              //startActivity(in);
  
    }
  
  
       protected XYMultipleSeriesDataset buildBarDataset(String[] titles, List&lt;double[]&gt; xvalues, List&lt;double[]&gt; values) {
      XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
       int length = titles.length;
       for (int i = 0; i &lt; length; i++) {
      //CategorySeries series = new CategorySeries(titles[i]);
  XYSeries series = new XYSeries(titles[i]);
  double[] v = values.get(i);
  double[]x=xvalues.get(i);
  
  int seriesLength = v.length;
      for (int k = 0; k &lt; seriesLength; k++) {
  if(v[k]==0)
  {
  v[k]=MathHelper.NULL_VALUE;
  }
  else
  {
       series.add(x[k],v[k]);
  }
        //Log.i("Invent","X Axis"+x[k]);
  //series.add(xdata[k],v[k]);
       }
       dataset.addSeries(series);
      for (int k = 0; k &lt; seriesLength; k++) {
  if(v[k]==MathHelper.NULL_VALUE)
  {
  v[k]=0;
  }
       }
      }
     return dataset;
         }
  
  
  }
  </code></pre>