Fix charts

This commit is contained in:
Ilya Laktyushin 2020-03-23 17:34:23 +04:00
parent 13cd7a2ab6
commit 7d7ccbee75
6 changed files with 22 additions and 21 deletions

View File

@ -17,7 +17,7 @@ prepare_build_variables () {
;;
esac
local BAZEL="/Users/ilya/bin/bazel"
local BAZEL="$(which bazel)"
if [ "$BAZEL" = "" ]; then
echo "bazel not found in PATH"
exit 1

View File

@ -87,7 +87,7 @@ class BarsComponentController: GeneralChartComponentController {
super.willAppear(animated: animated)
updatePreviewRangeClosure?(currentChartHorizontalRangeFraction, animated)
setConponentsVisible(visible: true, animated: animated)
setComponentsVisible(visible: true, animated: animated)
updateHorizontalLimitLabels(animated: animated, forceUpdate: true)
}
@ -111,10 +111,10 @@ class BarsComponentController: GeneralChartComponentController {
func prepareAppearanceAnimation(horizontalRnage: ClosedRange<CGFloat>) {
setupMainChart(horizontalRange: horizontalRnage, animated: false)
setConponentsVisible(visible: false, animated: false)
setComponentsVisible(visible: false, animated: false)
}
func setConponentsVisible(visible: Bool, animated: Bool) {
func setComponentsVisible(visible: Bool, animated: Bool) {
mainBarsRenderer.setVisible(visible, animated: animated)
horizontalScalesRenderer.setVisible(visible, animated: animated)
verticalScalesRenderer.setVisible(visible, animated: animated)
@ -183,6 +183,9 @@ class BarsComponentController: GeneralChartComponentController {
var viewModel = super.chartDetailsViewModel(closestDate: closestDate, pointIndex: pointIndex)
let visibleChartValues = self.visibleChartValues
let totalSumm: CGFloat = visibleChartValues.map { CGFloat($0.values[pointIndex]) }.reduce(0, +)
viewModel.hideAction = { [weak self] in
self?.hideDetailsView(animated: true)
}
if !self.step {
viewModel.totalValue = ChartDetailsViewModel.Value(prefix: nil,
title: "Total",

View File

@ -51,7 +51,7 @@ class BaseChartRenderer: ChartViewRenderer {
lazy var horizontalRange = AnimationController<ClosedRange<CGFloat>>(current: 0...1, refreshClosure: refreshClosure)
lazy var verticalRange = AnimationController<ClosedRange<CGFloat>>(current: 0...1, refreshClosure: refreshClosure)
func setup(verticalRange: ClosedRange<CGFloat>, animated: Bool, timeFunction: TimeFunction? = nil) {
func setup(verticalRange: ClosedRange<CGFloat>, animated: Bool, timeFunction: TimeFunction? = nil) {
guard self.verticalRange.end != verticalRange else {
self.verticalRange.timeFunction = timeFunction ?? .linear
return

View File

@ -500,6 +500,11 @@ extension LinesChartRenderer.LineData {
}
}
}
if vMin == vMax {
return 0...vMax * 2.0
}
return vMin...vMax
} else {
guard let firstPoint = lines.first?.points.first else { return nil }
@ -511,6 +516,11 @@ extension LinesChartRenderer.LineData {
vMax = max(vMax, point.y)
}
}
if vMin == vMax {
return 0...vMax * 2.0
}
return vMin...vMax
}
}

View File

@ -269,7 +269,7 @@ private enum StatsEntry: ItemListNodeEntry {
return false
}
case let .post(lhsIndex, lhsTheme, lhsStrings, lhsDateTimeFormat, lhsMessage, lhsInteractions):
if case let .post(rhsIndex, rhsTheme, rhsStrings, rhsDateTimeFormat, rhsMessage, rhsInteractions) = rhs, lhsIndex == rhsIndex, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsDateTimeFormat == rhsDateTimeFormat, lhsInteractions == rhsInteractions {
if case let .post(rhsIndex, rhsTheme, rhsStrings, rhsDateTimeFormat, rhsMessage, rhsInteractions) = rhs, lhsIndex == rhsIndex, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsDateTimeFormat == rhsDateTimeFormat, lhsMessage.id == rhsMessage.id, lhsInteractions == rhsInteractions {
return true
} else {
return false
@ -420,8 +420,6 @@ private func statsControllerEntries(data: ChannelStats?, messages: [Message]?, i
}
public func channelStatsController(context: AccountContext, peerId: PeerId, cachedPeerData: CachedPeerData) -> ViewController {
var pushControllerImpl: ((ViewController) -> Void)?
var presentControllerImpl: ((ViewController, ViewControllerPresentationArguments?) -> Void)?
var navigateToMessageImpl: ((MessageId) -> Void)?
let actionsDisposable = DisposableSet()
@ -506,16 +504,6 @@ public func channelStatsController(context: AccountContext, peerId: PeerId, cach
controller.didDisappear = { [weak controller] _ in
controller?.clearItemNodesHighlight(animated: true)
}
pushControllerImpl = { [weak controller] c in
if let controller = controller {
(controller.navigationController as? NavigationController)?.pushViewController(c, animated: true)
}
}
presentControllerImpl = { [weak controller] c, a in
if let controller = controller {
controller.present(c, in: .window(.root), with: a)
}
}
navigateToMessageImpl = { [weak controller] messageId in
if let navigationController = controller?.navigationController as? NavigationController {
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(messageId.peerId), subject: .message(messageId), keepStack: .always, useExisting: false, purposefulAction: {}))

View File

@ -110,7 +110,7 @@ class StatsGraphItemNode: ListViewItemNode {
super.didLoad()
self.view.interactiveTransitionGestureRecognizerTest = { point -> Bool in
return point.x > 30.0 || (point.y > 250.0 && point.y < 295.0)
return point.x > 30.0 || (point.y > 310.0 && point.y < 355.0)
}
}
@ -150,12 +150,12 @@ class StatsGraphItemNode: ListViewItemNode {
case .plain:
itemBackgroundColor = item.presentationData.theme.list.plainBackgroundColor
itemSeparatorColor = item.presentationData.theme.list.itemPlainSeparatorColor
contentSize = CGSize(width: params.width, height: 301.0)
contentSize = CGSize(width: params.width, height: 361.0)
insets = itemListNeighborsPlainInsets(neighbors)
case .blocks:
itemBackgroundColor = item.presentationData.theme.list.itemBlocksBackgroundColor
itemSeparatorColor = item.presentationData.theme.list.itemBlocksSeparatorColor
contentSize = CGSize(width: params.width, height: 301.0)
contentSize = CGSize(width: params.width, height: 361.0)
insets = itemListNeighborsGroupedInsets(neighbors)
}