Files
ChartView/Sources/SwiftUICharts/Charts/LineChart/LineBackgroundShapeView.swift
Andras Samu ac7680320f feat(core): refactoring chart dispalying
now it is possible to add background lines precisely as charts are displayed at correct size
also rewrote basics to conform with Shapes and Animatable protocol
2021-04-04 15:54:15 +02:00

20 lines
905 B
Swift

import SwiftUI
struct LineBackgroundShapeView: View {
var chartData: ChartData
var geometry: GeometryProxy
var style: ChartStyle
var body: some View {
LineBackgroundShape(data: chartData.normalisedPoints)
.transform(CGAffineTransform(scaleX: geometry.size.width / CGFloat(chartData.normalisedPoints.count - 1),
y: geometry.size.height / CGFloat(chartData.normalisedRange)))
.fill(LinearGradient(gradient: Gradient(colors: [style.foregroundColor.first?.startColor ?? .white,
style.backgroundColor.startColor]),
startPoint: .bottom,
endPoint: .top))
.rotationEffect(.degrees(180), anchor: .center)
.rotation3DEffect(.degrees(180), axis: (x: 0, y: 1, z: 0))
}
}