|
| 1 | +package com.github.mikephil.charting.data |
| 2 | + |
| 3 | +import android.graphics.Color |
| 4 | +import android.graphics.drawable.Drawable |
| 5 | +import com.github.mikephil.charting.interfaces.datasets.ILineRadarDataSet |
| 6 | +import com.github.mikephil.charting.utils.convertDpToPixel |
| 7 | + |
| 8 | +/** |
| 9 | + * Base dataset for line and radar DataSets. |
| 10 | + */ |
| 11 | +abstract class LineRadarDataSet<T : Entry?>(yVals: MutableList<T?>?, label: String) : LineScatterCandleRadarDataSet<T?>(yVals, label), ILineRadarDataSet<T?> { |
| 12 | + // TODO: Move to using `Fill` class |
| 13 | + /** |
| 14 | + * the color that is used for filling the line surface |
| 15 | + */ |
| 16 | + private var mFillColor = Color.rgb(140, 234, 255) |
| 17 | + |
| 18 | + /** |
| 19 | + * Sets the drawable to be used to fill the area below the line. |
| 20 | + */ |
| 21 | + /** |
| 22 | + * the drawable to be used for filling the line surface |
| 23 | + */ |
| 24 | + override var fillDrawable: Drawable? = null |
| 25 | + |
| 26 | + /** |
| 27 | + * sets the alpha value (transparency) that is used for filling the line |
| 28 | + * surface (0-255), default: 85 |
| 29 | + */ |
| 30 | + /** |
| 31 | + * transparency used for filling line surface |
| 32 | + */ |
| 33 | + override var fillAlpha: Int = 85 |
| 34 | + |
| 35 | + /** |
| 36 | + * the width of the drawn data lines |
| 37 | + */ |
| 38 | + private var mLineWidth = 2.5f |
| 39 | + |
| 40 | + /** |
| 41 | + * if true, the data will also be drawn filled |
| 42 | + */ |
| 43 | + override var isDrawFilledEnabled: Boolean = false |
| 44 | + |
| 45 | + override var fillColor: Int |
| 46 | + get() = mFillColor |
| 47 | + /** |
| 48 | + * Sets the color that is used for filling the area below the line. |
| 49 | + * Resets an eventually set "fillDrawable". |
| 50 | + */ |
| 51 | + set(color) { |
| 52 | + mFillColor = color |
| 53 | + this.fillDrawable = null |
| 54 | + } |
| 55 | + |
| 56 | + override var lineWidth: Float |
| 57 | + get() = mLineWidth |
| 58 | + /** |
| 59 | + * set the line width of the chart (min = 0.2f, max = 10f); default 1f NOTE: |
| 60 | + * thinner line == better performance, thicker line == worse performance |
| 61 | + */ |
| 62 | + set(width) { |
| 63 | + var width = width |
| 64 | + if (width < 0.0f) width = 0.0f |
| 65 | + if (width > 10.0f) width = 10.0f |
| 66 | + mLineWidth = width.convertDpToPixel() |
| 67 | + } |
| 68 | + |
| 69 | + override fun setDrawFilled(enabled: Boolean) { |
| 70 | + this.isDrawFilledEnabled = enabled |
| 71 | + } |
| 72 | + |
| 73 | + protected fun copy(lineRadarDataSet: LineRadarDataSet<*>) { |
| 74 | + super.copy((lineRadarDataSet as BaseDataSet<*>?)!!) |
| 75 | + lineRadarDataSet.isDrawFilledEnabled = this.isDrawFilledEnabled |
| 76 | + lineRadarDataSet.fillAlpha = this.fillAlpha |
| 77 | + lineRadarDataSet.mFillColor = mFillColor |
| 78 | + lineRadarDataSet.fillDrawable = this.fillDrawable |
| 79 | + lineRadarDataSet.mLineWidth = mLineWidth |
| 80 | + } |
| 81 | +} |
0 commit comments