How to show only left Y axis and down x axis in bar chart ie how to remove the the grid lines with right y axis and top x axis.
Want to see like this : Whats the code ?
Look at axis styling. Especially at setDrawGridLines and setPosition.
Can any one send me the sample code for this
There is a example at the bottom of the page.
To disable the right yAxis
YAxis rightYAxis = barChart.getAxisRight();
rightYAxis.setEnabled(false);
You may want to use similar example for xAxis.
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle b) {
view = inflater.inflate(R.layout.bar_chart_fragment, container, false);
final BarChart chart = (BarChart) view.findViewById(R.id.bar_chart);
BarData data = new BarData(getXAxisValues(), getDataSet());
chart.setData(data);
chart.setDrawValueAboveBar(false);
chart.getXAxis().setTextSize(15f);
chart.setDescription("Percent(%)");
//chart.getLegend().setEnabled(false);
// Hide the desc value of each bar on top
chart.getXAxis().setEnabled(false);
YAxis rightYAxis = chart.getAxisRight();
rightYAxis.setEnabled(false);
chart.animateXY(2000, 2000);
chart.invalidate();
@Override
public void onNothingSelected() {
}
});
return view;
}
private ArrayList<BarDataSet> getDataSet() {
ArrayList<BarDataSet> dataSets = null;
ArrayList<BarEntry> valueSet1 = new ArrayList<>();
BarEntry v1e1 = new BarEntry(96.000f, 0); // Jan
valueSet1.add(v1e1);
BarEntry v1e2 = new BarEntry(82.000f, 1); // Feb
valueSet1.add(v1e2);
BarEntry v1e3 = new BarEntry(88.000f, 2); // Mar
valueSet1.add(v1e3);
BarEntry v1e4 = new BarEntry(52.000f, 3); // Apr
valueSet1.add(v1e4);
BarDataSet barDataSet1 = new BarDataSet(valueSet1, "Availability of Drugs/Supplies");
//Chnaging the color
barDataSet1.setColor(Color.rgb(0, 169, 157));
barDataSet1.setBarSpacePercent(30f);
// Hide the value on each bar
/*barDataSet1.setDrawValues(false);*/
dataSets = new ArrayList<>();
dataSets.add(barDataSet1);
return dataSets;
}
private ArrayList<String> getXAxisValues() {
ArrayList<String> yAxis = new ArrayList<>();
yAxis.add("Well behaved staff (Total)");
yAxis.add("Utilization of untied fund adequate (Total)");
yAxis.add("Awareness generation (use ofIEC/BCC) (Total)");
yAxis.add("Grievance redressal mechanismin place (Total)");
return yAxis;
}
++++++++++++++++++++++++++++++++++++
After this i found the design like this, but i want to remove the x axis also
+++++++++++++++++++++++++++++++++++++

To show xAxis on bottom, please use
chart.getXAxix()..setPosition(XAxis.XAxisPosition.BOTTOM);
in place of
chart.getXAxis().setEnabled(false);
after putting
chart.getXAxix()..setPosition(XAxis.XAxisPosition.BOTTOM);
instaed of
chart.getXAxis().setEnabled(false);
I am getting the result like this : kindly help me sir i want to remove all lines except left Y axis and botton X axis.

To disable the grid lines, you have to use
chart.getXAxis().setDrawGridLines(false);
YAxis rightYAxis = barChart.getAxisRight();
rightYAxis.setEnabled(false);
rightYAxis.setDrawGridLines(false);
Please look into the wiki for more information...
How to remove the x axis grid lines except the button x axis line

final BarChart chart = (BarChart) view.findViewById(R.id.bar_chart);
BarData data = new BarData(getXAxisValues(), getDataSet());
chart.setData(data);
chart.setDrawValueAboveBar(false);
chart.getXAxis().setTextSize(15f);
chart.setDescription("Percent(%)");
chart.getLegend().setEnabled(false);
// Remove the grid line from background
chart.getAxisLeft().setDrawGridLines(false);
chart.getXAxis().setDrawGridLines(false);
YAxis yAxis = chart.getAxisLeft();
yAxis.setDrawGridLines(false);
// Disable the right y axis
YAxis rightYAxis = chart.getAxisRight();
rightYAxis.setEnabled(false);
rightYAxis.setDrawGridLines(false);
// Hide the desc value of each bar on top
chart.getXAxis().setEnabled(false);
chart.animateXY(2000, 2000);
chart.invalidate();
chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
@Override
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
if (e != null) {
String name = chart.getData().getXVals().get(e.getXIndex());
Float value = e.getVal();
showMsg(name,value);
}
}
@Override
public void onNothingSelected() {
}
});
my chart is like this, it remove all grid with button x axis also, so how to do this ,i want only the left y axis with button x axis.

Try this
XAxis xAxis = chart.getXAxis();
xAxis.setEnabled(true);
xAxis.setDrawGridLines(false);
xAxis.setTextSize(15f);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
i am using horizontal bar graph i want to set max value in y in single horizontal bar graph
please help
Closing for inactivity
Most helpful comment
To disable the right yAxis
You may want to use similar example for xAxis.