Fix chart line rendering

This commit is contained in:
Ilya Laktyushin 2020-03-23 22:19:10 +04:00
parent 43d889a1ba
commit fce2702c50
3 changed files with 4 additions and 4 deletions

View File

@ -89,7 +89,6 @@ public class TwoAxisStepBarsChartController: BaseLinesChartController {
} else { } else {
controller.mainBarsRenderer.bars = BarChartRenderer.BarsData(barWidth: 0.0, locations: [], components: []) controller.mainBarsRenderer.bars = BarChartRenderer.BarsData(barWidth: 0.0, locations: [], components: [])
controller.previewBarsRenderer.bars = BarChartRenderer.BarsData(barWidth: 0.0, locations: [], components: []) controller.previewBarsRenderer.bars = BarChartRenderer.BarsData(barWidth: 0.0, locations: [], components: [])
controller.verticalScalesRenderer.setHorizontalLinesVisible(false, animated: animated)
} }
} }

View File

@ -68,6 +68,7 @@ class LinesChartRenderer: BaseChartRenderer {
context.setAlpha(alpha) context.setAlpha(alpha)
context.setStrokeColor(toLine.color.cgColor) context.setStrokeColor(toLine.color.cgColor)
context.setLineWidth(lineWidth) context.setLineWidth(lineWidth)
context.setLineCap(.round)
if linesShapeAnimator.isAnimating { if linesShapeAnimator.isAnimating {
let animationOffset = linesShapeAnimator.current let animationOffset = linesShapeAnimator.current
@ -314,8 +315,9 @@ class LinesChartRenderer: BaseChartRenderer {
lines.removeLast() lines.removeLast()
} }
context.setLineCap(.round) context.beginTransparencyLayer(auxiliaryInfo: nil)
context.strokeLineSegments(between: lines) context.strokeLineSegments(between: lines)
context.endTransparencyLayer()
} else { } else {
if var index = toLine.points.firstIndex(where: { $0.x >= range.lowerBound }) { if var index = toLine.points.firstIndex(where: { $0.x >= range.lowerBound }) {
var lines: [CGPoint] = [] var lines: [CGPoint] = []
@ -431,7 +433,6 @@ class LinesChartRenderer: BaseChartRenderer {
lines.removeLast() lines.removeLast()
} }
context.setLineCap(.round)
context.strokeLineSegments(between: lines) context.strokeLineSegments(between: lines)
} }
} }

View File

@ -138,7 +138,7 @@ class PieChartRenderer: BaseChartRenderer {
let maximumFontSize: CGFloat = radius / 7 let maximumFontSize: CGFloat = radius / 7
let minimumFontSize: CGFloat = 4 let minimumFontSize: CGFloat = 4
let centerOffsetStartAngle = CGFloat.pi / 4 let centerOffsetStartAngle = CGFloat.pi / 4
let minimumValueToDraw: CGFloat = 0.01 let minimumValueToDraw: CGFloat = 1.01
let diagramRadius = radius - animationSelectionOffset let diagramRadius = radius - animationSelectionOffset
let numberOfVisibleItems = currentlyVisibleData.filter { $0.value > 0 }.count let numberOfVisibleItems = currentlyVisibleData.filter { $0.value > 0 }.count