Bonton255
Bonton255

Reputation: 2419

MPAndroidChart Change Graph's Date Range

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:

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?

Upvotes: 0

Views: 2302

Answers (1)

Bonton255
Bonton255

Reputation: 2419

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

Upvotes: 0

Related Questions