/
NikolayIvkin
/
MPAndroidChart1
Обзор
Документация
Войти
/
NikolayIvkin
/
MPAndroidChart1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/custom/MyCustomXAxisValueFormatter.java
43 строки
1 KB
Daniel Cohen Gindi
Revert:
e5b6619
- bring back polymorphism to value formatters
21 сен 2020, 17:48
21 сен 2020, 17:48
bc0be2c
Код
Авторство
О чём код?
package com.xxmassdeveloper.mpchartexample.custom; import com.github.mikephil.charting.components.AxisBase; import com.github.mikephil.charting.formatter.IAxisValueFormatter; import com.github.mikephil.charting.utils.ViewPortHandler; import java.text.DecimalFormat; /** * Created by Philipp Jahoda on 14/09/15. * * @deprecated The {@link MyAxisValueFormatter} does exactly the same thing and is more functional. */ @Deprecated public class MyCustomXAxisValueFormatter implements IAxisValueFormatter { private final DecimalFormat mFormat; private final ViewPortHandler mViewPortHandler; public MyCustomXAxisValueFormatter(ViewPortHandler viewPortHandler) { mViewPortHandler = viewPortHandler; // maybe do something here or provide parameters in constructor mFormat = new DecimalFormat("###,###,###,##0.0"); } @Override public String getFormattedValue(float value, AxisBase axis) { //Log.i("TRANS", "x: " + viewPortHandler.getTransX() + ", y: " + viewPortHandler.getTransY()); // e.g. adjust the x-axis values depending on scale / zoom level final float xScale = mViewPortHandler.getScaleX(); if (xScale > 5) return "4"; else if (xScale > 3) return "3"; else if (xScale > 1) return "2"; else return mFormat.format(value); } }