I was finally able to get android GraphView up and running. However when I try to scroll or zoom nothing happens. I've tried using ScrollView, LinearLayout, and a host of others. I'm currently loading the graph in a DialogFragment.
package com.example.resistograph;
import android.app.DialogFragment;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.GraphView.GraphViewData;
import com.jjoe64.graphview.GraphViewSeries;
import com.jjoe64.graphview.LineGraphView;
public class GraphFragment extends DialogFragment {
static String data;
int[] conversion;
public GraphFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
String[] lines = data.split("\r\n|\r|\n");
conversion = new int[lines.length];
for(int i=1; i<lines.length; i=i+1){
conversion[i]=Integer.parseInt(lines[i]);
}
View v = inflater.inflate(R.layout.graph_fragment, container, false);
GraphViewSeries exampleSeries = null;
for (int x=0; x<lines.length; x=x+1) {
exampleSeries = new GraphViewSeries(new GraphViewData[] {
new GraphViewData(x, conversion[x]),
});
}
GraphView graphView = new LineGraphView(
getActivity() // context
, "GraphViewDemo" // heading
);
graphView.addSeries(exampleSeries); // data
graphView.setScalable(true);
graphView.setScrollable(true);
graphView.getGraphViewStyle().setHorizontalLabelsColor(Color.BLUE);
graphView.getGraphViewStyle().setVerticalLabelsColor(Color.BLUE);
LinearLayout layout = (LinearLayout)v.findViewById(R.id.graph);
layout.addView(graphView);
return v;
}
}
My layout file looks like this.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/graph"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</LinearLayout>
When I go to scroll or zoom the eclipse log says this:
09-20 23:45:36.380: D/GraphView(12160): on touch event scale not handled+0.0
09-20 23:45:36.440: D/GraphView(12160): on touch event scale not handled+0.0
09-20 23:45:36.460: D/GraphView(12160): on touch event scale not handled+615.3957
09-20 23:45:36.470: D/GraphView(12160): on touch event scale not handled+613.4519
09-20 23:45:36.480: D/GraphView(12160): on touch event scale not handled+608.0
09-20 23:45:36.510: D/GraphView(12160): on touch event scale not handled+0.0
09-20 23:45:36.540: D/GraphView(12160): on touch event scale not handled+601.4615
09-20 23:45:36.580: D/GraphView(12160): on touch event scale not handled+598.99097
09-20 23:45:36.600: D/GraphView(12160): on touch event scale not handled+593.62683
09-20 23:45:37.770: D/GraphView(12160): on touch event scale not handled+0.0
09-20 23:45:37.770: D/GraphView(12160): on touch event scale not handled+508.0