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.
- Loading branch information
Showing
2 changed files
with
54 additions
and
77 deletions.
There are no files selected for viewing
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.
54 changes: 54 additions & 0 deletions
54
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,54 @@ | ||
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 fun getLineData(): LineData { | ||
return mData!! | ||
} | ||
|
||
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 | ||
) | ||
} | ||
} |