small graph fixes [skip ci]

This commit is contained in:
overtake 2020-05-12 12:13:38 +04:00
parent 7ce55ab128
commit 0716e14b84
2 changed files with 12 additions and 3 deletions

View File

@ -86,7 +86,6 @@ class BarsComponentController: GeneralChartComponentController {
setupMainChart(verticalRange: initialVerticalRange, animated: animated) setupMainChart(verticalRange: initialVerticalRange, animated: animated)
setupMainChart(horizontalRange: initialHorizontalRange, animated: animated) setupMainChart(horizontalRange: initialHorizontalRange, animated: animated)
updateChartVerticalRanges(horizontalRange: initialHorizontalRange, animated: animated) updateChartVerticalRanges(horizontalRange: initialHorizontalRange, animated: animated)
super.willAppear(animated: animated) super.willAppear(animated: animated)
@ -130,6 +129,10 @@ class BarsComponentController: GeneralChartComponentController {
mainBarsRenderer.setup(horizontalRange: horizontalRange, animated: animated) mainBarsRenderer.setup(horizontalRange: horizontalRange, animated: animated)
horizontalScalesRenderer.setup(horizontalRange: horizontalRange, animated: animated) horizontalScalesRenderer.setup(horizontalRange: horizontalRange, animated: animated)
verticalScalesRenderer.setup(horizontalRange: horizontalRange, animated: animated) verticalScalesRenderer.setup(horizontalRange: horizontalRange, animated: animated)
verticalLineRenderer.setup(horizontalRange: horizontalRange, animated: animated)
lineBulletsRenderer.setup(horizontalRange: horizontalRange, animated: animated)
} }
var visibleBars: BarChartRenderer.BarsData { var visibleBars: BarChartRenderer.BarsData {
@ -213,7 +216,7 @@ class BarsComponentController: GeneralChartComponentController {
} }
override func showDetailsView(at chartPosition: CGFloat, detailsViewPosition: CGFloat, dataIndex: Int, date: Date, animated: Bool, feedback: Bool) { override func showDetailsView(at chartPosition: CGFloat, detailsViewPosition: CGFloat, dataIndex: Int, date: Date, animated: Bool, feedback: Bool) {
let rangeWithOffset = detailsViewPosition - barsWidth / currentHorizontalMainChartRange.distance * chartFrame().width / 2 let rangeWithOffset = detailsViewPosition - barsWidth / currentHorizontalMainChartRange.distance * chartFrame().width / 2 + chartFrame().minX / 2
super.showDetailsView(at: chartPosition, detailsViewPosition: rangeWithOffset, dataIndex: dataIndex, date: date, animated: animated, feedback: feedback) super.showDetailsView(at: chartPosition, detailsViewPosition: rangeWithOffset, dataIndex: dataIndex, date: date, animated: animated, feedback: feedback)
mainBarsRenderer.setSelectedIndex(dataIndex, animated: true) mainBarsRenderer.setSelectedIndex(dataIndex, animated: true)
} }
@ -232,6 +235,7 @@ class BarsComponentController: GeneralChartComponentController {
verticalScalesRenderer.horizontalLinesColor = theme.barChartStrongLinesColor verticalScalesRenderer.horizontalLinesColor = theme.barChartStrongLinesColor
mainBarsRenderer.update(backgroundColor: theme.chartBackgroundColor, animated: false) mainBarsRenderer.update(backgroundColor: theme.chartBackgroundColor, animated: false)
previewBarsChartRenderer.update(backgroundColor: theme.chartBackgroundColor, animated: false) previewBarsChartRenderer.update(backgroundColor: theme.chartBackgroundColor, animated: false)
verticalLineRenderer.linesColor = theme.chartStrongLinesColor
} }
override func updateChartRangeTitle(animated: Bool) { override func updateChartRangeTitle(animated: Bool) {
@ -270,6 +274,8 @@ class BarsComponentController: GeneralChartComponentController {
} }
currentChartValue = chartValue currentChartValue = chartValue
let detailsViewPosition = (chartValue - horizontalRange.lowerBound) / horizontalRange.distance * chartFrame.width + chartFrame.minX let detailsViewPosition = (chartValue - horizontalRange.lowerBound) / horizontalRange.distance * chartFrame.width + chartFrame.minX
showDetailsView(at: chartValue, detailsViewPosition: detailsViewPosition, dataIndex: minIndex, date: closestDate, animated: chartWasInteracting, feedback: chartWasInteracting && chartValueUpdated) showDetailsView(at: chartValue, detailsViewPosition: detailsViewPosition, dataIndex: minIndex, date: closestDate, animated: chartWasInteracting, feedback: chartWasInteracting && chartValueUpdated)
super.chartInteractionDidBegin(point: point) super.chartInteractionDidBegin(point: point)

View File

@ -223,11 +223,14 @@ public class StepBarsChartController: BaseChartController {
} }
public override func cancelChartInteraction() { public override func cancelChartInteraction() {
self.barsController.lineBulletsRenderer.isEnabled = false
self.barsController.verticalLineRenderer.values = []
if isZoomed { if isZoomed {
return zoomedBarsController.hideDetailsView(animated: true) return zoomedBarsController.hideDetailsView(animated: true)
} else { } else {
return barsController.hideDetailsView(animated: true) return barsController.hideDetailsView(animated: true)
} }
} }
public override func didTapZoomIn(date: Date, pointIndex: Int) { public override func didTapZoomIn(date: Date, pointIndex: Int) {