Skip to content

Commit 7028a02

Browse files
committed
Kotlin BarLineScatterCandleBubbleDataSet
1 parent a4abdcf commit 7028a02

File tree

5 files changed

+32
-64
lines changed

5 files changed

+32
-64
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/data/BarDataSet.kt

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import kotlin.Int
1111
import kotlin.String
1212
import 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,13 +55,13 @@ 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(): BarDataSet {
6565
val entries: MutableList<BarEntry?> = ArrayList()
6666
for (i in mEntries.indices) {
6767
entries.add(mEntries[i]!!.copy())
@@ -85,14 +85,10 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
8585
}
8686

8787
override fun getFill(index: Int): Fill? {
88-
return gradients!!.get(index % gradients!!.size)
88+
return gradients!![index % gradients!!.size]
8989
}
9090

91-
/**
92-
* This method is deprecated.
93-
* Use getFill(...) instead.
94-
*/
95-
@Deprecated("")
91+
@Deprecated("Use getFill(...) instead")
9692
fun getGradient(index: Int): Fill? {
9793
return getFill(index)
9894
}
@@ -105,11 +101,7 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
105101
gradients!!.add(Fill(startColor, endColor))
106102
}
107103

108-
/**
109-
* This method is deprecated.
110-
* Use setFills(...) instead.
111-
*/
112-
@Deprecated("")
104+
@Deprecated("Use setFills(...) instead")
113105
fun setGradientColors(gradientColors: MutableList<Fill?>?) {
114106
this.gradients = gradientColors
115107
}
@@ -137,7 +129,7 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
137129
}
138130

139131
/**
140-
* calculates the maximum stacksize that occurs in the Entries array of this
132+
* calculates the maximum stackSize that occurs in the Entries array of this
141133
* DataSet
142134
*/
143135
private fun calcStackSize(yVals: MutableList<BarEntry?>) {
@@ -238,7 +230,7 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
238230
return mStackLabels
239231
}
240232

241-
override fun getEntryIndex(entry: BarEntry?): Int {
233+
override fun getEntryIndex(entry: BarEntry): Int {
242234
return this.getEntryIndex(entry)
243235
}
244236
}

MPChartLib/src/main/java/com/github/mikephil/charting/data/BarLineScatterCandleBubbleDataSet.java

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.github.mikephil.charting.data
2+
3+
import android.graphics.Color
4+
import com.github.mikephil.charting.interfaces.datasets.IBarLineScatterCandleBubbleDataSet
5+
6+
/**
7+
* Baseclass of all DataSets for Bar-, Line-, Scatter- and CandleStickChart.
8+
*/
9+
abstract class BarLineScatterCandleBubbleDataSet<T : Entry>(yVals: MutableList<T?>?, label: String?) :
10+
DataSet<T>(yVals, label), IBarLineScatterCandleBubbleDataSet<T> {
11+
/**
12+
* Sets the color that is used for drawing the highlight indicators. Dont
13+
* forget to resolve the color using getResources().getColor(...) or
14+
* Color.rgb(...).
15+
*/
16+
override var highLightColor: Int = Color.rgb(255, 187, 115)
17+
18+
protected fun copy(barLineScatterCandleBubbleDataSet: BarLineScatterCandleBubbleDataSet<*>) {
19+
super.copy((barLineScatterCandleBubbleDataSet as BaseDataSet<*>?)!!)
20+
barLineScatterCandleBubbleDataSet.highLightColor = this.highLightColor
21+
}
22+
}

MPChartLib/src/main/java/com/github/mikephil/charting/data/CandleDataSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected void copy(CandleDataSet candleDataSet) {
9494
candleDataSet.mShowCandleBar = mShowCandleBar;
9595
candleDataSet.mBarSpace = mBarSpace;
9696
candleDataSet.mShadowColorSameAsCandle = mShadowColorSameAsCandle;
97-
candleDataSet.mHighLightColor = mHighLightColor;
97+
candleDataSet.highLightColor = highLightColor;
9898
candleDataSet.mIncreasingPaintStyle = mIncreasingPaintStyle;
9999
candleDataSet.mDecreasingPaintStyle = mDecreasingPaintStyle;
100100
candleDataSet.mNeutralColor = mNeutralColor;

MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IDataSet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ interface IDataSet<T : Entry> {
107107
* Returns the position of the provided entry in the DataSets Entry array.
108108
* Returns -1 if doesn't exist.
109109
*/
110-
fun getEntryIndex(e: T): Int
110+
fun getEntryIndex(entry: T): Int
111111

112112
/**
113113
* This method returns the actual

0 commit comments

Comments
 (0)