CoreData and 'Charts'

I want to get data from coredata and present it as a chart. During the build process, it builds without any problem, but the chart is not visible when the actual app is run. I put some data in coredata.

Why?

import SwiftUI

import SwiftUICharts

import CoreData



struct ChartView: View{

    @Environment(\.managedObjectContext) private var viewContext



    @FetchRequest var items: FetchedResults<Item>

    

    @State var demoData: [Double] = []

    

    init() {

        let request: NSFetchRequest<Item> = Item.fetchRequest()

        

        request.sortDescriptors = [

                NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)

            ]

        

        

        request.fetchLimit = 7

        _items = FetchRequest(fetchRequest: request)

        

        for i in items{

            demoData.append(i.think)

        }

    }

    

    var body: some View{

        BarChart()

            .data(demoData)

            .chartStyle(ChartStyle(backgroundColor: .white,

                                           foregroundColor: ColorGradient(.blue, .purple)))

    }



}

What is "BarChart"?

func of package

its not "import SwiftUICharts" its "import Charts". maybe that was the problem

CoreData and 'Charts'
 
 
Q