MPAndroidChart in harozontal BarGraph X Axis values are not plotted correctly

In my Android Application i am trying to plot a horizontal BarGraph using MpAndroid Chart library but the values in X axis are not plotted correctly. E.g for plotting (6,15) cordinates on x Axis are displaying below 5.Please help to plot x Axis value properly . Here is my code ..

 

     mChart.setDrawBarShadow(false);

           mChart.setDrawValueAboveBar(true);

          mChart.getDescription().setEnabled(false);

          mChart.setMaxVisibleValueCount(60);

          mChart.setPinchZoom(true);

          mChart.setScaleEnabled(false);

          mChart.setDrawGridBackground(false);

           XAxis xl=mChart.getXAxis();

           xl.setPosition(XAxisPosition.BOTTOM);

 

        xl.setDrawAxisLine(false);

        //xl.setDrawGridLines(false);

        xl.setDrawGridLines(true);

        xl.setLabelCount(10,true);

        xl.setAxisMinValue(0f);

        xl.setAxisMaxValue(45f);

        xl.setGranularityEnabled(true);

        // xl.setGranularity(10f);

        xl.setCenterAxisLabels(false);

        xl.setGranularity(1f);

        YAxis yl=mChart.getAxisLeft();

        yl.setDrawAxisLine(true);

        // yl.setDrawGridLines(true);

        yl.setDrawGridLines(false);

        yl.setAxisMinimum(-50f); // this replaces setStartAtZero(true)

        //  yl.setInverted(true);

        yl.setLabelCount(6,true);

        yl.setAxisMinValue(-60f);

        yl.setAxisMaxValue(60f);

        yl.setGranularityEnabled(true);

        yl.setGranularity(10f);

        YAxis yr=mChart.getAxisRight();

        yr.setDrawAxisLine(false);

        yr.setDrawGridLines(false);

        yr.setAxisMinimum(-50f);

        yr.setLabelCount(10,true);

        yr.setAxisMinValue(-60f);

        yr.setAxisMaxValue(60f);

        yr.setGranularityEnabled(true);

        yr.setGranularity(10f);

        // yr.setInverted(true);

        setData();

        // mChart.setFitBars(true);

        YAxis rightYAxis=mChart.getAxisRight();

        rightYAxis.setEnabled(false); // to remove y axis at bottom

        Legend l=mChart.getLegend();

        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);

        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);

        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);

        l.setDrawInside(false);

        l.setFormSize(8f);

        l.setXEntrySpace(4f);

        l.setEnabled(false);

        }

 

 

 

private void setData(){

        float barWidth=3.5f;

        float spaceForBar=4f;

        ArrayList<BarEntry>yVals1=new ArrayList<BarEntry>();

        ArrayList<Integer>yValues=new ArrayList<>();

 

        yVals1.add(new BarEntry(0*spaceForBar,5));

        yVals1.add(new BarEntry(10f,15));

Android         mpandroidchart        
Your Answer: 

0 Answers
Edit Account
LOGIN INFORMATION
Change Settings
Email Notifications Notifications will be sent to abcd@gmail.com
Select option for your email notifications:
Mature / News Filter We'll send on email when new jobs are posted
Option 2 for email notification We'll send on email when new jobs are posted