So you need a layout (main.xml):
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/chart" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" /> <LinearLayout android:id="@+id/layXzoom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:orientation="horizontal" android:padding="5dp" > </LinearLayout> </RelativeLayout>
and activity (TestgrafActivity.java):
package si.pd.testgraf; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Random; import org.achartengine.ChartFactory; import org.achartengine.GraphicalView; import org.achartengine.chart.PointStyle; import org.achartengine.chart.TimeChart; import org.achartengine.model.TimeSeries; import org.achartengine.model.XYMultipleSeriesDataset; import org.achartengine.renderer.XYMultipleSeriesRenderer; import org.achartengine.renderer.XYSeriesRenderer; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.widget.LinearLayout; public class TestgrafActivity extends Activity { private XYMultipleSeriesDataset mDataset; private XYMultipleSeriesRenderer mRenderer; List<double[]> values = new ArrayList<double[]>(); private GraphicalView mChartView; private TimeSeries time_series;
I have not tested the code, so there may be some errors. Just wanted you to get the picture.
I checked at home. If you give me an email, I can send you an eclipse project.
toni
source share