3

AndroidPlot is an awesome lib. I followed http://androidplot.com/docs/how-to-pan-zoom-and-scale/ to make a scrollable chart but found the domain grid lines were fixed while the chart was scrolling. Is it possible to make the grid lines scroll with the chart?

Thanks

Louis Lee
  • 31
  • 1

1 Answers1

0

I wrapped my graph in a linear layout:

 <LinearLayout
    android:id="@+id/graphLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <com.androidplot.xy.XYPlot
        android:id="@+id/mySimpleXYPlot"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        ....

Then in the .java file I assigned the view to the linear layout and set the onTouchListener to that layout:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_graph);
    LinearLayout view = (LinearLayout) findViewById(R.id.graphLayout);  // assign layout graph is in
    view.setOnTouchListener(this);       // set onTouchListener to graph's layout     

    plot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
    ....

That worked for me.