嗨朋友们,我在我的 android 应用程序中使用了图表。在那我每秒更新一次图表。现在我想在它更新值时从右到左移动这个图表。有人知道怎么做吗?任何帮助表示赞赏。
dataset = new XYMultipleSeriesDataset();
renderer = new XYMultipleSeriesRenderer();
renderer.setChartTitleTextSize(12);
renderer.setLabelsTextSize(15);
renderer.setMarginsColor(Color.argb(0x00, 0x01, 0x01, 0x01));
renderer.setApplyBackgroundColor(true);
renderer.setBackgroundColor(Color.TRANSPARENT);
renderer.setZoomEnabled(false, false);
renderer.setPointSize(5f);
renderer.setShowGrid(true);
renderer.setXTitle("Time");
renderer.setYTitle("Number");
rendererSeries = new XYSeriesRenderer();
rendererSeries.setColor(Color.BLUE);
rendererSeries.setFillBelowLine(false);
rendererSeries.setFillPoints(true);
rendererSeries.setPointStyle(PointStyle.CIRCLE);
renderer.addSeriesRenderer(rendererSeries);
timeSeries = new TimeSeries("Random");
mThread = new Thread(){
public void run(){
while(true){
try {
Thread.sleep(2000L);
}
catch (InterruptedException e) {
e.printStackTrace();
}
timeSeries.add(new Date(), random.nextInt(10));
mchartView.repaint();
}
}
};
mThread.start();
dataset.addSeries(timeSeries);
mchartView = ChartFactory.getLineChartView(Pedometer.this, dataset, renderer);
mchartView.refreshDrawableState();
mchartView.repaint();
llChart.addView(mchartView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));