forked from PhilJay/MPAndroidChart
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from AppDevNext/KotlinConversionLineChart
Kotlin conversion LineChart
- Loading branch information
Showing
8 changed files
with
88 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 0 additions & 77 deletions
77
MPChartLib/src/main/java/com/github/mikephil/charting/charts/LineChart.java
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
MPChartLib/src/main/java/com/github/mikephil/charting/charts/LineChart.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.github.mikephil.charting.charts | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import com.github.mikephil.charting.data.LineData | ||
import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider | ||
import com.github.mikephil.charting.renderer.LineChartRenderer | ||
import java.util.Locale | ||
|
||
class LineChart : BarLineChartBase<LineData?>, LineDataProvider { | ||
|
||
constructor(context: Context?) : super(context) | ||
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) | ||
constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle) | ||
|
||
override fun init() { | ||
super.init() | ||
mRenderer = LineChartRenderer(this, mAnimator, mViewPortHandler) | ||
} | ||
|
||
override val lineData: LineData | ||
get() { | ||
mData?.let { | ||
return it | ||
} ?: run { | ||
return LineData() | ||
} | ||
} | ||
|
||
public override fun onDetachedFromWindow() { | ||
// releases the bitmap in the renderer to avoid oom error | ||
if (mRenderer != null && mRenderer is LineChartRenderer) { | ||
(mRenderer as LineChartRenderer).releaseBitmap() | ||
} | ||
super.onDetachedFromWindow() | ||
} | ||
|
||
override fun getAccessibilityDescription(): String { | ||
val lineData = lineData | ||
val numberOfPoints = lineData.entryCount | ||
|
||
// Min and max values... | ||
val yAxisValueFormatter = axisLeft.valueFormatter | ||
val minVal = yAxisValueFormatter.getFormattedValue(lineData.yMin, null) | ||
val maxVal = yAxisValueFormatter.getFormattedValue(lineData.yMax, null) | ||
|
||
// Data range... | ||
val xAxisValueFormatter = xAxis.valueFormatter | ||
val minRange = xAxisValueFormatter.getFormattedValue(lineData.xMin, null) | ||
val maxRange = xAxisValueFormatter.getFormattedValue(lineData.xMax, null) | ||
val entries = if (numberOfPoints == 1) "entry" else "entries" | ||
return String.format( | ||
Locale.getDefault(), "The line chart has %d %s. " + | ||
"The minimum value is %s and maximum value is %s." + | ||
"Data ranges from %s to %s.", | ||
numberOfPoints, entries, minVal, maxVal, minRange, maxRange | ||
) | ||
} | ||
} |
16 changes: 0 additions & 16 deletions
16
...hub/mikephil/charting/interfaces/dataprovider/BarLineScatterCandleBubbleDataProvider.java
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
...ithub/mikephil/charting/interfaces/dataprovider/BarLineScatterCandleBubbleDataProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.github.mikephil.charting.interfaces.dataprovider | ||
|
||
import com.github.mikephil.charting.components.YAxis.AxisDependency | ||
import com.github.mikephil.charting.data.BarLineScatterCandleBubbleData | ||
import com.github.mikephil.charting.utils.Transformer | ||
|
||
interface BarLineScatterCandleBubbleDataProvider : ChartInterface { | ||
fun getTransformer(axis: AxisDependency?): Transformer? | ||
fun isInverted(axis: AxisDependency?): Boolean | ||
val lowestVisibleX: Float | ||
val highestVisibleX: Float | ||
override fun getData(): BarLineScatterCandleBubbleData<*> | ||
} |
11 changes: 0 additions & 11 deletions
11
.../src/main/java/com/github/mikephil/charting/interfaces/dataprovider/LineDataProvider.java
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...ib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/LineDataProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.github.mikephil.charting.interfaces.dataprovider | ||
|
||
import com.github.mikephil.charting.components.YAxis | ||
import com.github.mikephil.charting.components.YAxis.AxisDependency | ||
import com.github.mikephil.charting.data.LineData | ||
|
||
interface LineDataProvider : BarLineScatterCandleBubbleDataProvider { | ||
val lineData: LineData | ||
fun getAxis(dependency: AxisDependency): YAxis? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters