0

I have a date-based graph with x-axis as dates. By default, I populate the graph with a data set of past 6 months. I would like to change the graph to show:

  • Last one week,
  • Last one month,
  • Last 3 months etc.

I looked at the API documentation for modifying the viewport here: https://github.com/PhilJay/MPAndroidChart/wiki/Modifying-the-Viewport

And tried playing around with:

    graph.setVisibleXRangeMaximum(100);
    graph.moveViewToX(50);
    graph.invalidate();

I tried various different parameters, but nothing happens when the above code is executed. My graph already has data filled and is displaying correctly.

Am I looking in the right direction for what I want to achieve? How can I debug my issue?

Bonton255
  • 2,231
  • 3
  • 28
  • 44

1 Answers1

0

For those interested, I found the solution.

TL;DR: There is no in-built functionality to change the granularity of the data shown. You need to set the chart's data-set accordingly.

Here is the example from samples: https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/LineChartTime.java

Bonton255
  • 2,231
  • 3
  • 28
  • 44