Post

Replies

Boosts

Views

Activity

How to reverse a custom Domain in Swift Charts?
I'm currently building an app in SwiftUI that needs to show some charts. Swift Charts has been quite helpful but I can't seem to set the domain of the chart just how I want it. The following chart display events that happend in a week and I want to display every hour even if nothing happened there, and I want the hours to go up, instead of the default where the new day start at the top of the chart. struct ChartView: View { let dataSets: [someData] // simplified date init let datemin = date(year:2025, month: 2, day: 24) let datemax = date(year:2025, month: 2, day: 25) var body: some View { Chart(dataset) { data in PointMark(x: .value("Day", data.day, unit: .weekday), y: .value("Time", data.time, unit: .minute)) } } // The focus is on this line .chartYScale(domain: .automatic(reversed: true)) } } The .chartYScale(domain:) modifier allows me to set the start of the day at the bottom, but still ignores some hours. If I instead use this Chart(...) { ... } .chartYScale(domain: datemin...datemax) The chart display every hour of the day, but now the start of the day is at the bottom. I can't seem to find a way to get both things at the same time. if I add both modifiers only the first one get applied while the other ignored. Any solutions or workarounds?
2
0
204
1w
¿How do I make Siri announce the local currency on notifications?
I'm currently testing the announce notifications feature and I can't seem to find out how to make Siri read aloud the current currency instead of dollars. My locale is es-CL (Chile). It uses the currency symbol $ and reads as Pesos locally or Chilean Pesos where the number 5000.1 is represented as 5.000,1 This is the notification content         let content = UNMutableNotificationContent()         content.body = "¡Has recibido un pago por $5.000!" Siri reads it aloud as "¡Has recibido un pago por 5.000 Dolares!" which translates to "You have received a payment for 5,000 Dollars", instead of the expected "¡Has recibido un pago por 5.000 Pesos!" -> "You have received a payment for 5,000 Pesos" I've tried changing the development region of the app, interpolating the string with NumberFormatter.localizedString(from: 5000, number: .currency), and with others styles( .currencyAccounting, .currencyISOCode and .currencyPlural) without good results. The last one seems to work buts it's not ideal since it outputs "5.000 pesos chilenos" which gets read as "5 pesos chilenos" which is not the correct amount (bug), it's as is you're not on Chile and I personally prefer it to be a symbol instead of words. I'm testing with my device which is setup with the region "Chile" Could someone help me find a solution?
5
1
1.2k
Jan ’23