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

Receive callback with Node on tap #5

Open
mateuszjablonski opened this issue Feb 8, 2020 · 2 comments
Open

Receive callback with Node on tap #5

mateuszjablonski opened this issue Feb 8, 2020 · 2 comments

Comments

@mateuszjablonski
Copy link

I am using the chart as a part of user interface, enabling them to select the option, that interests them most. Is it possible to receive a callback with a node, after user taps on it? Also it would be nice to be able to disable focused state for nodes, so that you need to tap only once to go inside/outside note.

@OpConTech
Copy link

In ArcView.swift there is func isNodeSelected() -> Bool {}

So you could customize that function. For example:

func isNodeSelected() -> Bool {
        print("Node is selected....", configuration.selectedNode?.name ?? "node name not found")
        return configuration.allowsSelection && arc.node == configuration.selectedNode
  }

@OpConTech
Copy link

I just noticed that in DataModel.swift @lludo made the entire configuration observable and published all the vars:
public class SunburstConfiguration: ObservableObject

So all you have to do is use .onRecieve for your SwiftUI view to monitor for any tap on an arc:

        VStack {
            SunburstView(configuration: configuration)
            
        }.onReceive(configuration.$selectedNode, perform: { _ in
            Print(configuration.selectedNode?.name, " is the selected node...")
        })

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

No branches or pull requests

2 participants