1
私は自分のコードにMPAndroidChart
プロジェクトを追加していると私はバーチャートを使用したいが、x-のentiresのために、私は開始日と終了日付変数を入力します。MPAndroidChart:バーチャート変数Xエントリ
どうすればいいですか?
私は自分のコードにMPAndroidChart
プロジェクトを追加していると私はバーチャートを使用したいが、x-のentiresのために、私は開始日と終了日付変数を入力します。MPAndroidChart:バーチャート変数Xエントリ
どうすればいいですか?
は最後に、私は解決策が見つかりましたがば完全によくない:
私は以下のようなパブリッククラスDayAxisValueFormatterを変更する必要があり:
private BarLineChartBase<?> chart;
private String[] mValues;
private ArrayList<Long> mDateList = new ArrayList<Long>();
private int mSize;
public DayAxisValueFormatter(BarLineChartBase<?> chart, ArrayList<Long> DateList, int size) {
this.chart = chart;
this.mDateList = DateList;
this.mSize = size;
}
@Override
public String getFormattedValue(float value, AxisBase axis) {
// "value" represents the position of the label on the axis (x or y)
return longToStringForTimeReal(mDateList.get(mSize));
}
//Pour le formatage de la date
public static String longToStringForTimeReal(long time) {
Date date = new Date(time);
SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy/MM/dd");
return simpleDate.format(date);
}
そして、私はこのようにそれを呼び出す:
AxisValueFormatter xAxisFormatter = new DayAxisValueFormatter(mChart,mDateList, mDateList.size());
xAxis.setValueFormatter(xAxisFormatter);
その方法の問題は次のとおりです。X値について同じ日付を取得しました。