Skip to content

Commit 143b3c3

Browse files
committed
Prevent graph from restarting when setting duplicate data
1 parent e0bd1ff commit 143b3c3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Classes/ScrollableGraphView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,12 @@ import UIKit
443443
// ######################
444444

445445
public func setData(data: [Double], withLabels labels: [String]) {
446+
447+
// If we are setting exactly the same data and labels, there's no need to re-init everything.
448+
guard self.data != data && self.labels != labels else {
449+
return
450+
}
451+
446452
self.dataNeedsReloading = true
447453
self.data = data
448454
self.labels = labels

0 commit comments

Comments
 (0)