Post

Replies

Boosts

Views

Activity

Reply to Replace substring using regex in a string
Looks like my implementation seems off static func roundOff(_ val: String, _ decimalPlace: Int) -> String {     let decimalFormatter = createDecimalFormatter()     decimalFormatter.minimumFractionDigits = decimalPlace     decimalFormatter.maximumFractionDigits = decimalPlace     let bigDecimal = NSDecimalNumber(string: val)     return decimalFormatter.string(from: bigDecimal.rounding(accordingToBehavior: NSDecimalNumberHandler(roundingMode: .up, scale: Int16(decimalPlace), raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false)))!   } static func cel2far(_ celsius: Double) -> String {     return roundOff(String(celsius * 9.0 / 5.0 + 32.0), 0)   }   static func far2cel(_ fahrenheit: Double) -> String {     return roundOff(String((fahrenheit - 32.0) * 0.5555555555555556), 0)   } LOL
Mar ’23
Reply to Swift Chart has too many labels on x-axis. How to lessen them?
This is the chart data struct ChartData : Identifiable {   var id = UUID()   var date: String   var rainfallTo: Int   var tempMean: Int } and the chart code Chart(createChartData(city)) {               LineMark(                 x: .value(StringTool.localize("date"), $0.date),                 y: .value("Rainfall mm", $0.rainfallTo),                 series: .value("type", StringTool.localize("rainfall_mm"))               )               .foregroundStyle(by: .value("type", StringTool.localize("rainfall_mm")))               LineMark(                 x: .value(StringTool.localize("date"), $0.date),                 y: .value(StringTool.localize("temperature"), $0.tempMean),                 series: .value("type", StringTool.localize("temperature"))               )               .foregroundStyle(by: .value("type", StringTool.localize("temperature"))) }
Jan ’23