I want to add my bar values to the left of the bar and the bar labels to the right of the bar.
Below is the code that initilizes HorizontalBarChart
HorizontalBarChart mChart = (HorizontalBarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription(strHeading);
mChart.setMaxVisibleValueCount(60);
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
XAxis xl = mChart.getXAxis();
xl.setDrawLabels(false);
YAxis yl = mChart.getAxisLeft();
yl.setDrawLabels(false);
YAxis yr = mChart.getAxisRight();
yr.setTypeface(mTfLight);
yr.setDrawAxisLine(true);
yr.setDrawGridLines(false);
setData(12, 50);
mChart.setFitBars(true);
mChart.animateY(2500);
mChart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
Legend l = mChart.getLegend();
l.setPosition(Legend.LegendPosition.ABOVE_CHART_LEFT);
l.setFormSize(8f);
l.setXEntrySpace(4f);
Below is the method that binds the data, The following code
float barWidth = 9f;
float spaceForBar = 10f;
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i=0 ; i< arrayChart.size(); i++){
ModelChart modelChart = arrayChart.get(i);
String aString = modelChart.getHeader();
float space = i * spaceForBar;
BarEntry eachEntry = new BarEntry(i * spaceForBar, modelChart.getValue() , modelChart.getHeader());
yVals1.add(eachEntry);
}
if (mChart.getData() != null &&
mChart.getData().getDataSetCount() > 0) {
BarDataSet set1 = (BarDataSet)mChart.getData().getDataSetByIndex(0);
set1.setValues(yVals1);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();
} else {
set1 = new BarDataSet(yVals1, "A , B , C");
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(dataSets);
data.setValueTextSize(10f);
data.setValueTypeface(mTfLight);
data.setBarWidth(barWidth);
mChart.setData(data);
}