Skip to content

Commit 8b3bacc

Browse files
committed
Rename
1 parent d8aa178 commit 8b3bacc

File tree

4 files changed

+41
-30
lines changed

4 files changed

+41
-30
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/formatter/DefaultFillFormatter.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ open class DefaultFillFormatter : IFillFormatter {
1616
fillMin = if (dataSet!!.yMax > 0 && dataSet.yMin < 0) {
1717
0f
1818
} else {
19-
val max: Float = if (data.yMax > 0) 0f else chartMaxY
20-
val min: Float = if (data.yMin < 0) 0f else chartMinY
19+
val max: Float = if (data.yMax > 0) 0f
20+
else
21+
chartMaxY
22+
val min: Float = if (data.yMin < 0)
23+
0f
24+
else
25+
chartMinY
2126
if (dataSet.yMin >= 0)
2227
min
2328
else

MPChartLib/src/main/java/com/github/mikephil/charting/formatter/IndexAxisValueFormatter.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import kotlin.math.roundToInt
88
*/
99
open class IndexAxisValueFormatter : IAxisValueFormatter {
1010

11+
var values: Array<String> = arrayOf()
12+
1113
/**
1214
* Constructor that specifies axis labels.
1315
*
1416
* @param values The values string array
1517
*/
1618
constructor(values: Array<String>?) {
17-
if (values != null) this.values = values
19+
if (values != null)
20+
this.values = values
1821
}
1922

2023
/**
@@ -23,13 +26,16 @@ open class IndexAxisValueFormatter : IAxisValueFormatter {
2326
* @param values The values string array
2427
*/
2528
constructor(values: Collection<String>?) {
26-
if (values != null) this.values = values.toTypedArray()
29+
if (values != null)
30+
this.values = values.toTypedArray()
2731
}
2832

2933
override fun getFormattedValue(value: Float, axis: AxisBase?): String {
3034
val index = value.roundToInt()
31-
return if (index < 0 || index >= values.size || index != value.toInt()) "" else values[index]
35+
return if (index < 0 || index >= values.size || index != value.toInt())
36+
""
37+
else
38+
values[index]
3239
}
3340

34-
var values: Array<String> = arrayOf()
3541
}

MPChartLib/src/main/java/com/github/mikephil/charting/formatter/LargeValueFormatter.kt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,30 @@ import java.text.DecimalFormat
1515
*/
1616
open class LargeValueFormatter() : IValueFormatter, IAxisValueFormatter {
1717

18-
private var mSuffix = arrayOf(
18+
private var suffix = arrayOf(
1919
"", "k", "m", "b", "t"
2020
)
21-
private var mMaxLength = 5
22-
private val mFormat: DecimalFormat = DecimalFormat("###E00")
23-
private var mText = ""
21+
private var maxLength = 5
22+
private val decimalFormat: DecimalFormat = DecimalFormat("###E00")
23+
private var text = ""
2424

2525
/**
2626
* Creates a formatter that appends a specified text to the result string
2727
*
2828
* @param appendix a text that will be appended
2929
*/
3030
constructor(appendix: String) : this() {
31-
mText = appendix
31+
text = appendix
3232
}
3333

3434
// IValueFormatter
3535
override fun getFormattedValue(value: Float, entry: Entry?, dataSetIndex: Int, viewPortHandler: ViewPortHandler?): String {
36-
return makePretty(value.toDouble()) + mText
36+
return makePretty(value.toDouble()) + text
3737
}
3838

3939
// IAxisValueFormatter
4040
override fun getFormattedValue(value: Float, axis: AxisBase?): String {
41-
return makePretty(value.toDouble()) + mText
41+
return makePretty(value.toDouble()) + text
4242
}
4343

4444
/**
@@ -47,37 +47,37 @@ open class LargeValueFormatter() : IValueFormatter, IAxisValueFormatter {
4747
* @param appendix
4848
*/
4949
fun setAppendix(appendix: String) {
50-
mText = appendix
50+
text = appendix
5151
}
5252

5353
/**
5454
* Set custom suffix to be appended after the values.
5555
* Default suffix: ["", "k", "m", "b", "t"]
5656
*
57-
* @param suffix new suffix
57+
* @param suffixArray new suffix
5858
*/
59-
fun setSuffix(suffix: Array<String>) {
60-
mSuffix = suffix
59+
fun setSuffix(suffixArray: Array<String>) {
60+
suffix = suffixArray
6161
}
6262

63-
fun setMaxLength(maxLength: Int) {
64-
mMaxLength = maxLength
63+
fun setMaxLength(max: Int) {
64+
maxLength = max
6565
}
6666

6767
/**
6868
* Formats each number properly. Special thanks to Roman Gromov
6969
* (https://github.com/romangromov) for this piece of code.
7070
*/
7171
private fun makePretty(number: Double): String {
72-
var r = mFormat.format(number)
73-
val numericValue1 = Character.getNumericValue(r[r.length - 1])
74-
val numericValue2 = Character.getNumericValue(r[r.length - 2])
72+
var decimalFormat = decimalFormat.format(number)
73+
val numericValue1 = Character.getNumericValue(decimalFormat[decimalFormat.length - 1])
74+
val numericValue2 = Character.getNumericValue(decimalFormat[decimalFormat.length - 2])
7575
val combined = Integer.valueOf(numericValue2.toString() + "" + numericValue1)
76-
r = r.replace("E[0-9][0-9]".toRegex(), mSuffix[combined / 3])
77-
while (r.length > mMaxLength || r.matches("[0-9]+\\.[a-z]".toRegex())) {
78-
r = r.substring(0, r.length - 2) + r.substring(r.length - 1)
76+
decimalFormat = decimalFormat.replace("E[0-9][0-9]".toRegex(), suffix[combined / 3])
77+
while (decimalFormat.length > maxLength || decimalFormat.matches("[0-9]+\\.[a-z]".toRegex())) {
78+
decimalFormat = decimalFormat.substring(0, decimalFormat.length - 2) + decimalFormat.substring(decimalFormat.length - 1)
7979
}
80-
return r
80+
return decimalFormat
8181
}
8282

8383
}

MPChartLib/src/main/java/com/github/mikephil/charting/formatter/StackedValueFormatter.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import java.text.DecimalFormat
1717
* @param decimals the number of decimal digits to use
1818
*/
1919
open class StackedValueFormatter(private val drawWholeStack: Boolean, private val appendix: String, decimals: Int) : IValueFormatter {
20-
private val mFormat: DecimalFormat
20+
private val decimalFormat: DecimalFormat
2121

2222
init {
2323
val b = StringBuffer()
@@ -26,7 +26,7 @@ open class StackedValueFormatter(private val drawWholeStack: Boolean, private va
2626
b.append("0")
2727
}
2828

29-
this.mFormat = DecimalFormat("###,###,###,##0$b")
29+
this.decimalFormat = DecimalFormat("###,###,###,##0$b")
3030
}
3131

3232
override fun getFormattedValue(value: Float, entry: Entry?, dataSetIndex: Int, viewPortHandler: ViewPortHandler?): String {
@@ -40,14 +40,14 @@ open class StackedValueFormatter(private val drawWholeStack: Boolean, private va
4040
return if (vals[vals.size - 1] == value) {
4141
// return the "sum" across all stack values
4242

43-
mFormat.format(barEntry.y.toDouble()) + appendix
43+
decimalFormat.format(barEntry.y.toDouble()) + appendix
4444
} else {
4545
"" // return empty
4646
}
4747
}
4848
}
4949

5050
// return the "proposed" value
51-
return mFormat.format(value.toDouble()) + appendix
51+
return decimalFormat.format(value.toDouble()) + appendix
5252
}
5353
}

0 commit comments

Comments
 (0)