Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import kotlin.Int
import kotlin.String
import kotlin.arrayOf

open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineScatterCandleBubbleDataSet<BarEntry?>(yVals, label), IBarDataSet {
open class BarDataSet(yVals: MutableList<BarEntry?>, label: String = "") : BarLineScatterCandleBubbleDataSet<BarEntry>(yVals, label), IBarDataSet {
/**
* the maximum number of bars that are stacked upon each other, this value
* is calculated from the Entries that are added to the DataSet
Expand Down Expand Up @@ -55,20 +55,22 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
protected set

init {
mHighLightColor = Color.rgb(0, 0, 0)
highLightColor = Color.rgb(0, 0, 0)

calcStackSize(yVals)
calcEntryCountIncludingStacks(yVals)
}

override fun copy(): DataSet<BarEntry?> {
override fun copy(): DataSet<BarEntry?>? {
val entries: MutableList<BarEntry?> = ArrayList()
for (i in mEntries.indices) {
entries.add(mEntries[i]!!.copy())
mEntries?.let {
for (i in it.indices) {
entries.add(it[i]!!.copy())
}
}
val copied = BarDataSet(entries, label)
copy(copied)
return copied
return copied as DataSet<BarEntry?>?
}

protected fun copy(barDataSet: BarDataSet) {
Expand All @@ -85,14 +87,10 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
}

override fun getFill(index: Int): Fill? {
return gradients!!.get(index % gradients!!.size)
return gradients!![index % gradients!!.size]
}

/**
* This method is deprecated.
* Use getFill(...) instead.
*/
@Deprecated("")
@Deprecated("Use getFill(...) instead")
fun getGradient(index: Int): Fill? {
return getFill(index)
}
Expand All @@ -105,11 +103,7 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
gradients!!.add(Fill(startColor, endColor))
}

/**
* This method is deprecated.
* Use setFills(...) instead.
*/
@Deprecated("")
@Deprecated("Use setFills(...) instead")
fun setGradientColors(gradientColors: MutableList<Fill?>?) {
this.gradients = gradientColors
}
Expand Down Expand Up @@ -137,7 +131,7 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
}

/**
* calculates the maximum stacksize that occurs in the Entries array of this
* calculates the maximum stackSize that occurs in the Entries array of this
* DataSet
*/
private fun calcStackSize(yVals: MutableList<BarEntry?>) {
Expand All @@ -151,13 +145,13 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
override fun calcMinMax(e: BarEntry?) {
if (e != null && !Float.isNaN(e.y)) {
if (e.yVals == null) {
if (e.y < mYMin) mYMin = e.y
if (e.y < yMin) yMin = e.y

if (e.y > mYMax) mYMax = e.y
if (e.y > yMax) yMax = e.y
} else {
if (-e.negativeSum < mYMin) mYMin = -e.negativeSum
if (-e.negativeSum < yMin) yMin = -e.negativeSum

if (e.positiveSum > mYMax) mYMax = e.positiveSum
if (e.positiveSum > yMax) yMax = e.positiveSum
}

calcMinMaxX(e)
Expand Down Expand Up @@ -238,7 +232,7 @@ open class BarDataSet(yVals: MutableList<BarEntry?>, label: String?) : BarLineSc
return mStackLabels
}

override fun getEntryIndex(entry: BarEntry?): Int {
override fun getEntryIndex(entry: BarEntry): Int {
return this.getEntryIndex(entry)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.github.mikephil.charting.data

import android.graphics.Color
import com.github.mikephil.charting.interfaces.datasets.IBarLineScatterCandleBubbleDataSet

/**
* Baseclass of all DataSets for Bar-, Line-, Scatter- and CandleStickChart.
*/
abstract class BarLineScatterCandleBubbleDataSet<T : Entry?>(yVals: MutableList<T?>?, label: String = "") :
DataSet<T>(yVals, label), IBarLineScatterCandleBubbleDataSet<T?> {
/**
* Sets the color that is used for drawing the highlight indicators. Dont
* forget to resolve the color using getResources().getColor(...) or
* Color.rgb(...).
*/
override var highLightColor: Int = Color.rgb(255, 187, 115)

protected fun copy(barLineScatterCandleBubbleDataSet: BarLineScatterCandleBubbleDataSet<*>) {
super.copy((barLineScatterCandleBubbleDataSet as BaseDataSet<*>?)!!)
barLineScatterCandleBubbleDataSet.highLightColor = this.highLightColor
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import com.github.mikephil.charting.utils.convertDpToPixel
* This is the base dataset of all DataSets. It's purpose is to implement critical methods
* provided by the IDataSet interface.
*/
abstract class BaseDataSet<T : Entry>() : IDataSet<T> {
abstract class BaseDataSet<T : Entry?>() : IDataSet<T> {
/**
* List representing all colors that are used for this DataSet
*/
Expand Down Expand Up @@ -236,12 +236,10 @@ abstract class BaseDataSet<T : Entry>() : IDataSet<T> {
mColors.clear()
}

override var label: String?
override var label: String
get() = mLabel
set(value) {
if (value != null) {
mLabel = value
}
mLabel = value
}
override var axisDependency: AxisDependency
get() = mAxisDependency
Expand Down
Loading
Loading