2016-08-08 43 views

回答

0

最後,我找到了一個解決辦法,但不是完全以良好:

我有修改公共類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值上得到了相同的日期。

相關問題