Compare commits

..

1 Commits

Author SHA1 Message Date
Samu Andras 64407d0369 feat: add new axis interface 2022-10-16 20:12:56 +02:00
3 changed files with 4 additions and 14 deletions
@@ -11,9 +11,8 @@ extension LineChart {
return self
}
public func showChartMarks(_ show: Bool, with color: ColorGradient? = nil) -> LineChart {
public func showChartMarks(_ show: Bool) -> LineChart {
self.chartProperties.showChartMarks = show
self.chartProperties.customChartMarksColors = color
return self
}
@@ -13,16 +13,6 @@ struct LineShapeView: View, Animatable {
set { trimTo = Double(newValue) }
}
var chartMarkColor: LinearGradient {
if let customColor = chartProperties.customChartMarksColors {
return customColor.linearGradient(from: .leading, to: .trailing)
}
return LinearGradient(gradient: style.foregroundColor.first?.gradient ?? ColorGradient.orangeBright.gradient,
startPoint: .leading,
endPoint: .trailing)
}
var body: some View {
ZStack {
LineShape(data: chartData.normalisedData, lineStyle: chartProperties.lineStyle)
@@ -38,7 +28,9 @@ struct LineShapeView: View, Animatable {
MarkerShape(data: chartData.normalisedData)
.trim(from: 0, to: CGFloat(trimTo))
.fill(.white,
strokeBorder: chartMarkColor,
strokeBorder: LinearGradient(gradient: style.foregroundColor.first?.gradient ?? ColorGradient.orangeBright.gradient,
startPoint: .leading,
endPoint: .trailing),
lineWidth: chartProperties.lineWidth)
.rotationEffect(.degrees(180), anchor: .center)
.rotation3DEffect(.degrees(180), axis: (x: 0, y: 1, z: 0))
@@ -4,7 +4,6 @@ public class LineChartProperties: ObservableObject {
@Published var lineWidth: CGFloat = 2.0
@Published var backgroundGradient: ColorGradient?
@Published var showChartMarks: Bool = true
@Published var customChartMarksColors: ColorGradient?
@Published var lineStyle: LineStyle = .curved
public init() {