mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Chart fixes
This commit is contained in:
parent
28e7596534
commit
14510b11bb
8 changed files with 21 additions and 33 deletions
|
|
@ -170,9 +170,6 @@ class GeneralChartComponentController: ChartThemeContainer {
|
|||
}
|
||||
|
||||
func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||
guard !ignoreInteraction else {
|
||||
return
|
||||
}
|
||||
if manual && !isChartInteracting && detailsVisible {
|
||||
self.hideDetailsView(animated: true)
|
||||
ignoreInteraction = true
|
||||
|
|
|
|||
|
|
@ -122,9 +122,6 @@ public class GeneralLinesChartController: BaseLinesChartController {
|
|||
}
|
||||
|
||||
public override func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||
guard !ignoreInteraction else {
|
||||
return
|
||||
}
|
||||
if manual && !isChartInteracting && !self.verticalLineRenderer.values.isEmpty {
|
||||
self.cancelChartInteraction()
|
||||
ignoreInteraction = true
|
||||
|
|
@ -147,7 +144,7 @@ public class GeneralLinesChartController: BaseLinesChartController {
|
|||
|
||||
let chartValue: CGFloat = CGFloat(closestDate.timeIntervalSince1970)
|
||||
let detailsViewPosition = (chartValue - horizontalRange.lowerBound) / horizontalRange.distance * chartFrame.width + chartFrame.minX
|
||||
self.setDetailsViewModel?(chartDetailsViewModel(closestDate: closestDate, pointIndex: minIndex, loading: false), chartInteractionWasBegin, !chartInteractionWasBegin)
|
||||
self.setDetailsViewModel?(chartDetailsViewModel(closestDate: closestDate, pointIndex: minIndex, loading: false), chartInteractionWasBegin, chartInteractionWasBegin)
|
||||
self.setDetailsChartVisibleClosure?(true, true)
|
||||
self.setDetailsViewPositionClosure?(detailsViewPosition)
|
||||
self.verticalLineRenderer.values = [chartValue]
|
||||
|
|
|
|||
|
|
@ -149,9 +149,6 @@ public class TwoAxisLinesChartController: BaseLinesChartController {
|
|||
}
|
||||
|
||||
public override func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||
guard !ignoreInteraction else {
|
||||
return
|
||||
}
|
||||
if manual && !isChartInteracting && !self.verticalLineRenderer.values.isEmpty {
|
||||
self.cancelChartInteraction()
|
||||
ignoreInteraction = true
|
||||
|
|
@ -176,7 +173,7 @@ public class TwoAxisLinesChartController: BaseLinesChartController {
|
|||
|
||||
let chartValue: CGFloat = CGFloat(closestDate.timeIntervalSince1970)
|
||||
let detailsViewPosition = (chartValue - horizontalRange.lowerBound) / horizontalRange.distance * chartFrame.width + chartFrame.minX
|
||||
self.setDetailsViewModel?(chartDetailsViewModel(closestDate: closestDate, pointIndex: minIndex, loading: false), chartInteractionWasBegin, !chartInteractionWasBegin)
|
||||
self.setDetailsViewModel?(chartDetailsViewModel(closestDate: closestDate, pointIndex: minIndex, loading: false), chartInteractionWasBegin, chartInteractionWasBegin)
|
||||
self.setDetailsChartVisibleClosure?(true, true)
|
||||
self.setDetailsViewPositionClosure?(detailsViewPosition)
|
||||
self.verticalLineRenderer.values = [chartValue]
|
||||
|
|
|
|||
|
|
@ -253,9 +253,9 @@ public class PercentPieChartController: BaseChartController {
|
|||
var lowIndex = max(0, index - range / 2)
|
||||
var highIndex = min(currentCollection.axisValues.count - 1, index + range / 2)
|
||||
if lowIndex == 0 {
|
||||
highIndex = lowIndex + (range - 1)
|
||||
highIndex = min(currentCollection.axisValues.count - 1, lowIndex + (range - 1))
|
||||
} else if highIndex == currentCollection.axisValues.count - 1 {
|
||||
lowIndex = highIndex - (range - 1)
|
||||
lowIndex = max(0, highIndex - (range - 1))
|
||||
}
|
||||
|
||||
let newValues = currentCollection.chartValues.map { chart in
|
||||
|
|
|
|||
|
|
@ -152,9 +152,6 @@ public class TwoAxisStepBarsChartController: BaseLinesChartController {
|
|||
}
|
||||
|
||||
public override func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||
guard !ignoreInteraction else {
|
||||
return
|
||||
}
|
||||
if manual && !isChartInteracting && !self.verticalLineRenderer.values.isEmpty {
|
||||
self.cancelChartInteraction()
|
||||
ignoreInteraction = true
|
||||
|
|
@ -193,7 +190,7 @@ public class TwoAxisStepBarsChartController: BaseLinesChartController {
|
|||
|
||||
let chartValue: CGFloat = CGFloat(closestDate.timeIntervalSince1970)
|
||||
let detailsViewPosition = (chartValue - horizontalRange.lowerBound) / horizontalRange.distance * chartFrame.width + chartFrame.minX + barOffset
|
||||
self.setDetailsViewModel?(chartDetailsViewModel(closestDate: closestDate, pointIndex: minIndex, loading: false), chartInteractionWasBegin, !chartInteractionWasBegin)
|
||||
self.setDetailsViewModel?(chartDetailsViewModel(closestDate: closestDate, pointIndex: minIndex, loading: false), chartInteractionWasBegin, chartInteractionWasBegin)
|
||||
self.setDetailsChartVisibleClosure?(true, true)
|
||||
self.setDetailsViewPositionClosure?(detailsViewPosition)
|
||||
self.verticalLineRenderer.values = [chartValue]
|
||||
|
|
|
|||
|
|
@ -57,20 +57,20 @@ class BaseChartRenderer: ChartViewRenderer {
|
|||
return
|
||||
}
|
||||
if animated {
|
||||
let function: TimeFunction
|
||||
if let timeFunction = timeFunction {
|
||||
function = timeFunction
|
||||
} else if self.verticalRange.current.distance > 0 && verticalRange.distance > 0 {
|
||||
if self.verticalRange.current.distance / verticalRange.distance > exponentialAnimationTrashold {
|
||||
function = .easeIn
|
||||
} else if verticalRange.distance / self.verticalRange.current.distance > exponentialAnimationTrashold {
|
||||
function = .easeOut
|
||||
} else {
|
||||
function = .linear
|
||||
}
|
||||
} else {
|
||||
function = .linear
|
||||
}
|
||||
let function: TimeFunction = .easeInOut
|
||||
// if let timeFunction = timeFunction {
|
||||
// function = timeFunction
|
||||
// } else if self.verticalRange.current.distance > 0 && verticalRange.distance > 0 {
|
||||
// if self.verticalRange.current.distance / verticalRange.distance > exponentialAnimationTrashold {
|
||||
// function = .easeIn
|
||||
// } else if verticalRange.distance / self.verticalRange.current.distance > exponentialAnimationTrashold {
|
||||
// function = .easeOut
|
||||
// } else {
|
||||
// function = .linear
|
||||
// }
|
||||
// } else {
|
||||
// function = .linear
|
||||
// }
|
||||
|
||||
self.verticalRange.animate(to: verticalRange, duration: .defaultDuration, timeFunction: function)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue