@@ -11,7 +11,7 @@ import kotlin.Int
1111import kotlin.String
1212import kotlin.arrayOf
1313
14- open class BarDataSet (yVals : MutableList <BarEntry ?>, label : String? ) : BarLineScatterCandleBubbleDataSet<BarEntry? >(yVals, label), IBarDataSet {
14+ open class BarDataSet (yVals : MutableList <BarEntry ?>, label : String = " " ) : BarLineScatterCandleBubbleDataSet<BarEntry>(yVals, label), IBarDataSet {
1515 /* *
1616 * the maximum number of bars that are stacked upon each other, this value
1717 * is calculated from the Entries that are added to the DataSet
@@ -55,20 +55,22 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
5555 protected set
5656
5757 init {
58- mHighLightColor = Color .rgb(0 , 0 , 0 )
58+ highLightColor = Color .rgb(0 , 0 , 0 )
5959
6060 calcStackSize(yVals)
6161 calcEntryCountIncludingStacks(yVals)
6262 }
6363
64- override fun copy (): DataSet <BarEntry ?> {
64+ override fun copy (): DataSet <BarEntry ?>? {
6565 val entries: MutableList <BarEntry ?> = ArrayList ()
66- for (i in mEntries.indices) {
67- entries.add(mEntries[i]!! .copy())
66+ mEntries?.let {
67+ for (i in it.indices) {
68+ entries.add(it[i]!! .copy())
69+ }
6870 }
6971 val copied = BarDataSet (entries, label)
7072 copy(copied)
71- return copied
73+ return copied as DataSet < BarEntry ?> ?
7274 }
7375
7476 protected fun copy (barDataSet : BarDataSet ) {
@@ -85,14 +87,10 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
8587 }
8688
8789 override fun getFill (index : Int ): Fill ? {
88- return gradients!! .get( index % gradients!! .size)
90+ return gradients!! [ index % gradients!! .size]
8991 }
9092
91- /* *
92- * This method is deprecated.
93- * Use getFill(...) instead.
94- */
95- @Deprecated(" " )
93+ @Deprecated(" Use getFill(...) instead" )
9694 fun getGradient (index : Int ): Fill ? {
9795 return getFill(index)
9896 }
@@ -105,11 +103,7 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
105103 gradients!! .add(Fill (startColor, endColor))
106104 }
107105
108- /* *
109- * This method is deprecated.
110- * Use setFills(...) instead.
111- */
112- @Deprecated(" " )
106+ @Deprecated(" Use setFills(...) instead" )
113107 fun setGradientColors (gradientColors : MutableList <Fill ?>? ) {
114108 this .gradients = gradientColors
115109 }
@@ -137,7 +131,7 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
137131 }
138132
139133 /* *
140- * calculates the maximum stacksize that occurs in the Entries array of this
134+ * calculates the maximum stackSize that occurs in the Entries array of this
141135 * DataSet
142136 */
143137 private fun calcStackSize (yVals : MutableList <BarEntry ?>) {
@@ -151,13 +145,13 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
151145 override fun calcMinMax (e : BarEntry ? ) {
152146 if (e != null && ! Float .isNaN(e.y)) {
153147 if (e.yVals == null ) {
154- if (e.y < mYMin) mYMin = e.y
148+ if (e.y < yMin) yMin = e.y
155149
156- if (e.y > mYMax) mYMax = e.y
150+ if (e.y > yMax) yMax = e.y
157151 } else {
158- if (- e.negativeSum < mYMin) mYMin = - e.negativeSum
152+ if (- e.negativeSum < yMin) yMin = - e.negativeSum
159153
160- if (e.positiveSum > mYMax) mYMax = e.positiveSum
154+ if (e.positiveSum > yMax) yMax = e.positiveSum
161155 }
162156
163157 calcMinMaxX(e)
@@ -238,7 +232,7 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
238232 return mStackLabels
239233 }
240234
241- override fun getEntryIndex (entry : BarEntry ? ): Int {
235+ override fun getEntryIndex (entry : BarEntry ): Int {
242236 return this .getEntryIndex(entry)
243237 }
244238}
0 commit comments