Skip to content

Commit

Permalink
Merge pull request #158 from kunalverma25/BarChartCornerUpdates
Browse files Browse the repository at this point in the history
Enabling corner radius for left/right and explicitly setting all corners
  • Loading branch information
willdale authored Jan 5, 2022
2 parents 133c493 + deb98fc commit 6ba7163
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
38 changes: 33 additions & 5 deletions Sources/SwiftUICharts/BarChart/Models/CornerRadius.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,43 @@ import SwiftUI
*/
public struct CornerRadius: Hashable {

public let top: CGFloat
public let bottom: CGFloat
public let topLeft: CGFloat
public let topRight: CGFloat
public let bottomLeft: CGFloat
public let bottomRight: CGFloat

/// Set the coner radius for the bar shapes
/// Set the coner radius for the bar shapes for top and bottom
public init(
top: CGFloat = 15.0,
bottom: CGFloat = 0.0
) {
self.top = top
self.bottom = bottom
self.topLeft = top
self.topRight = top
self.bottomLeft = bottom
self.bottomRight = bottom
}

/// Set the coner radius for the bar shapes for left and right
public init(
left: CGFloat = 0.0,
right: CGFloat = 0.0
) {
self.topLeft = left
self.topRight = right
self.bottomLeft = left
self.bottomRight = right
}

/// Set the coner radius for the bar shapes for all corners
public init(
topLeft: CGFloat = 0,
topRight: CGFloat = 0,
bottomLeft: CGFloat = 0,
bottomRight: CGFloat = 0
) {
self.topLeft = topLeft
self.topRight = topRight
self.bottomLeft = bottomLeft
self.bottomRight = bottomRight
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ internal struct RoundedRectangleBarShape: Shape {
}

internal init(_ cornerRadius: CornerRadius) {
self.tl = cornerRadius.top
self.tr = cornerRadius.top
self.bl = cornerRadius.bottom
self.br = cornerRadius.bottom
self.tl = cornerRadius.topLeft
self.tr = cornerRadius.topRight
self.bl = cornerRadius.bottomLeft
self.br = cornerRadius.bottomRight
}

internal func path(in rect: CGRect) -> Path {
Expand Down

0 comments on commit 6ba7163

Please sign in to comment.