mirror of
https://github.com/dzeiocom/charts.git
synced 2025-04-22 02:32:10 +00:00
fix: crash while clicking on an empty chart (#50)
This commit is contained in:
parent
fe20f90654
commit
b2c51f7be1
@ -4,16 +4,13 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:7.4.0")
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
classpath("com.android.tools.build:gradle:7.4.1")
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.android.application") version "7.4.0" apply false
|
||||
id("com.android.library") version "7.4.0" apply false
|
||||
id("com.android.application") version "7.4.1" apply false
|
||||
id("com.android.library") version "7.4.1" apply false
|
||||
id("org.jetbrains.kotlin.android") version "1.7.0" apply false
|
||||
}
|
||||
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Sun Aug 07 22:38:24 CEST 2022
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-rc-1-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
@ -42,6 +42,9 @@ class ChartView @JvmOverloads constructor(context: Context?, attrs: AttributeSet
|
||||
var lastMovementX = 0.0
|
||||
var lastMovementY = 0f
|
||||
setOnChartMoved { movementX, movementY ->
|
||||
if (getDataset().isEmpty()) {
|
||||
return@setOnChartMoved
|
||||
}
|
||||
if (xAxis.scrollEnabled) {
|
||||
xAxis.x += (movementX - lastMovementX) * xAxis.getDataWidth() / width
|
||||
lastMovementX = movementX.toDouble()
|
||||
@ -59,6 +62,9 @@ class ChartView @JvmOverloads constructor(context: Context?, attrs: AttributeSet
|
||||
refresh()
|
||||
}
|
||||
setOnChartClick { x, y ->
|
||||
if (getDataset().isEmpty()) {
|
||||
return@setOnChartClick
|
||||
}
|
||||
// Log.d("Chart clicked at", "$x, $y")
|
||||
val dataset = series.map { it.getDisplayedEntries() }.reduce { acc, entries ->
|
||||
acc.addAll(entries)
|
||||
|
Loading…
x
Reference in New Issue
Block a user