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
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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
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.