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 esac
local BAZEL="/Users/ilya/bin/bazel" local BAZEL="$(which bazel)"
if [ "$BAZEL" = "" ]; then if [ "$BAZEL" = "" ]; then
echo "bazel not found in PATH" echo "bazel not found in PATH"
exit 1 exit 1

View File

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

View File

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

View File

@ -269,7 +269,7 @@ private enum StatsEntry: ItemListNodeEntry {
return false return false
} }
case let .post(lhsIndex, lhsTheme, lhsStrings, lhsDateTimeFormat, lhsMessage, lhsInteractions): 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 return true
} else { } else {
return false return false
@ -420,8 +420,6 @@ private func statsControllerEntries(data: ChannelStats?, messages: [Message]?, i
} }
public func channelStatsController(context: AccountContext, peerId: PeerId, cachedPeerData: CachedPeerData) -> ViewController { public func channelStatsController(context: AccountContext, peerId: PeerId, cachedPeerData: CachedPeerData) -> ViewController {
var pushControllerImpl: ((ViewController) -> Void)?
var presentControllerImpl: ((ViewController, ViewControllerPresentationArguments?) -> Void)?
var navigateToMessageImpl: ((MessageId) -> Void)? var navigateToMessageImpl: ((MessageId) -> Void)?
let actionsDisposable = DisposableSet() let actionsDisposable = DisposableSet()
@ -506,16 +504,6 @@ public func channelStatsController(context: AccountContext, peerId: PeerId, cach
controller.didDisappear = { [weak controller] _ in controller.didDisappear = { [weak controller] _ in
controller?.clearItemNodesHighlight(animated: true) 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 navigateToMessageImpl = { [weak controller] messageId in
if let navigationController = controller?.navigationController as? NavigationController { 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: {})) 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() super.didLoad()
self.view.interactiveTransitionGestureRecognizerTest = { point -> Bool in 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: case .plain:
itemBackgroundColor = item.presentationData.theme.list.plainBackgroundColor itemBackgroundColor = item.presentationData.theme.list.plainBackgroundColor
itemSeparatorColor = item.presentationData.theme.list.itemPlainSeparatorColor 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) insets = itemListNeighborsPlainInsets(neighbors)
case .blocks: case .blocks:
itemBackgroundColor = item.presentationData.theme.list.itemBlocksBackgroundColor itemBackgroundColor = item.presentationData.theme.list.itemBlocksBackgroundColor
itemSeparatorColor = item.presentationData.theme.list.itemBlocksSeparatorColor 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) insets = itemListNeighborsGroupedInsets(neighbors)
} }