0

there's something wrong with my graphview first attempt code:

GraphView graphView;
GraphViewSeries series;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    GraphViewData[] data = new GraphViewData[4];
    Double[] x_values = new Double[] { 1.0, 2.0, 3.0, 4.0 };
    Double[] y_values = new Double[] { 1.0, 2.0, 3.0, 4.0 };

    for (int i = 0; i < data.length; i++) {
        data[i] = new GraphViewData(x_values[i], y_values[i]);
    }

    series = new GraphViewSeries(data);

    graphView = new LineGraphView(this, "Title");
    graphView.addSeries(series);
    graphView.setScrollable(true);
    graphView.setScalable(true);
    graphView.setBackgroundColor(Color.BLACK);

    LinearLayout l = (LinearLayout) findViewById(R.id.linearLay);
    l.addView(graphView);
}

two issues: -the background is still white -after zooming in, i can't zooming out -the label on x axes are not showed

giozh
  • 9,868
  • 30
  • 102
  • 183

1 Answers1

3

Regarding the white background, try adding:

((LineGraphView) graphView).setDrawBackground(true);

You can set the label colors like this:

graphView.getGraphViewStyle().setHorizontalLabelsColor(Color.BLACK);
graphView.getGraphViewStyle().setVerticalLabelsColor(Color.BLACK);

I hope it works!

Br, Tim

Tim Hansson
  • 309
  • 2
  • 16