2013-08-21 1 views
2

achartengine 라이브러리를 사용하여 그래프를 플롯하는 응용 프로그램을 작성 중입니다. X 축에 대한 값은 yyyy-MM-dd hh : mm : ss 형식이고 y 축에는 정수 값을 갖습니다. Y 및 X 축에 레이블을 설정하는 데 문제가 있습니다.achartengine에 대한 날짜 및 시간 레이블 사용

X 축 값 : 2013-07-09 12:34:32, 2013-07-11 10:34:32, 2013-07-11 12:34:31, 2013-07-12 12:34:32

Y 축 값 : 40, 50, 60, 35

I 의해 날짜 오브젝트를 획득하고 난 Y 축 여기서 0으로 원점 조정하고자하는 샘플 데이터 세트 인 나는 Y 좌표지고 있지 않다 다음은이 코드를 실행에 형식 yyyy-MM-dd hh:mm:ss

의 문자열은 new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(date)

date입니다 호출 원점을 0으로 지정하고 X 축 레이블의 값이 날짜 형식 yyyy-mm-dd hh:mm:ss이 아닙니다. 누군가 그것을 그 형식으로 표시하도록 도울 수 있습니까? 그게 내가이어야는 형식으로 표시 할 수있는 방법을 할 수없는 경우 등 Jan 1st 2013 또는 여기

01-01-2013 내 코드입니다 :

TimeSeries series = new TimeSeries("Line1"); 
for(int i = 0; i < x.length; i++) 
{ 
    //x[i] represents the date object and y[i] represents the integer 
    series.add(x[i], y[i]); 
} 
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); 
dataset.addSeries(series); 

XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer(); // Holds a collection of XYSeriesRenderer and customizes the graph 
XYSeriesRenderer renderer = new XYSeriesRenderer(); 
mRenderer.addSeriesRenderer(renderer); 

// Customization line 1 
renderer.setColor(Color.BLACK); 
renderer.setPointStyle(PointStyle.SQUARE); 
renderer.setFillPoints(true); 

Intent intent = ChartFactory.getLineChartIntent(context, dataset, mRenderer, "Line Graph Title"); 
return intent; 

답변

2

당신은 TimeSeries를 사용하고, 그래서 당신은 아마 시간 차트를 구축하고자 . 따라서 ChartFactory.getLineChartIntent() 대신 ChartFactory.getTimeChartIntent()을 사용하고 싶습니다.