-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): refactoring chart dispalying (#191)
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
- Loading branch information
Showing
15 changed files
with
292 additions
and
194 deletions.
There are no files selected for viewing
Binary file added
BIN
+37.1 KB
...code/package.xcworkspace/xcuserdata/samuandris.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
.swiftpm/xcode/xcuserdata/samuandris.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Bucket | ||
uuid = "91E23D30-CB6C-44DA-BEFC-9D39A1DA2242" | ||
type = "1" | ||
version = "2.0"> | ||
</Bucket> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
Sources/SwiftUICharts/Charts/BarChart/BarChartCellShape.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import SwiftUI | ||
|
||
struct BarChartCellShape: Shape, Animatable { | ||
var value: Double | ||
var cornerRadius: CGFloat = 6.0 | ||
var animatableData: CGFloat { | ||
get { CGFloat(value) } | ||
set { value = Double(newValue) } | ||
} | ||
|
||
func path(in rect: CGRect) -> Path { | ||
let adjustedOriginY = rect.height - (rect.height * CGFloat(value)) | ||
var path = Path() | ||
path.move(to: CGPoint(x: 0.0 , y: rect.height)) | ||
path.addLine(to: CGPoint(x: 0.0, y: adjustedOriginY + cornerRadius)) | ||
path.addArc(center: CGPoint(x: cornerRadius, y: adjustedOriginY + cornerRadius), | ||
radius: cornerRadius, | ||
startAngle: Angle(radians: Double.pi), | ||
endAngle: Angle(radians: -Double.pi/2), | ||
clockwise: false) | ||
path.addLine(to: CGPoint(x: rect.width - cornerRadius, y: adjustedOriginY)) | ||
path.addArc(center: CGPoint(x: rect.width - cornerRadius, y: adjustedOriginY + cornerRadius), | ||
radius: cornerRadius, | ||
startAngle: Angle(radians: -Double.pi/2), | ||
endAngle: Angle(radians: 0), | ||
clockwise: false) | ||
path.addLine(to: CGPoint(x: rect.width, y: rect.height)) | ||
path.closeSubpath() | ||
|
||
return path | ||
} | ||
} | ||
|
||
struct BarChartCellShape_Previews: PreviewProvider { | ||
static var previews: some View { | ||
Group { | ||
BarChartCellShape(value: 0.75) | ||
.fill(Color.red) | ||
|
||
BarChartCellShape(value: 0.3) | ||
.fill(Color.blue) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.