diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/LineChart.java b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/LineChart.java deleted file mode 100644 index db0536db27..0000000000 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/LineChart.java +++ /dev/null @@ -1,77 +0,0 @@ - -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.formatter.IAxisValueFormatter; -import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider; -import com.github.mikephil.charting.renderer.LineChartRenderer; - -import java.util.Locale; - -/** - * Chart that draws lines, surfaces, circles, ... - * - * @author Philipp Jahoda - */ -public class LineChart extends BarLineChartBase implements LineDataProvider { - - public LineChart(Context context) { - super(context); - } - - public LineChart(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public LineChart(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - @Override - protected void init() { - super.init(); - - mRenderer = new LineChartRenderer(this, mAnimator, mViewPortHandler); - } - - @Override - public LineData getLineData() { - return mData; - } - - @Override - protected void onDetachedFromWindow() { - // releases the bitmap in the renderer to avoid oom error - if (mRenderer != null && mRenderer instanceof LineChartRenderer) { - ((LineChartRenderer) mRenderer).releaseBitmap(); - } - super.onDetachedFromWindow(); - } - - @Override - public String getAccessibilityDescription() { - LineData lineData = getLineData(); - - int numberOfPoints = lineData.getEntryCount(); - - // Min and max values... - IAxisValueFormatter yAxisValueFormmater = getAxisLeft().getValueFormatter(); - String minVal = yAxisValueFormmater.getFormattedValue(lineData.getYMin(), null); - String maxVal = yAxisValueFormmater.getFormattedValue(lineData.getYMax(), null); - - // Data range... - IAxisValueFormatter xAxisValueFormatter = getXAxis().getValueFormatter(); - String minRange = xAxisValueFormatter.getFormattedValue(lineData.getXMin(), null); - String maxRange = xAxisValueFormatter.getFormattedValue(lineData.getXMax(), null); - - String entries = numberOfPoints == 1 ? "entry" : "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); - } -} diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/LineChart.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/LineChart.kt new file mode 100644 index 0000000000..86591cd467 --- /dev/null +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/LineChart.kt @@ -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, 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 + ) + } +}