1

I'm working on an app that uses GraphView. Users can scale the graph (zoom in, zoom out), and they can use a 'reset zoom' button to reset to the default view they get when they open the graph. I got it working, but the graph doesn't update when I press the button. Only if I press the button THEN scroll the graph will it reset to the default zoom. I was looking for redraw() or refresh() methods to fix it, but nothing's worked so far. Here's my code:

 resett.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //set manual X bounds
            graph.getViewport().setXAxisBoundsManual(true);
            graph.getViewport().setMinX(-10);
            graph.getViewport().setMaxX(10);

            // set manual Y bounds
            graph.getViewport().setYAxisBoundsManual(true);
            graph.getViewport().setMinY(-15);
            graph.getViewport().setMaxY(15);

            graph.refreshDrawableState();
        }
    });

Any leads?

Nihilish
  • 105
  • 1
  • 16

1 Answers1

4

For changes to take effect, you need to call this instead of refreshDrawableState:

    graph.onDataChanged(false, false);

You may modify the parameters to see the change in the graph that you are looking for.

svahidhoss
  • 333
  • 2
  • 11