0
我正在創建一個應用程序並使用MPAndroidChart庫繪製折線圖。我將x軸上的日期和y軸上的數字放在一起。有更多數據時,我無法水平滾動折線圖。我的片段在這裏:MPAndroidChart中的可滾動LineChart
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();
仍然我無法滾動圖表,當有更多的數據,然後日期被壓縮在X軸上。請幫助解決這個問題。
如果我在yAxis左邊和yAxis的權利? – MNFS