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()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("com.android.tools.build:gradle:7.4.0")
|
classpath("com.android.tools.build:gradle:7.4.1")
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
|
||||||
// in the individual module build.gradle files
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application") version "7.4.0" apply false
|
id("com.android.application") version "7.4.1" apply false
|
||||||
id("com.android.library") version "7.4.0" apply false
|
id("com.android.library") version "7.4.1" apply false
|
||||||
id("org.jetbrains.kotlin.android") version "1.7.0" 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
|
#Sun Aug 07 22:38:24 CEST 2022
|
||||||
distributionBase=GRADLE_USER_HOME
|
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
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
@ -42,6 +42,9 @@ class ChartView @JvmOverloads constructor(context: Context?, attrs: AttributeSet
|
|||||||
var lastMovementX = 0.0
|
var lastMovementX = 0.0
|
||||||
var lastMovementY = 0f
|
var lastMovementY = 0f
|
||||||
setOnChartMoved { movementX, movementY ->
|
setOnChartMoved { movementX, movementY ->
|
||||||
|
if (getDataset().isEmpty()) {
|
||||||
|
return@setOnChartMoved
|
||||||
|
}
|
||||||
if (xAxis.scrollEnabled) {
|
if (xAxis.scrollEnabled) {
|
||||||
xAxis.x += (movementX - lastMovementX) * xAxis.getDataWidth() / width
|
xAxis.x += (movementX - lastMovementX) * xAxis.getDataWidth() / width
|
||||||
lastMovementX = movementX.toDouble()
|
lastMovementX = movementX.toDouble()
|
||||||
@ -59,6 +62,9 @@ class ChartView @JvmOverloads constructor(context: Context?, attrs: AttributeSet
|
|||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
setOnChartClick { x, y ->
|
setOnChartClick { x, y ->
|
||||||
|
if (getDataset().isEmpty()) {
|
||||||
|
return@setOnChartClick
|
||||||
|
}
|
||||||
// Log.d("Chart clicked at", "$x, $y")
|
// Log.d("Chart clicked at", "$x, $y")
|
||||||
val dataset = series.map { it.getDisplayedEntries() }.reduce { acc, entries ->
|
val dataset = series.map { it.getDisplayedEntries() }.reduce { acc, entries ->
|
||||||
acc.addAll(entries)
|
acc.addAll(entries)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user