在這裏,我試圖表現出與x軸的日期,其中值從網絡服務器檢索圖表的Android圖:與x軸的日期
// Our first data
Date[] x = dates_array; // x values!
double[] y = readings_array; // y values!
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer(); // Holds a collection of XYSeriesRenderer and customizes the graph
XYSeriesRenderer renderer = new XYSeriesRenderer(); // This will be used to customize line 1
XYSeriesRenderer renderer2 = new XYSeriesRenderer(); // This will be used to customize line 2
mRenderer.addSeriesRenderer(renderer);
mRenderer.addSeriesRenderer(renderer2);
TimeSeries series = new TimeSeries("peak flow");
for(int i = 0; i < x.length; i++)
{
series.add(x[i], y[i]);
}
// Our second data
int[] x2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
int[] y2 = { 145, 123, 111, 100, 89, 77, 57, 45, 34, 30}; // y values!
TimeSeries series2 = new TimeSeries("Line2");
for(int i = 0; i < x2.length; i++)
{
series2.add(x2[i], y2[i]);
}
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.addSeries(series);
dataset.addSeries(series2);
// Customization time for line 1!
renderer.setColor(Color.WHITE);
renderer.setPointStyle(PointStyle.SQUARE);
renderer.setFillPoints(true);
// Customization time for line 2!
renderer2.setColor(Color.YELLOW);
renderer2.setPointStyle(PointStyle.DIAMOND);
renderer2.setFillPoints(true);
Intent intent = ChartFactory.getTimeChartIntent(getApplicationContext(), dataset,
mRenderer, "DD MMM yyyy");
startActivity(intent);
}
});
它正常工作與Y-但在x軸上顯示的值是隨機值,不是我的值! 請幫忙嗎?
你是說,該系列數據不正確或X標籤? – Simon
該系列數據顯示爲長數字而不是日期格式,並且當我使用getTimeChartIntent()時出現了隨機日期! – NMJ