diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/components/Legend.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/components/Legend.kt index 4b0d4b9f5f..066c92832f 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/components/Legend.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/components/Legend.kt @@ -6,6 +6,7 @@ import com.github.mikephil.charting.utils.ColorTemplate import com.github.mikephil.charting.utils.FSize import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler +import com.github.mikephil.charting.utils.calcTextSize import com.github.mikephil.charting.utils.convertDpToPixel import java.lang.Float import kotlin.Array @@ -463,7 +464,7 @@ class Legend() : ComponentBase() { // grouped forms have null labels if (label != null) { - calculatedLabelSizes.add(Utils.calcTextSize(labelpaint, label)) + calculatedLabelSizes.add(labelpaint.calcTextSize(label)) requiredWidth += if (drawingForm) formToTextSpace + formSize else 0f requiredWidth += calculatedLabelSizes.get(i)!!.width } else { diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.kt index b8e8812bcb..b26607898e 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseDataSet.kt @@ -11,8 +11,8 @@ import com.github.mikephil.charting.formatter.IValueFormatter import com.github.mikephil.charting.interfaces.datasets.IDataSet import com.github.mikephil.charting.utils.ColorTemplate import com.github.mikephil.charting.utils.MPPointF -import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.convertDpToPixel +import com.github.mikephil.charting.utils.getDefaultValueFormatter /** * This is the base dataset of all DataSets. It's purpose is to implement critical methods @@ -255,7 +255,7 @@ abstract class BaseDataSet() : IDataSet { override var valueFormatter: IValueFormatter get() = if (needsFormatter()) - Utils.getDefaultValueFormatter() + getDefaultValueFormatter() else mValueFormatter!! set(value) { diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/RadarHighlighter.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/RadarHighlighter.kt index 4f6c60b71d..e60ceb5b7c 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/RadarHighlighter.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/highlight/RadarHighlighter.kt @@ -3,7 +3,7 @@ package com.github.mikephil.charting.highlight import com.github.mikephil.charting.charts.RadarChart import com.github.mikephil.charting.data.Entry import com.github.mikephil.charting.utils.MPPointF -import com.github.mikephil.charting.utils.Utils +import com.github.mikephil.charting.utils.getPosition import kotlin.math.abs open class RadarHighlighter(chart: RadarChart) : PieRadarHighlighter(chart) { @@ -42,7 +42,7 @@ open class RadarHighlighter(chart: RadarChart) : PieRadarHighlighter val sliceAngle = chartPieRadar.sliceAngle val factor = chartPieRadar.factor - val pOut = MPPointF.getInstance(0f, 0f) + var pOut: MPPointF for (i in 0.. val y = (entry!!.y - chartPieRadar.yChartMin) - Utils.getPosition( - chartPieRadar.centerOffsets, y * factor * phaseY, - sliceAngle * index * phaseX + chartPieRadar.rotationAngle, pOut + pOut = getPosition( + y * factor * phaseY, + sliceAngle * index * phaseX + chartPieRadar.rotationAngle ) mHighlightBuffer.add(Highlight(index.toFloat(), entry.y, pOut.x, pOut.y, i, dataSet.axisDependency)) diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.kt index 5c38011efc..feb215b9e8 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.kt @@ -69,8 +69,7 @@ open class HorizontalBarChartRenderer( var i = 0 val count = min((ceil(((dataSet.entryCount).toFloat() * phaseX).toDouble())).toInt().toDouble(), dataSet.entryCount.toDouble()).toInt() while (i < count) { - val barEntry = dataSet.getEntryForIndex(i) - barEntry?.let { + dataSet.getEntryForIndex(i)?.let { x = it.x mBarShadowRectBuffer.top = x - barWidthHalf diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/RadarChartRenderer.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/RadarChartRenderer.kt index de5becd1aa..d5ca27d66e 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/RadarChartRenderer.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/RadarChartRenderer.kt @@ -14,6 +14,7 @@ import com.github.mikephil.charting.utils.MPPointF import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler import com.github.mikephil.charting.utils.convertDpToPixel +import com.github.mikephil.charting.utils.getPosition open class RadarChartRenderer( protected var chart: RadarChart, animator: ChartAnimator, @@ -123,7 +124,7 @@ open class RadarChartRenderer( val factor = chart.factor val center = chart.centerOffsets - val pOut = MPPointF.getInstance(0f, 0f) + var pOut = MPPointF.getInstance(0f, 0f) val pIcon = MPPointF.getInstance(0f, 0f) val yOffset = 5f.convertDpToPixel() @@ -149,12 +150,10 @@ open class RadarChartRenderer( for (j in 0.. - Utils.getPosition( - center, + pOut = getPosition( (entry.y - chart.yChartMin) * factor * phaseY, - sliceAngle * j * phaseX + chart.rotationAngle, - pOut - ) + sliceAngle * j * phaseX + chart.rotationAngle + ) if (dataSet.isDrawValues) { drawValue( diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRenderer.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRenderer.kt index d662da7522..c046e43960 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRenderer.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRenderer.kt @@ -18,6 +18,7 @@ import com.github.mikephil.charting.utils.MPPointF import com.github.mikephil.charting.utils.Transformer import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler +import com.github.mikephil.charting.utils.calcTextSize import com.github.mikephil.charting.utils.convertDpToPixel import kotlin.math.roundToInt @@ -69,7 +70,7 @@ open class XAxisRenderer( paintAxisLabels.typeface = xAxis.typeface paintAxisLabels.textSize = xAxis.textSize - val labelSize = Utils.calcTextSize(paintAxisLabels, longest) + val labelSize = paintAxisLabels.calcTextSize(longest) val labelWidth = labelSize.width val labelHeight = Utils.calcTextHeight(paintAxisLabels, "Q").toFloat() diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererHorizontalBarChart.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererHorizontalBarChart.kt index cd29bcee04..1a2a5c0ef6 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererHorizontalBarChart.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererHorizontalBarChart.kt @@ -15,6 +15,7 @@ import com.github.mikephil.charting.utils.MPPointF import com.github.mikephil.charting.utils.Transformer import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler +import com.github.mikephil.charting.utils.calcTextSize import com.github.mikephil.charting.utils.convertDpToPixel import kotlin.math.roundToInt @@ -57,7 +58,7 @@ open class XAxisRendererHorizontalBarChart( val longest = xAxis.longestLabel - val labelSize = Utils.calcTextSize(paintAxisLabels, longest) + val labelSize = paintAxisLabels.calcTextSize(longest) val labelWidth = (labelSize.width + xAxis.xOffset * 3.5f).toInt().toFloat() val labelHeight = labelSize.height diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererRadarChart.kt b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererRadarChart.kt index 2760b91483..63e751142c 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererRadarChart.kt +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/XAxisRendererRadarChart.kt @@ -4,8 +4,8 @@ import android.graphics.Canvas import com.github.mikephil.charting.charts.RadarChart import com.github.mikephil.charting.components.XAxis import com.github.mikephil.charting.utils.MPPointF -import com.github.mikephil.charting.utils.Utils import com.github.mikephil.charting.utils.ViewPortHandler +import com.github.mikephil.charting.utils.getPosition class XAxisRendererRadarChart(viewPortHandler: ViewPortHandler, xAxis: XAxis, private val chart: RadarChart) : XAxisRenderer(viewPortHandler, xAxis, null) { override fun renderAxisLabels(canvas: Canvas) { @@ -26,15 +26,15 @@ class XAxisRendererRadarChart(viewPortHandler: ViewPortHandler, xAxis: XAxis, pr val factor = chart.factor val center = chart.centerOffsets - val pOut = MPPointF.getInstance(0f, 0f) + var pOut = MPPointF.getInstance(0f, 0f) chart.getData()!!.maxEntryCountSet?.let { maxEntryCountSet -> for (i in 0.. for (j in 0..