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

View File

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

View File

@@ -12,54 +12,117 @@
<key>Feels (macOS).xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>0</integer>
</dict>
<key>FeelsWidgetExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>2</integer>
</dict>
<key>PlaygroundChart (Playground) 1.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<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>
<key>PlaygroundChart (Playground) 2.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>5</integer>
<integer>6</integer>
</dict>
<key>PlaygroundChart (Playground) 3.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>6</integer>
<integer>7</integer>
</dict>
<key>PlaygroundChart (Playground) 4.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>7</integer>
<integer>8</integer>
</dict>
<key>PlaygroundChart (Playground) 5.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<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>
<key>PlaygroundChart (Playground).xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>3</integer>
<integer>4</integer>
</dict>
</dict>
</dict>

View File

@@ -53,6 +53,8 @@ struct HeaderStatsView : UIViewRepresentable {
chart.xAxis.drawGridLinesEnabled = false
chart.leftAxis.drawGridLinesEnabled = false
chart.rightAxis.drawGridLinesEnabled = false
chart.leftAxis.axisLineColor = .clear
chart.rightAxis.axisLineColor = .clear
@@ -61,29 +63,43 @@ struct HeaderStatsView : UIViewRepresentable {
chart.drawBordersEnabled = false
chart.drawMarkers = false
// chart.yAxis.drawGridLinesEnabled = false
chart.rightAxis.drawGridLinesEnabled = false
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
}
// this func is required to conform to UIViewRepresentable protocol
func updateUIView(_ uiView: BarChartView, context: Context) {
//when data changes chartd.data update is required
uiView.data = addData()
let data = BarChartData()
let dataSet = dataSet()
data.append(dataSet)
uiView.data = data
dataSet.valueFormatter = DefaultValueFormatter(decimals: 0)
}
func addData() -> BarChartData{
let data = BarChartData()
//BarChartDataSet is an object that contains information about your data, styling and more
func dataSet() -> BarChartDataSet {
let dataSet = BarChartDataSet(entries: entries)
// change bars color to green
dataSet.colors = Mood.allValues.map({ NSUIColor( $0.color ) })
//change data label
data.append(dataSet)
return data
dataSet.secondaryTextColor = UIColor.systemGray
dataSet.valueColors = [.white]
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