Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Data structure #95

Open
AppPear opened this issue May 24, 2020 · 2 comments · Fixed by #114
Open

Create Data structure #95

AppPear opened this issue May 24, 2020 · 2 comments · Fixed by #114
Labels

Comments

@AppPear
Copy link
Owner

AppPear commented May 24, 2020

v2 ticket

Ticket description:

This should hold and handle the values for charts. You should create it in a way that changes in the source data can be automatically reflected in the charts.

  • should be a structure which can hold a x and y value.
  • y value must be numeric (possibly floating point number)
  • x can be numeric or string
  • has to be at least 3 initialisers: 1) only y values, 2) x and y numeric values 3) x string and y numeric values
  • changes in the source are reflected in the charts automatically

More info: #89

@AppPear AppPear added the v2 label May 24, 2020
@satan87
Copy link
Contributor

satan87 commented May 31, 2020

I did a simple test.

import SwiftUI
import SwiftUICharts

struct ContentView: View {
    
    @State var data: [Double] = [1, 2, 3]
    
    var body: some View {
        
        VStack {
            
            CardView {
                ChartView(data: self.data)
                ChartLabel("Test \(self.data[0])")
            }
            
            Button(action: {
                self.data[0] += 1
                print(self.data[0])
            }) {
                Text("Click to add")
            }
        
        }
    }
}

I can see the value of the ChartLabel being updated.
But the graph is not being updated...

I manage to have the BarCell, and BarChart update using Binding for the value instead of State.
But still, when using ChartView, there is no update.

Should we use @EnvironmentObject, and move to somehing like this:
ChartView().environmentObject(DataControler(Data: [1,2,3]))

@satan87
Copy link
Contributor

satan87 commented Jun 1, 2020

PR #112
I manage to arrive at the result by using Binding, all the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants