MPAndroidChart
MPAndroidChart copied to clipboard
map is not drawing when time is added x axis value
when i have added time in axis time and y axis values are displayed but bar is not drawn yet.. i need urgent help
adding code here
if (barEntriesArrayList.isEmpty()) { values.clear(); binding.cBarChart.notifyDataSetChanged(); binding.cBarChart.clear(); } else {
binding.cBarChart.setDrawGridBackground(false);
binding.cBarChart.setDrawBarShadow(false);
binding.cBarChart.setDrawBorders(false);
binding.cBarChart.getDescription().setEnabled(false);
binding.cBarChart.animateX(1000);
binding.cBarChart.animateY(1000);
XAxis xAxis = binding.cBarChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setGranularity(1f);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
YAxis leftAxis = binding.cBarChart.getAxisLeft();
leftAxis.setDrawAxisLine(false);
YAxis rightAxis = binding.cBarChart.getAxisRight();
rightAxis.setDrawAxisLine(false);
Legend legend = binding.cBarChart.getLegend();
legend.setForm(Legend.LegendForm.LINE);
legend.setTextSize(11f);
legend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
legend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
//setting the stacking direction of legend
legend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
//setting the location of legend outside the chart, default false if not set
legend.setDrawInside(false);
barDataSet = new BarDataSet(barEntriesArrayList, parameter);
Collections.sort(barEntriesArrayList, new EntryXComparator());
barDataSet.setDrawIcons(false);
barDataSet.setColors(Color.BLACK);
barDataSet.setValueTextColor(Color.BLACK);
barDataSet.setValueTextSize(10f);
barDataSet.setFormSize(10f);
barDataSet.setDrawValues(true);
barData = new BarData(barDataSet);
binding.cBarChart.setData(barData);
binding.cBarChart.getXAxis().setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
String date = "";
// convert the float value to Date object
date = CalanderUtilis.getSchedulerTime((long) value);
// retuArn the formatted date string
return date;
}
});
if (binding.cBarChart != null && binding.cBarChart.getXAxis() != null) {
binding.cBarChart.getXAxis().setGranularityEnabled(true);
}
xAxis.setLabelRotationAngle(-90f); // changing angle of x axis data
xAxis.setLabelCount(barEntriesArrayList.size()); // to get all input data plotted
binding.cBarChart.notifyDataSetChanged();
binding.cBarChart.invalidate();
}