mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-10 05:19:22 +00:00
49 lines
1.5 KiB
Swift
49 lines
1.5 KiB
Swift
import Foundation
|
|
import UIKit
|
|
import Display
|
|
import AsyncDisplayKit
|
|
import AppBundle
|
|
|
|
public final class ChartNode: ASDisplayNode {
|
|
private var chartView: ChartStackSection {
|
|
return self.view as! ChartStackSection
|
|
}
|
|
|
|
public override init() {
|
|
super.init()
|
|
|
|
self.setViewBlock({
|
|
return ChartStackSection()
|
|
})
|
|
}
|
|
|
|
public override func didLoad() {
|
|
super.didLoad()
|
|
|
|
self.view.disablesInteractiveTransitionGestureRecognizer = true
|
|
}
|
|
|
|
public func setup(_ data: String, bar: Bool = false) {
|
|
if let data = data.data(using: .utf8) {
|
|
ChartsDataManager().readChart(data: data, extraCopiesCount: 0, sync: true, success: { [weak self] collection in
|
|
let controller: BaseChartController
|
|
if bar {
|
|
controller = DailyBarsChartController(chartsCollection: collection)
|
|
} else {
|
|
controller = GeneralLinesChartController(chartsCollection: collection)
|
|
}
|
|
if let strongSelf = self {
|
|
strongSelf.chartView.setup(controller: controller, title: "")
|
|
strongSelf.chartView.apply(colorMode: .day, animated: false)
|
|
}
|
|
}) { error in
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
required public init?(coder aDecoder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|