diff --git a/Feels.xcodeproj/project.pbxproj b/Feels.xcodeproj/project.pbxproj index 499088e..3ad4fb1 100644 --- a/Feels.xcodeproj/project.pbxproj +++ b/Feels.xcodeproj/project.pbxproj @@ -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 */ diff --git a/Feels.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Feels.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d7cede6..9d0009f 100644 --- a/Feels.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Feels.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -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 } }, diff --git a/Feels.xcodeproj/xcuserdata/treyt.xcuserdatad/xcschemes/xcschememanagement.plist b/Feels.xcodeproj/xcuserdata/treyt.xcuserdatad/xcschemes/xcschememanagement.plist index 14118e7..4f6251c 100644 --- a/Feels.xcodeproj/xcuserdata/treyt.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Feels.xcodeproj/xcuserdata/treyt.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,54 +12,117 @@ Feels (macOS).xcscheme_^#shared#^_ orderHint - 2 + 0 FeelsWidgetExtension.xcscheme_^#shared#^_ orderHint - 0 + 2 PlaygroundChart (Playground) 1.xcscheme isShown orderHint - 4 + 5 + + PlaygroundChart (Playground) 10.xcscheme + + isShown + + orderHint + 13 + + PlaygroundChart (Playground) 11.xcscheme + + isShown + + orderHint + 14 + + PlaygroundChart (Playground) 12.xcscheme + + isShown + + orderHint + 15 + + PlaygroundChart (Playground) 13.xcscheme + + isShown + + orderHint + 16 + + PlaygroundChart (Playground) 14.xcscheme + + isShown + + orderHint + 17 PlaygroundChart (Playground) 2.xcscheme isShown orderHint - 5 + 6 PlaygroundChart (Playground) 3.xcscheme isShown orderHint - 6 + 7 PlaygroundChart (Playground) 4.xcscheme isShown orderHint - 7 + 8 PlaygroundChart (Playground) 5.xcscheme isShown orderHint - 8 + 9 + + PlaygroundChart (Playground) 6.xcscheme + + isShown + + orderHint + 2 + + PlaygroundChart (Playground) 7.xcscheme + + isShown + + orderHint + 10 + + PlaygroundChart (Playground) 8.xcscheme + + isShown + + orderHint + 11 + + PlaygroundChart (Playground) 9.xcscheme + + isShown + + orderHint + 12 PlaygroundChart (Playground).xcscheme isShown orderHint - 3 + 4 diff --git a/Shared/views/HeaderStatsView.swift b/Shared/views/HeaderStatsView.swift index 4fae560..c76cae3 100644 --- a/Shared/views/HeaderStatsView.swift +++ b/Shared/views/HeaderStatsView.swift @@ -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