add personal charts project

layout of header graph view
This commit is contained in:
Trey t
2022-01-17 14:23:06 -06:00
parent c5be6e0cc9
commit fd185ac80f
4 changed files with 110 additions and 31 deletions

View File

@@ -7,13 +7,13 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
1C2618FA2795E41D00FDC148 /* Charts in Frameworks */ = {isa = PBXBuildFile; productRef = 1C2618F92795E41D00FDC148 /* Charts */; };
1C412082278F2B8800D9153A /* FilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C412081278F2B8800D9153A /* FilterView.swift */; }; 1C412082278F2B8800D9153A /* FilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C412081278F2B8800D9153A /* FilterView.swift */; };
1C412083278F2B8800D9153A /* FilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C412081278F2B8800D9153A /* FilterView.swift */; }; 1C412083278F2B8800D9153A /* FilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C412081278F2B8800D9153A /* FilterView.swift */; };
1C683FCA2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; }; 1C683FCA2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; };
1C683FCB2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; }; 1C683FCB2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; };
1C683FCC2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; }; 1C683FCC2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; };
1C744F2C278CE15600953A57 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C744F2B278CE15600953A57 /* AppDelegate.swift */; }; 1C744F2C278CE15600953A57 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C744F2B278CE15600953A57 /* AppDelegate.swift */; };
1CA2662A2793843200C0E12C /* Charts in Frameworks */ = {isa = PBXBuildFile; productRef = 1CA266292793843200C0E12C /* Charts */; };
1CA2662D2793908700C0E12C /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD90AEF278C7DDF001C4FEA /* Persistence.swift */; }; 1CA2662D2793908700C0E12C /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD90AEF278C7DDF001C4FEA /* Persistence.swift */; };
1CC469AA278F30A0003E0C6E /* BGTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC469A9278F30A0003E0C6E /* BGTask.swift */; }; 1CC469AA278F30A0003E0C6E /* BGTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC469A9278F30A0003E0C6E /* BGTask.swift */; };
1CC469AC27907D48003E0C6E /* CircleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC469AB27907D48003E0C6E /* CircleView.swift */; }; 1CC469AC27907D48003E0C6E /* CircleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC469AB27907D48003E0C6E /* CircleView.swift */; };
@@ -148,7 +148,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
1CD90B6C278C7F78001C4FEA /* CloudKit.framework in Frameworks */, 1CD90B6C278C7F78001C4FEA /* CloudKit.framework in Frameworks */,
1CA2662A2793843200C0E12C /* Charts in Frameworks */, 1C2618FA2795E41D00FDC148 /* Charts in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@@ -323,7 +323,7 @@
); );
name = "Feels (iOS)"; name = "Feels (iOS)";
packageProductDependencies = ( packageProductDependencies = (
1CA266292793843200C0E12C /* Charts */, 1C2618F92795E41D00FDC148 /* Charts */,
); );
productName = "Feels (iOS)"; productName = "Feels (iOS)";
productReference = 1CD90AF5278C7DE0001C4FEA /* Feels.app */; productReference = 1CD90AF5278C7DE0001C4FEA /* Feels.app */;
@@ -438,7 +438,7 @@
); );
mainGroup = 1CD90AE5278C7DDF001C4FEA; mainGroup = 1CD90AE5278C7DDF001C4FEA;
packageReferences = ( packageReferences = (
1CA266282793843200C0E12C /* XCRemoteSwiftPackageReference "Charts" */, 1C2618F82795E41D00FDC148 /* XCRemoteSwiftPackageReference "ChartsPackage" */,
); );
productRefGroup = 1CD90AF6278C7DE0001C4FEA /* Products */; productRefGroup = 1CD90AF6278C7DE0001C4FEA /* Products */;
projectDirPath = ""; projectDirPath = "";
@@ -1040,9 +1040,9 @@
/* End XCConfigurationList section */ /* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */ /* Begin XCRemoteSwiftPackageReference section */
1CA266282793843200C0E12C /* XCRemoteSwiftPackageReference "Charts" */ = { 1C2618F82795E41D00FDC148 /* XCRemoteSwiftPackageReference "ChartsPackage" */ = {
isa = XCRemoteSwiftPackageReference; isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/danielgindi/Charts"; repositoryURL = "https://github.com/akatreyt/ChartsPackage";
requirement = { requirement = {
branch = master; branch = master;
kind = branch; kind = branch;
@@ -1051,9 +1051,9 @@
/* End XCRemoteSwiftPackageReference section */ /* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */ /* Begin XCSwiftPackageProductDependency section */
1CA266292793843200C0E12C /* Charts */ = { 1C2618F92795E41D00FDC148 /* Charts */ = {
isa = XCSwiftPackageProductDependency; isa = XCSwiftPackageProductDependency;
package = 1CA266282793843200C0E12C /* XCRemoteSwiftPackageReference "Charts" */; package = 1C2618F82795E41D00FDC148 /* XCRemoteSwiftPackageReference "ChartsPackage" */;
productName = Charts; productName = Charts;
}; };
/* End XCSwiftPackageProductDependency section */ /* End XCSwiftPackageProductDependency section */

View File

@@ -2,11 +2,11 @@
"object": { "object": {
"pins": [ "pins": [
{ {
"package": "Charts", "package": "ChartsPackage",
"repositoryURL": "https://github.com/danielgindi/Charts", "repositoryURL": "https://github.com/akatreyt/ChartsPackage",
"state": { "state": {
"branch": "master", "branch": "master",
"revision": "85cfba96eb3492124d645ac0901b66f0cb266267", "revision": "735f9542271945f1b3424c177ddd7f4bb9fcd0b1",
"version": null "version": null
} }
}, },

View File

@@ -12,54 +12,117 @@
<key>Feels (macOS).xcscheme_^#shared#^_</key> <key>Feels (macOS).xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>2</integer> <integer>0</integer>
</dict> </dict>
<key>FeelsWidgetExtension.xcscheme_^#shared#^_</key> <key>FeelsWidgetExtension.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>0</integer> <integer>2</integer>
</dict> </dict>
<key>PlaygroundChart (Playground) 1.xcscheme</key> <key>PlaygroundChart (Playground) 1.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>4</integer> <integer>5</integer>
</dict>
<key>PlaygroundChart (Playground) 10.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>13</integer>
</dict>
<key>PlaygroundChart (Playground) 11.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>14</integer>
</dict>
<key>PlaygroundChart (Playground) 12.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>15</integer>
</dict>
<key>PlaygroundChart (Playground) 13.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>16</integer>
</dict>
<key>PlaygroundChart (Playground) 14.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>17</integer>
</dict> </dict>
<key>PlaygroundChart (Playground) 2.xcscheme</key> <key>PlaygroundChart (Playground) 2.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>5</integer> <integer>6</integer>
</dict> </dict>
<key>PlaygroundChart (Playground) 3.xcscheme</key> <key>PlaygroundChart (Playground) 3.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>6</integer> <integer>7</integer>
</dict> </dict>
<key>PlaygroundChart (Playground) 4.xcscheme</key> <key>PlaygroundChart (Playground) 4.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>7</integer> <integer>8</integer>
</dict> </dict>
<key>PlaygroundChart (Playground) 5.xcscheme</key> <key>PlaygroundChart (Playground) 5.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>8</integer> <integer>9</integer>
</dict>
<key>PlaygroundChart (Playground) 6.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>PlaygroundChart (Playground) 7.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>10</integer>
</dict>
<key>PlaygroundChart (Playground) 8.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>11</integer>
</dict>
<key>PlaygroundChart (Playground) 9.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>12</integer>
</dict> </dict>
<key>PlaygroundChart (Playground).xcscheme</key> <key>PlaygroundChart (Playground).xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>3</integer> <integer>4</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>

View File

@@ -53,6 +53,8 @@ struct HeaderStatsView : UIViewRepresentable {
chart.xAxis.drawGridLinesEnabled = false chart.xAxis.drawGridLinesEnabled = false
chart.leftAxis.drawGridLinesEnabled = false chart.leftAxis.drawGridLinesEnabled = false
chart.rightAxis.drawGridLinesEnabled = false
chart.leftAxis.axisLineColor = .clear chart.leftAxis.axisLineColor = .clear
chart.rightAxis.axisLineColor = .clear chart.rightAxis.axisLineColor = .clear
@@ -61,29 +63,43 @@ struct HeaderStatsView : UIViewRepresentable {
chart.drawBordersEnabled = false chart.drawBordersEnabled = false
chart.drawMarkers = false chart.drawMarkers = false
// chart.yAxis.drawGridLinesEnabled = false
chart.rightAxis.drawGridLinesEnabled = false
chart.borderColor = .clear chart.borderColor = .clear
//it is convenient to form chart data in a separate func
chart.data = addData() let data = BarChartData()
let dataSet = dataSet()
data.append(dataSet)
chart.data = data
dataSet.valueFormatter = DefaultValueFormatter(decimals: 0)
return chart return chart
} }
// this func is required to conform to UIViewRepresentable protocol // this func is required to conform to UIViewRepresentable protocol
func updateUIView(_ uiView: BarChartView, context: Context) { func updateUIView(_ uiView: BarChartView, context: Context) {
//when data changes chartd.data update is required let data = BarChartData()
uiView.data = addData() let dataSet = dataSet()
data.append(dataSet)
uiView.data = data
dataSet.valueFormatter = DefaultValueFormatter(decimals: 0)
} }
func addData() -> BarChartData{ func dataSet() -> BarChartDataSet {
let data = BarChartData()
//BarChartDataSet is an object that contains information about your data, styling and more
let dataSet = BarChartDataSet(entries: entries) let dataSet = BarChartDataSet(entries: entries)
// change bars color to green // change bars color to green
dataSet.colors = Mood.allValues.map({ NSUIColor( $0.color ) }) dataSet.colors = Mood.allValues.map({ NSUIColor( $0.color ) })
//change data label dataSet.secondaryTextColor = UIColor.systemGray
data.append(dataSet) dataSet.valueColors = [.white]
return data if let descriptor = UIFontDescriptor.preferredFontDescriptor(
withTextStyle: .body).withSymbolicTraits([.traitBold]) {
dataSet.valueFont = UIFont(descriptor: descriptor, size: 0)
} else {
dataSet.valueFont = UIFont.preferredFont(forTextStyle: .body)
}
return dataSet
} }
typealias UIViewType = BarChartView typealias UIViewType = BarChartView