title: Bar graph X axis labels disappeared after Shunting the viewport to show the full width of bars
body: <p>In my android code, I am creating a bar graph with x axis labeled with dates (String), and y axis being double values. Everything was fine, but when I had to Shunt the viewport to show the full width of the first and last bars, the dates disappeared on the X axis. Only 2 of them are visible, and 3 are not. How can I fix the problem?</p>
  
  <p>Below is my code:</p>
  
  <pre><code>//BAR Graph:
  //Only possible to make bar graph for 2 weeks or more
  GraphView barGraph = (GraphView) findViewById(R.id.bar_graph);
  
   if (MainActivity.weekLabelsArray.length &lt;= 1)
       barGraph.setVisibility(GraphView.GONE);
  
  else {
  
       ArrayList&lt;DataPoint&gt; barData = MainActivity.weeklyData;
       BarGraphSeries&lt;DataPoint&gt; barSeries = new BarGraphSeries&lt;&gt;();
  
       for (DataPoint d : barData)
           barSeries.appendData(d, true, 30);
       barGraph.addSeries(barSeries);
  
  
       // styling
       barSeries.setValueDependentColor(new ValueDependentColor&lt;DataPoint&gt;() {
           @Override
           public int get(DataPoint data) {
  
               double expense = data.getY();
               if (expense &gt; 500)
                   return Color.rgb(255, 0, 0);
               else if (expense &gt; 200)
                   return Color.rgb(0, 0, 255);
               else
                   return Color.rgb(0, 220, 0);
  
           }
       });
  
       barSeries.setSpacing(10);
  
  
       barSeries.setDrawValuesOnTop(true);
       barSeries.setValuesOnTopColor(Color.RED);
  
       //All this below just to make the x axis labeled with the dates
       barGraph.getViewport().setScrollable(true);
       barGraph.getViewport().setYAxisBoundsManual(true);
       barGraph.getViewport().setXAxisBoundsManual(true);
       StaticLabelsFormatter staticLabelsFormatterBar = new StaticLabelsFormatter(barGraph);
       staticLabelsFormatterBar.setHorizontalLabels(MainActivity.weekLabelsArray);
       barGraph.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatterBar);
  
       //adjusting labels and other stuff
       barGraph.getGridLabelRenderer().setHorizontalLabelsAngle(100);
       barGraph.getViewport().setMinY(0);
       barGraph.getGridLabelRenderer().setTextSize(40);
       barGraph.getGridLabelRenderer().reloadStyles();
       barGraph.setTitle("Total Weekly Expenses");
  
  
       //adjusting bars width
       double xInterval=1.0;
       barGraph.getViewport().setXAxisBoundsManual(true);
       barGraph.getViewport().setMinX(barSeries.getLowestValueX() - (xInterval/2.0));
       barGraph.getViewport().setMaxX(barSeries.getHighestValueX() + (xInterval/2.0));
       barGraph.getViewport().setYAxisBoundsManual(true);
       barGraph.getViewport().setMinY(barSeries.getLowestValueY() );
       barGraph.getViewport().setMaxY(barSeries.getHighestValueY()+50);
  
       barGraph.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.NONE );
       barGraph.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.HORIZONTAL);
  </code></pre>
  
  <p>The dates disappeared after adding the following exact lines of code:</p>
  
  <pre><code>         barGraph.getViewport().setXAxisBoundsManual(true);
           barGraph.getViewport().setMinX(barSeries.getLowestValueX() - (xInterval/2.0));
           barGraph.getViewport().setMaxX(barSeries.getHighestValueX() + (xInterval/2.0));
  </code></pre>
  
  <p>Here's how my graph looks like with missing date labels on the x Axis:</p>
  
  <p><a href="https://i.stack.imgur.com/Pse8J.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pse8J.jpg" alt="enter image description here"></a></p>