mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 06:10:03 +00:00
Chart fixes
This commit is contained in:
parent
4abab11e7e
commit
eb4105cc36
@ -97,7 +97,7 @@ public class BaseChartController: ChartThemeContainer {
|
|||||||
fatalError("Abstract")
|
fatalError("Abstract")
|
||||||
}
|
}
|
||||||
|
|
||||||
public func chartInteractionDidBegin(point: CGPoint) {
|
public func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||||
fatalError("Abstract")
|
fatalError("Abstract")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -129,7 +129,7 @@ class GeneralChartComponentController: ChartThemeContainer {
|
|||||||
func updateChartsVisibility(visibility: [Bool], animated: Bool) {
|
func updateChartsVisibility(visibility: [Bool], animated: Bool) {
|
||||||
self.chartVisibility = visibility
|
self.chartVisibility = visibility
|
||||||
if isChartInteractionBegun {
|
if isChartInteractionBegun {
|
||||||
chartInteractionDidBegin(point: lastChartInteractionPoint)
|
chartInteractionDidBegin(point: lastChartInteractionPoint, manual: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,11 +169,11 @@ class GeneralChartComponentController: ChartThemeContainer {
|
|||||||
return (closestDate, minIndex)
|
return (closestDate, minIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
func chartInteractionDidBegin(point: CGPoint) {
|
func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||||
guard !ignoreInteraction else {
|
guard !ignoreInteraction else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !isChartInteractionBegun && detailsVisible {
|
if manual && !isChartInteracting && detailsVisible {
|
||||||
self.hideDetailsView(animated: true)
|
self.hideDetailsView(animated: true)
|
||||||
ignoreInteraction = true
|
ignoreInteraction = true
|
||||||
return
|
return
|
||||||
@ -203,7 +203,6 @@ class GeneralChartComponentController: ChartThemeContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func chartInteractionDidEnd() {
|
func chartInteractionDidEnd() {
|
||||||
isChartInteractionBegun = false
|
|
||||||
isChartInteracting = false
|
isChartInteracting = false
|
||||||
ignoreInteraction = false
|
ignoreInteraction = false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@ public class BaseLinesChartController: BaseChartController {
|
|||||||
var zoomChartVisibility: [Bool]
|
var zoomChartVisibility: [Bool]
|
||||||
var lastChartInteractionPoint: CGPoint = .zero
|
var lastChartInteractionPoint: CGPoint = .zero
|
||||||
var isChartInteractionBegun: Bool = false
|
var isChartInteractionBegun: Bool = false
|
||||||
|
var isChartInteracting: Bool = false
|
||||||
var ignoreInteraction: Bool = false
|
var ignoreInteraction: Bool = false
|
||||||
|
|
||||||
var initialChartRange: ClosedRange<CGFloat> = BaseConstants.defaultRange
|
var initialChartRange: ClosedRange<CGFloat> = BaseConstants.defaultRange
|
||||||
@ -66,17 +67,18 @@ public class BaseLinesChartController: BaseChartController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func chartInteractionDidBegin(point: CGPoint) {
|
public override func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||||
lastChartInteractionPoint = point
|
lastChartInteractionPoint = point
|
||||||
isChartInteractionBegun = true
|
isChartInteractionBegun = true
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func chartInteractionDidEnd() {
|
public override func chartInteractionDidEnd() {
|
||||||
isChartInteractionBegun = false
|
isChartInteracting = false
|
||||||
ignoreInteraction = false
|
ignoreInteraction = false
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func cancelChartInteraction() {
|
public override func cancelChartInteraction() {
|
||||||
|
isChartInteracting = false
|
||||||
isChartInteractionBegun = false
|
isChartInteractionBegun = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -117,15 +117,15 @@ public class GeneralLinesChartController: BaseLinesChartController {
|
|||||||
updateVerticalLimitsAndRange(horizontalRange: currentHorizontalRange, animated: true)
|
updateVerticalLimitsAndRange(horizontalRange: currentHorizontalRange, animated: true)
|
||||||
|
|
||||||
if isChartInteractionBegun {
|
if isChartInteractionBegun {
|
||||||
chartInteractionDidBegin(point: lastChartInteractionPoint)
|
chartInteractionDidBegin(point: lastChartInteractionPoint, manual: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func chartInteractionDidBegin(point: CGPoint) {
|
public override func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||||
guard !ignoreInteraction else {
|
guard !ignoreInteraction else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !isChartInteractionBegun && !self.verticalLineRenderer.values.isEmpty {
|
if manual && !isChartInteracting && !self.verticalLineRenderer.values.isEmpty {
|
||||||
self.cancelChartInteraction()
|
self.cancelChartInteraction()
|
||||||
ignoreInteraction = true
|
ignoreInteraction = true
|
||||||
return
|
return
|
||||||
|
|||||||
@ -144,15 +144,15 @@ public class TwoAxisLinesChartController: BaseLinesChartController {
|
|||||||
updateVerticalLimitsAndRange(horizontalRange: currentHorizontalRange, animated: true)
|
updateVerticalLimitsAndRange(horizontalRange: currentHorizontalRange, animated: true)
|
||||||
|
|
||||||
if isChartInteractionBegun {
|
if isChartInteractionBegun {
|
||||||
chartInteractionDidBegin(point: lastChartInteractionPoint)
|
chartInteractionDidBegin(point: lastChartInteractionPoint, manual: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func chartInteractionDidBegin(point: CGPoint) {
|
public override func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||||
guard !ignoreInteraction else {
|
guard !ignoreInteraction else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !isChartInteractionBegun && !self.verticalLineRenderer.values.isEmpty {
|
if manual && !isChartInteracting && !self.verticalLineRenderer.values.isEmpty {
|
||||||
self.cancelChartInteraction()
|
self.cancelChartInteraction()
|
||||||
ignoreInteraction = true
|
ignoreInteraction = true
|
||||||
return
|
return
|
||||||
|
|||||||
@ -208,11 +208,11 @@ public class PercentPieChartController: BaseChartController {
|
|||||||
return collection
|
return collection
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func chartInteractionDidBegin(point: CGPoint) {
|
public override func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||||
if isZoomed {
|
if isZoomed {
|
||||||
pieController.chartInteractionDidBegin(point: point)
|
pieController.chartInteractionDidBegin(point: point, manual: manual)
|
||||||
} else {
|
} else {
|
||||||
percentController.chartInteractionDidBegin(point: point)
|
percentController.chartInteractionDidBegin(point: point, manual: manual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -170,7 +170,7 @@ class PieChartComponentController: GeneralChartComponentController {
|
|||||||
return previewBarChartRenderer
|
return previewBarChartRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func chartInteractionDidBegin(point: CGPoint) {
|
public override func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||||
if let segment = pieChartRenderer.selectedItemIndex(at: point) {
|
if let segment = pieChartRenderer.selectedItemIndex(at: point) {
|
||||||
pieChartRenderer.selectSegmentAt(at: segment, animated: true)
|
pieChartRenderer.selectSegmentAt(at: segment, animated: true)
|
||||||
updateSelectedDataLabelIfNeeded()
|
updateSelectedDataLabelIfNeeded()
|
||||||
|
|||||||
@ -173,11 +173,11 @@ public class DailyBarsChartController: BaseChartController {
|
|||||||
return collection
|
return collection
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func chartInteractionDidBegin(point: CGPoint) {
|
public override func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||||
if isZoomed {
|
if isZoomed {
|
||||||
linesController.chartInteractionDidBegin(point: point)
|
linesController.chartInteractionDidBegin(point: point, manual: manual)
|
||||||
} else {
|
} else {
|
||||||
barsController.chartInteractionDidBegin(point: point)
|
barsController.chartInteractionDidBegin(point: point, manual: manual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -184,11 +184,11 @@ public class StackedBarsChartController: BaseChartController {
|
|||||||
return collection
|
return collection
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func chartInteractionDidBegin(point: CGPoint) {
|
public override func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||||
if isZoomed {
|
if isZoomed {
|
||||||
zoomedBarsController.chartInteractionDidBegin(point: point)
|
zoomedBarsController.chartInteractionDidBegin(point: point, manual: manual)
|
||||||
} else {
|
} else {
|
||||||
barsController.chartInteractionDidBegin(point: point)
|
barsController.chartInteractionDidBegin(point: point, manual: manual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -192,11 +192,11 @@ public class StepBarsChartController: BaseChartController {
|
|||||||
return collection
|
return collection
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func chartInteractionDidBegin(point: CGPoint) {
|
public override func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||||
if isZoomed {
|
if isZoomed {
|
||||||
zoomedBarsController.chartInteractionDidBegin(point: point)
|
zoomedBarsController.chartInteractionDidBegin(point: point, manual: manual)
|
||||||
} else {
|
} else {
|
||||||
barsController.chartInteractionDidBegin(point: point)
|
barsController.chartInteractionDidBegin(point: point, manual: manual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -147,15 +147,15 @@ public class TwoAxisStepBarsChartController: BaseLinesChartController {
|
|||||||
updateVerticalLimitsAndRange(horizontalRange: currentHorizontalRange, animated: true)
|
updateVerticalLimitsAndRange(horizontalRange: currentHorizontalRange, animated: true)
|
||||||
|
|
||||||
if isChartInteractionBegun {
|
if isChartInteractionBegun {
|
||||||
chartInteractionDidBegin(point: lastChartInteractionPoint)
|
chartInteractionDidBegin(point: lastChartInteractionPoint, manual: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func chartInteractionDidBegin(point: CGPoint) {
|
public override func chartInteractionDidBegin(point: CGPoint, manual: Bool = true) {
|
||||||
guard !ignoreInteraction else {
|
guard !ignoreInteraction else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !isChartInteractionBegun && !self.verticalLineRenderer.values.isEmpty {
|
if manual && !isChartInteracting && !self.verticalLineRenderer.values.isEmpty {
|
||||||
self.cancelChartInteraction()
|
self.cancelChartInteraction()
|
||||||
ignoreInteraction = true
|
ignoreInteraction = true
|
||||||
return
|
return
|
||||||
|
|||||||
@ -17,7 +17,7 @@ private var labelSpacing: CGFloat = 2
|
|||||||
private var margin: CGFloat = 10
|
private var margin: CGFloat = 10
|
||||||
private var prefixLabelWidth: CGFloat = 29
|
private var prefixLabelWidth: CGFloat = 29
|
||||||
private var textLabelWidth: CGFloat = 110
|
private var textLabelWidth: CGFloat = 110
|
||||||
private var valueLabelWidth: CGFloat = 65
|
private var valueLabelWidth: CGFloat = 70
|
||||||
|
|
||||||
class ChartDetailsView: UIControl {
|
class ChartDetailsView: UIControl {
|
||||||
let titleLabel = UILabel()
|
let titleLabel = UILabel()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user