Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot find 'SectorMark' in scope

I’m trying create a Pie Charts in SwiftUI via SectorMark but I have a error "Cannot find ‘SectorMark’ in scope". So Swift detected this like a property or variable not like a method.

Please, help me find a solution

import SwiftUI
import Charts

struct MacroData {
    let name: String
    let value: Int
}

struct CircleIndicatorView: View {
    
    @State private var macros: [MacroData] = [
        .init(name: "Free money", value: 3800),
        .init(name: "Taxes", value: 800),
        .init(name: "Regular Payment", value: 3000)]
    
    var body: some View {
        VStack {
            Chart(macros, id: \.name) { macro in
                SectorMark(angle: .value("Macros", macro.value)
                
                )
                .foregroundStyle(by: .value("Name", macro.name))
            }
            .frame(height: 50)
            .chartXAxis(.hidden)
        }
        .padding()
    }
}

struct CircleIndicatorView_Previews: PreviewProvider {
    static var previews: some View {
        CircleIndicatorView()
    }
}

I try to find solution myself, but…
I know, this a new method, but how I can added it in my project?
Thank you everyone for help me

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

https://developer.apple.com/documentation/charts/sectormark

It is only available in Beta now.

iOS 17.0+ Beta
iPadOS 17.0+ Beta
macOS 14.0+ Beta
Mac Catalyst 17.0+ Beta
tvOS 17.0+ Beta
watchOS 10.0+ Beta
visionOS 1.0+ Beta

You need a developer account and Xcode 15 from

https://developer.apple.com/

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading