fun prepareYLegend() { val yLegend = ArrayList<Float>() if (mRoundedYLegend) { val interval: Float = mDeltaY / (mYLegendCount - 1) val log10 = Math.log10(interval.toDouble()) var exp = Math.floor(log10).toInt() if (exp < 0) { exp = 0 } val tenPowExp: Double = POW_10.get(exp + 5) var multi = Math.round(interval / tenPowExp).toDouble() if (multi >= 1) { if (multi > 2 && multi <= 3) { multi = 3.0 } else if (multi > 3 && multi <= 5) { multi = 5.0 } else if (multi > 5 && multi < 10) { multi = 10.0 } } else { multi = 1.0 } val step = (multi * tenPowExp).toFloat() log(" log10 is $log10 interval is $interval mDeltaY is $mDeltaY tenPowExp is $tenPowExp multi is $multi mYChartMin is $mYChartMin step is $step") var `val` = 0f if (step >= 1f) { `val` = (mYChartMin / step) as Int * step } else { `val` = mYChartMin } while (`val` <= mDeltaY + step + mYChartMin) { yLegend.add(`val`) `val` = `val` + step } if (step >= 1f) { mYChartMin = (mYChartMin / step) as Int * step log("mYChartMin write --- step >= 1f -- and mYChartMin is $mYChartMin") } mDeltaY = `val` - step - mYChartMin mYChartMax = yLegend[yLegend.size() - 1] } else { val interval: Float = mDeltaY / (mYLegendCount - 1) yLegend.add(mYChartMin) var i = 1 if (!isDrawOutline) { i = 0 } while (i < mYLegendCount - 1) { yLegend.add(mYChartMin + i.toFloat() * interval) i++ } yLegend.add(mDeltaY + mYChartMin) } mYLegend = yLegend.toArray(arrayOfNulls<Float>(0)) }
setup the Y legend