Post

Replies

Boosts

Views

Activity

How to Handle Split Data in `Charts`?
I have a dataset I want to have split between past/historic data and future/predicted data. The values for the predicted data take the last value from pastData and apply a decay function to show how much of something is left. I have the data split into two arrays (sampleData_History and sampleData_Future); I have also attempted this with the data combined (sampleData) and tried a conditional in the .foregroundStyle property. Chart { ForEach(sampleData_History) { item in RuleMark(x: .value("Now", Date.now, unit: .hour)).foregroundStyle(.orange) LineMark( x: .value("time", item.date, unit: .hour), y: .value("mg", item.amount) ) .foregroundStyle(Color.blue) AreaMark( x: .value("time", item.date, unit: .hour), y: .value("mg", item.amount) ).foregroundStyle(Color.teal.opacity(0.2)) } ForEach(sampleData_Future) { item in LineMark( x: .value("time", item.date, unit: .hour), y: .value("mg", item.amount) ) .foregroundStyle(Color.red) AreaMark( x: .value("time", item.date, unit: .hour), y: .value("mg", item.amount) ).foregroundStyle(Color.red.opacity(0.2)) } } The above code yields the screenshot below. In the ideal case, I'd like to have everything AFTER the RuleMark line be a different color. Am I missing something? Where might I look to figure this out? EDIT: I have also tried separating them into series to no avail
5
0
2k
Jun ’22
LineMark Does Not Respect .foregroundStyle Color choice
Working through the new Swift Chart framework and I am noticing LineMark does not seem to want to respect .foregroundStyle(.pink) (or any respective color) for more than one line. Apple's own Chart page lists an example that, when copied into Xcode 14 (beta 1) it does not render in preview as it does in their screenshot Data used: struct ProfitOverTime { var week: Int var profit: Double } let departmentAProfile: [ProfitOverTime] = [ .init(week: 1, profit: 21.5), .init(week: 2, profit: 19.2), .init(week: 3, profit: 18.4), .init(week: 4, profit: 21.0), .init(week: 5, profit: 19.7), .init(week: 6, profit: 14.7), .init(week: 7, profit: 22.1), .init(week: 8, profit: 18.0) ] let departmentBProfile: [ProfitOverTime] = [ .init(week: 1, profit: 5.7), .init(week: 2, profit: 12.0), .init(week: 3, profit: 11.9), .init(week: 4, profit: 18.0), .init(week: 5, profit: 15.9), .init(week: 6, profit: 16.7), .init(week: 7, profit: 12.1), .init(week: 8, profit: 19.0) ] Content View: struct ContentView: View {     var body: some View { Chart { ForEach(departmentAProfile, id: \.week) { LineMark( x: .value("Week", $0.week), y: .value("Profit A", $0.profit) ).foregroundStyle(.green) } ForEach(departmentBProfile, id: \.week) { LineMark( x: .value("Week", $0.week), y: .value("Profit B", $0.profit) ) .foregroundStyle(.green) } RuleMark( y: .value("Threshold", 20.0) ) .foregroundStyle(.teal) }     } } Produces
2
0
1.7k
Jun ’22
Xcode Bluetooth Quality Drop
Problem Statement I've noticed I cannot use any Bluetooth headphones, including AirPods et al, connected to my while running builds in Xcode. Each time, the quality of the music drops to something below 80s cassette tape level quality. Steps to Produce Connect a set of Bluetooth headphones. Start an audio stream. I am usually using Apple Music, but I've seen it work with YT videos as well. Open any Xcode project, even a new one. Build and run. You should notice the audio cut out and then phone in from its landline. Resolution Not really a bug, but curious if I am the only one experiencing this issue and/or if there are work arounds. I have taken to only connecting headphones to my phone and/or running the builds solely on the phone. Any solutions for remedying this quickly would also be helpful.
0
0
602
Oct ’21
Xcode Beta Deletion Help
I made the jump straight into Xcode 12 (Beta 1). Every thing seems to be running okay; the new features are AMAZING! However, there might have been a snag when I first downloaded and set up my profiles. Now, I cannot open the Preferences pane without Xcode crashing. Re-downloading the Beta (all 9+GB of it) results in the same crash. I am guessing this means I still have whatever PLIST from the previous install still on my Mac. I know there are some Terminal commands one can run to delete all custom settings and preferences (and their respective Plists). I also don't really care if I have to lose my Xcode 11 custom themes, etc. (should really start fresh anyway😉). I just want to be able to log in and change my Theme to something a bit easier on the eyes. What can I do to remove all Xcode associated files from my Mac? What else might I try before deleting ALL my Xcode instances?
0
0
474
Jun ’20