forked from PhilJay/MPAndroidChart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyCustomXValueFormatter.java
More file actions
30 lines (24 loc) · 956 Bytes
/
MyCustomXValueFormatter.java
File metadata and controls
30 lines (24 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.xxmassdeveloper.mpchartexample.custom;
import com.github.mikephil.charting.utils.ViewPortHandler;
import com.github.mikephil.charting.utils.XValueFormatter;
/**
* Created by Philipp Jahoda on 14/09/15.
*/
public class MyCustomXValueFormatter implements XValueFormatter {
public MyCustomXValueFormatter() {
// maybe do something here or provide parameters in constructor
}
@Override
public String getXValue(String original, int index, ViewPortHandler viewPortHandler) {
//Log.i("TRANS", "x: " + viewPortHandler.getTransX() + ", y: " + viewPortHandler.getTransY());
// e.g. adjust the x-axis values depending on scale / zoom level
if (viewPortHandler.getScaleX() > 5)
return "4";
else if (viewPortHandler.getScaleX() > 3)
return "3";
else if (viewPortHandler.getScaleX() > 1)
return "2";
else
return original;
}
}