I am creating an application and use the MPAndroidChart library to draw line chart. I am putting Dates on x-axis and number on y-axis. I am not able to scroll line chart horizontally when there are more data. My snippet is here:
XAxis xAxis = chart.getXAxis();
xAxis.setTextSize(8f);
xAxis.setTextColor(Color.BLACK);
xAxis.setDrawGridLines(false);
xAxis.setPosition(xAxis.getPosition());
xAxis.setDrawAxisLine(true);
// xAxis.setSpaceBetweenLabels(1);
xAxis.setLabelRotationAngle(-90.0f);
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setTextColor(Color.BLACK);
leftAxis.setDrawGridLines(true);
leftAxis.setValueFormatter(new DefaultYAxisValueFormatter(0));
YAxis rightAxis = chart.getAxisRight();
rightAxis.setTextColor(Color.BLACK);
rightAxis.setDrawGridLines(true);
rightAxis.setValueFormatter(new DefaultYAxisValueFormatter(0));
LineDataSet barDataSet1 = null;
if (valueSet1 != null && valueSet1.size() > 0) {
barDataSet1 = new LineDataSet(valueSet1, "Sended");
barDataSet1.setColor(Color.BLACK);
barDataSet1.setCircleColor(Color.BLACK);
barDataSet1.setCircleSize(2.0f);
barDataSet1.setLineWidth(1.0f);
barDataSet1.setValueTextColor(Color.BLACK);
barDataSet1.setValueTextSize(10.0f);
barDataSet1.setDrawCubic(true);
}
ArrayList dataSets = new ArrayList<>();
if (barDataSet1 != null)
dataSets.add(barDataSet1);
LineData data = new LineData(xDatelist, dataSets);
if (data != null)
chart.setData(data);
chart.setPinchZoom(true);
chart.setScrollContainer(true);
chart.setHorizontalScrollBarEnabled(true);
chart.setScaleXEnabled(true);
chart.setDescription("Send/Received files");
chart.invalidate();
Still I am not able to scroll graph when there is more data then date gets compressed on x-axis. How can I solve this issue?