Skip to content

Commit a954c50

Browse files
committed
Return not in same line
1 parent 7771bd0 commit a954c50

24 files changed

Lines changed: 94 additions & 48 deletions

MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarChart.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ open class BarChart : BarLineChartBase<BarData>, BarDataProvider {
110110
} else {
111111
highlighter?.let {
112112
val h = it.getHighlight(x, y)
113-
if (h == null || !isHighlightFullBarEnabled) return h
113+
if (h == null || !isHighlightFullBarEnabled)
114+
return h
114115

115116
// For isHighlightFullBarEnabled, remove stackIndex
116117
return Highlight(

MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieChart.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ class PieChart : PieRadarChartBase<PieData> {
150150
override fun onDraw(canvas: Canvas) {
151151
super.onDraw(canvas)
152152

153-
if (mData == null) return
153+
if (mData == null)
154+
return
154155

155156
mRenderer?.drawData(canvas)
156157

@@ -316,7 +317,8 @@ class PieChart : PieRadarChartBase<PieData> {
316317
* Checks if the given index is set to be highlighted.
317318
*/
318319
fun needsHighlight(index: Int): Boolean {
319-
if (!valuesToHighlight()) return false
320+
if (!valuesToHighlight())
321+
return false
320322

321323
// check if the xvalue for the given dataset needs highlight
322324
highlighted?.let {
@@ -347,7 +349,8 @@ class PieChart : PieRadarChartBase<PieData> {
347349
val a = Utils.getNormalizedAngle(angle - rotationAngle)
348350

349351
for (i in absoluteAngles.indices) {
350-
if (this.absoluteAngles[i] > a) return i
352+
if (this.absoluteAngles[i] > a)
353+
return i
351354
}
352355

353356
return -1 // return -1 if no index found
@@ -360,7 +363,8 @@ class PieChart : PieRadarChartBase<PieData> {
360363
val dataSets = mData?.dataSets
361364

362365
for (i in dataSets!!.indices) {
363-
if (dataSets[i].getEntryForXValue(xIndex.toFloat(), Float.NaN) != null) return i
366+
if (dataSets[i].getEntryForXValue(xIndex.toFloat(), Float.NaN) != null)
367+
return i
364368
}
365369

366370
return -1

MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieRadarChartBase.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ abstract class PieRadarChartBase<T : ChartData<out IDataSet<out Entry>>>
104104
}
105105

106106
override fun notifyDataSetChanged() {
107-
if (mData == null) return
107+
if (mData == null)
108+
return
108109

109110
calcMinMax()
110111

MPChartLib/src/main/java/com/github/mikephil/charting/charts/RadarChart.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ class RadarChart : PieRadarChartBase<RadarData> {
133133
override fun onDraw(canvas: Canvas) {
134134
super.onDraw(canvas)
135135

136-
if (mData == null) return
136+
if (mData == null)
137+
return
137138

138139
// if (mYAxis.isEnabled())
139140
// mYAxisRenderer.computeAxis(mYAxis.mAxisMinimum, mYAxis.mAxisMaximum, mYAxis.isInverted());

MPChartLib/src/main/java/com/github/mikephil/charting/components/AxisBase.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,10 @@ abstract class AxisBase : ComponentBase() {
506506
}
507507

508508
fun getFormattedLabel(index: Int): String? {
509-
if (index < 0 || index >= mEntries.size) return ""
510-
else return this.valueFormatter!!.getFormattedValue(mEntries[index], this)
509+
return if (index < 0 || index >= mEntries.size)
510+
""
511+
else
512+
this.valueFormatter!!.getFormattedValue(mEntries[index], this)
511513
}
512514

513515
var valueFormatter: IAxisValueFormatter?

MPChartLib/src/main/java/com/github/mikephil/charting/components/YAxis.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,10 @@ class YAxis : AxisBase {
267267
* Returns true if this axis needs horizontal offset, false if no offset is needed.
268268
*/
269269
fun needsOffset(): Boolean {
270-
if (isEnabled && isDrawLabelsEnabled && this.labelPosition == YAxisLabelPosition.OUTSIDE_CHART) return true
271-
else return false
270+
return if (isEnabled && isDrawLabelsEnabled && this.labelPosition == YAxisLabelPosition.OUTSIDE_CHART)
271+
true
272+
else
273+
false
272274
}
273275

274276

MPChartLib/src/main/java/com/github/mikephil/charting/data/BarEntry.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ open class BarEntry : Entry {
159159
}
160160

161161
fun getSumBelow(stackIndex: Int): Float {
162-
if (this.yVals == null) return 0f
162+
if (this.yVals == null)
163+
return 0f
163164

164165
var remainder = 0f
165166
var index = yVals!!.size - 1
@@ -194,7 +195,8 @@ open class BarEntry : Entry {
194195
protected fun calcRanges() {
195196
val values = this.yVals
196197

197-
if (values == null || values.isEmpty()) return
198+
if (values == null || values.isEmpty())
199+
return
198200

199201
this.ranges = arrayOf()
200202

@@ -219,7 +221,8 @@ open class BarEntry : Entry {
219221
* Calculates the sum across all values of the given stack.
220222
*/
221223
private fun calcSum(vals: FloatArray?): Float {
222-
if (vals == null) return 0f
224+
if (vals == null)
225+
return 0f
223226

224227
var sum = 0f
225228

MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ abstract class BaseDataSet<T : Entry>() : IDataSet<T> {
313313

314314
override fun getIndexInEntries(xIndex: Int): Int {
315315
for (i in 0..<entryCount) {
316-
if (xIndex.toFloat() == getEntryForIndex(i)!!.x) return i
316+
if (xIndex.toFloat() == getEntryForIndex(i)!!.x)
317+
return i
317318
}
318319

319320
return -1
@@ -345,9 +346,9 @@ abstract class BaseDataSet<T : Entry>() : IDataSet<T> {
345346

346347
override fun contains(entry: T): Boolean {
347348
for (i in 0..<entryCount) {
348-
if (getEntryForIndex(i) == entry) return true
349+
if (getEntryForIndex(i) == entry)
350+
return true
349351
}
350-
351352
return false
352353
}
353354

MPChartLib/src/main/java/com/github/mikephil/charting/data/CombinedData.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,13 @@ class CombinedData : BarLineScatterCandleBubbleData<IBarLineScatterCandleBubbleD
138138
* @return the entry that is highlighted
139139
*/
140140
override fun getEntryForHighlight(highlight: Highlight): Entry? {
141-
if (highlight.dataIndex >= this.allData.size) return null
141+
if (highlight.dataIndex >= this.allData.size)
142+
return null
142143

143144
val data: ChartData<*> = getDataByIndex(highlight.dataIndex)
144145

145-
if (highlight.dataSetIndex >= data.dataSetCount) return null
146+
if (highlight.dataSetIndex >= data.dataSetCount)
147+
return null
146148

147149
// The value of the highlighted entry could be NaN -
148150
// if we are not interested in highlighting a specific value.
@@ -162,11 +164,13 @@ class CombinedData : BarLineScatterCandleBubbleData<IBarLineScatterCandleBubbleD
162164
* @return dataset related to highlight
163165
*/
164166
fun getDataSetByHighlight(highlight: Highlight): IBarLineScatterCandleBubbleDataSet<out Entry>? {
165-
if (highlight.dataIndex >= this.allData.size) return null
167+
if (highlight.dataIndex >= this.allData.size)
168+
return null
166169

167170
val data = getDataByIndex(highlight.dataIndex)
168171

169-
if (highlight.dataSetIndex >= data.dataSetCount) return null
172+
if (highlight.dataSetIndex >= data.dataSetCount)
173+
return null
170174

171175
return data.dataSets!![highlight.dataSetIndex] as IBarLineScatterCandleBubbleDataSet<out Entry>?
172176
}

MPChartLib/src/main/java/com/github/mikephil/charting/data/DataSet.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ abstract class DataSet<T : Entry>(
213213
}
214214

215215
override fun removeEntry(entry: T): Boolean {
216-
if (mEntries == null) return false
216+
if (mEntries == null)
217+
return false
217218

218219
// remove the entry
219220
val removed = mEntries!!.remove(entry)

0 commit comments

Comments
 (0)