Skip to content

Commit ccdc84c

Browse files
committed
Cosmetic
1 parent 697e86b commit ccdc84c

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

app/src/main/kotlin/info/appdev/chartexample/LineChartActivity.kt

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import info.appdev.chartexample.notimportant.DemoBase
2727
import timber.log.Timber
2828

2929
/**
30-
* Example of a heavily customized [LineChart] with limit lines, custom line shapes, etc.
30+
* Example of a heavily customized [com.github.mikephil.charting.charts.LineChart] with limit lines, custom line shapes, etc.
3131
*/
3232
class LineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelectedListener {
3333

@@ -80,13 +80,6 @@ class LineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelec
8080
// axis range
8181
binding.chart1.axisLeft.axisMaximum = 200f
8282
binding.chart1.axisLeft.axisMinimum = -50f
83-
val llXAxis10 = LimitLine(9f, "Index 10").apply {
84-
lineWidth = 4f
85-
enableDashedLine(10f, 10f, 0f)
86-
labelPosition = LimitLabelPosition.RIGHT_BOTTOM
87-
textSize = 10f
88-
typeface = tfRegular
89-
}
9083

9184
val limitLineUpper = LimitLine(150f, "Upper Limit").apply {
9285
lineWidth = 4f
@@ -161,16 +154,14 @@ class LineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelec
161154
}
162155

163156
R.id.actionToggleValues -> {
164-
binding.chart1.data?.dataSets?.forEach {
165-
val set = it as LineDataSet
157+
binding.chart1.data?.dataSets?.forEach { set ->
166158
set.setDrawValues(!set.isDrawValuesEnabled)
167159
}
168160
binding.chart1.invalidate()
169161
}
170162

171163
R.id.actionToggleIcons -> {
172-
binding.chart1.data?.dataSets?.forEach {
173-
val set = it as LineDataSet
164+
binding.chart1.data?.dataSets?.forEach { set ->
174165
set.setDrawIcons(!set.isDrawIconsEnabled)
175166
binding.chart1.invalidate()
176167
}
@@ -184,8 +175,7 @@ class LineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelec
184175
}
185176

186177
R.id.actionToggleFilled -> {
187-
binding.chart1.data?.dataSets?.forEach {
188-
val set = it as LineDataSet
178+
binding.chart1.data?.dataSets?.forEach { set ->
189179
set.setDrawFilled(!set.isDrawFilledEnabled)
190180
binding.chart1.invalidate()
191181
}
@@ -202,23 +192,32 @@ class LineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelec
202192
R.id.actionToggleCubic -> {
203193
binding.chart1.data?.dataSets?.forEach {
204194
val set = it as LineDataSet
205-
set.lineMode = if (set.lineMode == LineDataSet.Mode.CUBIC_BEZIER) LineDataSet.Mode.LINEAR else LineDataSet.Mode.CUBIC_BEZIER
195+
set.lineMode = if (set.lineMode == LineDataSet.Mode.CUBIC_BEZIER)
196+
LineDataSet.Mode.LINEAR
197+
else
198+
LineDataSet.Mode.CUBIC_BEZIER
206199
}
207200
binding.chart1.invalidate()
208201
}
209202

210203
R.id.actionToggleStepped -> {
211204
binding.chart1.data?.dataSets?.forEach {
212205
val set = it as LineDataSet
213-
set.lineMode = if (set.lineMode == LineDataSet.Mode.STEPPED) LineDataSet.Mode.LINEAR else LineDataSet.Mode.STEPPED
206+
set.lineMode = if (set.lineMode == LineDataSet.Mode.STEPPED)
207+
LineDataSet.Mode.LINEAR
208+
else
209+
LineDataSet.Mode.STEPPED
214210
}
215211
binding.chart1.invalidate()
216212
}
217213

218214
R.id.actionToggleHorizontalCubic -> {
219215
binding.chart1.data?.dataSets?.forEach {
220216
val set = it as LineDataSet
221-
set.lineMode = if (set.lineMode == LineDataSet.Mode.HORIZONTAL_BEZIER) LineDataSet.Mode.LINEAR else LineDataSet.Mode.HORIZONTAL_BEZIER
217+
set.lineMode = if (set.lineMode == LineDataSet.Mode.HORIZONTAL_BEZIER)
218+
LineDataSet.Mode.LINEAR
219+
else
220+
LineDataSet.Mode.HORIZONTAL_BEZIER
222221
}
223222
binding.chart1.invalidate()
224223
}
@@ -264,8 +263,8 @@ class LineChartActivity : DemoBase(), OnSeekBarChangeListener, OnChartValueSelec
264263
override fun onStopTrackingTouch(seekBar: SeekBar) {}
265264
override fun onValueSelected(entry: Entry, highlight: Highlight) {
266265
Timber.i(entry.toString())
267-
Timber.i("LOW HIGH low: " + binding.chart1.lowestVisibleX + ", high: " + binding.chart1.highestVisibleX)
268-
Timber.i("MIN MAX xMin: " + binding.chart1.xChartMin + ", xMax: " + binding.chart1.xChartMax + ", yMin: " + binding.chart1.yChartMin + ", yMax: " + binding.chart1.yChartMax)
266+
Timber.i("LOW HIGH low: ${binding.chart1.lowestVisibleX}, high: ${binding.chart1.highestVisibleX}")
267+
Timber.i("MIN MAX xMin: ${binding.chart1.xChartMin}, xMax: ${binding.chart1.xChartMax}, yMin: ${binding.chart1.yChartMin}, yMax: ${binding.chart1.yChartMax}")
269268
}
270269

271270
override fun onNothingSelected() = Unit

0 commit comments

Comments
 (0)