Skip to content

Commit 2af1945

Browse files
zachareehannesa2
authored andcommitted
Second pass at Kotlin conversion
1 parent 7a42aae commit 2af1945

File tree

95 files changed

+1334
-1455
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1334
-1455
lines changed

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,17 @@ open class BarChart : BarLineChartBase<BarEntry, IBarDataSet, BarData>, BarDataP
6565
}
6666

6767
override fun calcMinMax() {
68-
if (mFitBars) {
69-
mXAxis?.calculate(mData!!.xMin - mData!!.barWidth / 2f, mData!!.xMax + mData!!.barWidth / 2f)
70-
} else {
71-
mXAxis?.calculate(mData!!.xMin, mData!!.xMax)
72-
}
68+
mData?.let { data ->
69+
if (mFitBars) {
70+
mXAxis.calculate(data.xMin - data.barWidth / 2f, data.xMax + data.barWidth / 2f)
71+
} else {
72+
mXAxis.calculate(data.xMin, data.xMax)
73+
}
7374

74-
// calculate axis range (min / max) according to provided data
75-
mAxisLeft?.calculate(mData!!.getYMin(AxisDependency.LEFT), mData!!.getYMax(AxisDependency.LEFT))
76-
mAxisRight?.calculate(mData!!.getYMin(AxisDependency.RIGHT), mData!!.getYMax(AxisDependency.RIGHT))
75+
// calculate axis range (min / max) according to provided data
76+
mAxisLeft.calculate(data.getYMin(AxisDependency.LEFT), data.getYMax(AxisDependency.LEFT))
77+
mAxisRight.calculate(data.getYMin(AxisDependency.RIGHT), data.getYMax(AxisDependency.RIGHT))
78+
}
7779
}
7880

7981
/**
@@ -86,7 +88,7 @@ open class BarChart : BarLineChartBase<BarEntry, IBarDataSet, BarData>, BarDataP
8688
*/
8789
override fun getHighlightByTouchPoint(x: Float, y: Float): Highlight? {
8890
if (mData == null) {
89-
Log.e(Chart.Companion.LOG_TAG, "Can't select by touch. No data set.")
91+
Log.e(LOG_TAG, "Can't select by touch. No data set.")
9092
return null
9193
} else {
9294
val h = highlighter?.getHighlight(x, y)
@@ -121,7 +123,7 @@ open class BarChart : BarLineChartBase<BarEntry, IBarDataSet, BarData>, BarDataP
121123
* @param barEntry
122124
*/
123125
open fun getBarBounds(barEntry: BarEntry, outputRect: RectF) {
124-
val set = mData!!.getDataSetForEntry(barEntry)
126+
val set = mData?.getDataSetForEntry(barEntry)
125127

126128
if (set == null) {
127129
outputRect.set(Float.Companion.MIN_VALUE, Float.Companion.MIN_VALUE, Float.Companion.MIN_VALUE, Float.Companion.MIN_VALUE)
@@ -131,7 +133,7 @@ open class BarChart : BarLineChartBase<BarEntry, IBarDataSet, BarData>, BarDataP
131133
val y = barEntry.y
132134
val x = barEntry.x
133135

134-
val barWidth = mData!!.barWidth
136+
val barWidth = mData?.barWidth ?: return
135137

136138
val left = x - barWidth / 2f
137139
val right = x + barWidth / 2f
@@ -257,12 +259,12 @@ open class BarChart : BarLineChartBase<BarEntry, IBarDataSet, BarData>, BarDataP
257259

258260
// Find the min and max index
259261
val yAxisValueFormatter = axisLeft.valueFormatter
260-
val minVal = yAxisValueFormatter!!.getFormattedValue(barData.yMin, null)
262+
val minVal = yAxisValueFormatter.getFormattedValue(barData.yMin, null)
261263
val maxVal = yAxisValueFormatter.getFormattedValue(barData.yMax, null)
262264

263265
// Data range...
264266
val xAxisValueFormatter = xAxis.valueFormatter
265-
val minRange = xAxisValueFormatter!!.getFormattedValue(barData.xMin, null)
267+
val minRange = xAxisValueFormatter.getFormattedValue(barData.xMin, null)
266268
val maxRange = xAxisValueFormatter.getFormattedValue(barData.xMax, null)
267269

268270
val entries = if (entryCount == 1) "entry" else "entries"

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

Lines changed: 143 additions & 153 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)