Skip to content

Commit 7db6086

Browse files
committed
Working prototype
1 parent d7c4cbb commit 7db6086

File tree

82 files changed

+6154
-6933
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+6154
-6933
lines changed

MPChartLib/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ android {
2828
consumerProguardFiles 'proguard-lib.pro'
2929
}
3030
compileOptions {
31-
sourceCompatibility JavaVersion.VERSION_17
32-
targetCompatibility JavaVersion.VERSION_17
31+
sourceCompatibility JavaVersion.VERSION_21
32+
targetCompatibility JavaVersion.VERSION_21
33+
}
34+
kotlinOptions {
35+
jvmTarget = "21"
3336
}
3437
buildTypes {
3538
release {

MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarChart.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ open class BarChart : BarLineChartBase<BarEntry, IBarDataSet, BarData>, BarDataP
5353

5454
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)
5555

56-
override fun init() {
57-
super.init()
58-
56+
init {
5957
mRenderer = BarChartRenderer(this, mAnimator, viewPortHandler, mDrawRoundedBars, mRoundedBarRadius)
6058

6159
setHighlighter(BarHighlighter(this))
@@ -201,8 +199,8 @@ open class BarChart : BarLineChartBase<BarEntry, IBarDataSet, BarData>, BarDataP
201199
* @param dataSetIndex
202200
* @param dataIndex the index inside the stack - only relevant for stacked entries
203201
*/
204-
override fun highlightValue(x: Float, dataSetIndex: Int, dataIndex: Int) {
205-
highlightValue(Highlight(x, dataSetIndex, dataIndex), false)
202+
override fun highlightValue(x: Float, y: Float, dataSetIndex: Int, dataIndex: Int, callListener: Boolean) {
203+
super.highlightValue(Highlight(x, dataSetIndex, dataIndex), false)
206204
}
207205

208206
override val barData: BarData?
@@ -245,7 +243,7 @@ open class BarChart : BarLineChartBase<BarEntry, IBarDataSet, BarData>, BarDataP
245243
fun setRoundedBarRadius(mRoundedBarRadius: Float) {
246244
this.mRoundedBarRadius = mRoundedBarRadius
247245
this.mDrawRoundedBars = true
248-
init()
246+
mRenderer = BarChartRenderer(this, mAnimator, viewPortHandler, mDrawRoundedBars, mRoundedBarRadius)
249247
}
250248

251249
override val accessibilityDescription: String?

MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,7 @@ abstract class BarLineChartBase<E: Entry, D : IBarLineScatterCandleBubbleDataSet
252252

253253
constructor(context: Context) : super(context)
254254

255-
override fun init() {
256-
super.init()
257-
255+
init {
258256
setHighlighter(ChartHighlighter(this))
259257

260258
mChartTouchListener = BarLineChartTouchListener(this, viewPortHandler.matrixTouch, 3f)

MPChartLib/src/main/java/com/github/mikephil/charting/charts/BubbleChart.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ class BubbleChart : BarLineChartBase<BubbleEntry, IBubbleDataSet, BubbleData>, B
2323

2424
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)
2525

26-
override fun init() {
27-
super.init()
28-
26+
init {
2927
mRenderer = BubbleChartRenderer(this, mAnimator, viewPortHandler)
3028
}
3129

MPChartLib/src/main/java/com/github/mikephil/charting/charts/CandleStickChart.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ class CandleStickChart : BarLineChartBase<CandleEntry, ICandleDataSet, CandleDat
2020

2121
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)
2222

23-
override fun init() {
24-
super.init()
25-
23+
init {
2624
mRenderer = CandleStickChartRenderer(this, mAnimator, viewPortHandler)
2725

2826
xAxis.spaceMin = 0.5f

MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.kt

Lines changed: 8 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,6 @@ abstract class Chart<E: Entry, D: IDataSet<E>, T : ChartData<E, D>> : ViewGroup,
6969
*/
7070
var isLogEnabled: Boolean = false
7171

72-
@Suppress("UsePropertyAccessSyntax")
73-
override val width: Int
74-
get() = getWidth()
75-
76-
@Suppress("UsePropertyAccessSyntax")
77-
override val height: Int
78-
get() = getHeight()
79-
8072
/**
8173
* object that holds all data that was originally set for the chart, before
8274
* it was modified or any filtering algorithms had been applied
@@ -235,27 +227,29 @@ abstract class Chart<E: Entry, D: IDataSet<E>, T : ChartData<E, D>> : ViewGroup,
235227
* default constructor for initialization in code
236228
*/
237229
constructor(context: Context) : super(context) {
238-
init()
239230
}
240231

241232
/**
242233
* constructor for initialization in xml
243234
*/
244235
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
245-
init()
246236
}
247237

248238
/**
249239
* even more awesome constructor
250240
*/
251241
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle) {
252-
init()
253242
}
254243

244+
/**
245+
* The maximum distance in dp away from an entry causing it to highlight.
246+
*/
247+
protected var mMaxHighlightDistance: Float = 0f
248+
255249
/**
256250
* initialize all paints and stuff
257251
*/
258-
protected open fun init() {
252+
init {
259253
setWillNotDraw(false)
260254

261255
// initialize the utils
@@ -476,11 +470,6 @@ abstract class Chart<E: Entry, D: IDataSet<E>, T : ChartData<E, D>> : ViewGroup,
476470
var highlighted: Array<Highlight>? = null
477471
protected set
478472

479-
/**
480-
* The maximum distance in dp away from an entry causing it to highlight.
481-
*/
482-
protected var mMaxHighlightDistance: Float = 0f
483-
484473
override val maxHighlightDistance: Float
485474
get() = mMaxHighlightDistance
486475

@@ -535,52 +524,6 @@ abstract class Chart<E: Entry, D: IDataSet<E>, T : ChartData<E, D>> : ViewGroup,
535524
highlightValues(highs.toTypedArray<Highlight>())
536525
}
537526

538-
/**
539-
* Highlights any y-value at the given x-value in the given DataSet.
540-
* Provide -1 as the dataSetIndex to undo all highlighting.
541-
* This method will call the listener.
542-
* @param x The x-value to highlight
543-
* @param dataSetIndex The dataset index to search in
544-
* @param dataIndex The data index to search in (only used in CombinedChartView currently)
545-
*/
546-
open fun highlightValue(x: Float, dataSetIndex: Int, dataIndex: Int) {
547-
highlightValue(x, dataSetIndex, dataIndex, true)
548-
}
549-
550-
/**
551-
* Highlights any y-value at the given x-value in the given DataSet.
552-
* Provide -1 as the dataSetIndex to undo all highlighting.
553-
*
554-
* @param x The x-value to highlight
555-
* @param dataSetIndex The dataset index to search in
556-
* @param dataIndex The data index to search in (only used in CombinedChartView currently)
557-
* @param callListener Should the listener be called for this change
558-
*/
559-
/**
560-
* Highlights any y-value at the given x-value in the given DataSet.
561-
* Provide -1 as the dataSetIndex to undo all highlighting.
562-
* This method will call the listener.
563-
*
564-
* @param x The x-value to highlight
565-
* @param dataSetIndex The dataset index to search in
566-
*/
567-
@JvmOverloads
568-
fun highlightValue(x: Float, dataSetIndex: Int, dataIndex: Int = -1, callListener: Boolean = true) {
569-
highlightValue(x, Float.Companion.NaN, dataSetIndex, dataIndex, callListener)
570-
}
571-
572-
/**
573-
* Highlights any y-value at the given x-value in the given DataSet.
574-
* Provide -1 as the dataSetIndex to undo all highlighting.
575-
*
576-
* @param x The x-value to highlight
577-
* @param dataSetIndex The dataset index to search in
578-
* @param callListener Should the listener be called for this change
579-
*/
580-
fun highlightValue(x: Float, dataSetIndex: Int, callListener: Boolean) {
581-
highlightValue(x, Float.Companion.NaN, dataSetIndex, -1, callListener)
582-
}
583-
584527
/**
585528
* Highlights any y-value at the given x-value in the given DataSet.
586529
* Provide -1 as the dataSetIndex to undo all highlighting.
@@ -611,7 +554,7 @@ abstract class Chart<E: Entry, D: IDataSet<E>, T : ChartData<E, D>> : ViewGroup,
611554
* @param dataIndex The data index to search in (only used in CombinedChartView currently)
612555
*/
613556
@JvmOverloads
614-
fun highlightValue(x: Float, y: Float, dataSetIndex: Int, dataIndex: Int = -1, callListener: Boolean = true) {
557+
open fun highlightValue(x: Float, y: Float = Float.NaN, dataSetIndex: Int = -1, dataIndex: Int = -1, callListener: Boolean = true) {
615558
if (dataSetIndex < 0 || mData.let { it != null && dataSetIndex >= it.dataSetCount }) {
616559
highlightValue(null, callListener)
617560
} else {
@@ -1153,7 +1096,7 @@ abstract class Chart<E: Entry, D: IDataSet<E>, T : ChartData<E, D>> : ViewGroup,
11531096
/**
11541097
* Returns the ChartData object that has been set for the chart.
11551098
*/
1156-
override val data: ChartData<E, D>?
1099+
override val data: T?
11571100
get() = mData
11581101

11591102
var renderer: DataRenderer?

MPChartLib/src/main/java/com/github/mikephil/charting/charts/CombinedChart.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ open class CombinedChart : BarLineChartBase<Entry, IBarLineScatterCandleBubbleDa
6161

6262
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)
6363

64-
override fun init() {
65-
super.init()
66-
64+
init {
6765
setHighlighter(CombinedHighlighter(this, this))
6866

6967
// Old default behaviour

MPChartLib/src/main/java/com/github/mikephil/charting/charts/HorizontalBarChart.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ class HorizontalBarChart : BarChart {
3636

3737
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)
3838

39-
override fun init() {
39+
init {
4040
viewPortHandler = HorizontalViewPortHandler()
4141

42-
super.init()
43-
4442
mLeftAxisTransformer = TransformerHorizontalBarChart(viewPortHandler)
4543
mRightAxisTransformer = TransformerHorizontalBarChart(viewPortHandler)
4644

MPChartLib/src/main/java/com/github/mikephil/charting/charts/LineChart.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ open class LineChart : BarLineChartBase<Entry, ILineDataSet, LineData>, LineData
1414
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
1515
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)
1616

17-
override fun init() {
18-
super.init()
17+
init {
1918
mRenderer = LineChartRenderer(this, mAnimator, viewPortHandler)
2019
}
2120

MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieChart.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,7 @@ open class PieChart : PieRadarChartBase<PieEntry, IPieDataSet, PieData> {
202202

203203
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)
204204

205-
override fun init() {
206-
super.init()
207-
205+
init {
208206
mRenderer = PieChartRenderer(this, mAnimator, viewPortHandler)
209207

210208
highlighter = PieHighlighter(this)

0 commit comments

Comments
 (0)