-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
PIE-CHART how to get the index of the selected slice.??? #1267
Comments
did you checked the delegate protocol? It seems like |
Hi , thanx for the quick reply . I could not find the delegate protocol in the library .(swift library) |
Just search |
sir , i have searched chartValueSelected everywhere in all swift classes. i am not able to find it. |
sir , i found it finally . thank you very much for the awesome library and your quick and helpful reply. have a nice day . cheers ! |
sir , just one last question. |
I would you suggest to take a look at ChartsDemo, there are examples |
sir , i am sorry for disturbing you again and again but i am frustated. my delegate function is not getting called. please help me. i have tried setting the delegate in my class and have searched hundreds of questions on stackoverflow but not able to get anywhere. please let me know the exact steps to follow to make this work. please help sir. i really need it |
let me tell you what i have done. class Test : UIViewController { viewDidLoad(){ setChart() func setChart(){ var obj = Test() } } extension Test : ChartViewDelegate { func chartValueSelected(chartView: ChartViewBase, entry: ChartDataEntry, dataSetIndex: Int, highlight: ChartHighlight) { print(chartDataEntry) } i have done it this way and i know something is wrong here. please tell me what to do exactly. I BEG YOU! :( |
Hi, I'm not a chart collaborators but I use charts. For your specific case above, you are declaring an object of Test and trying to use it's delegate to get selected notifications, but Test is a UIViewController and is not descending from any ChartView, so it's delegate cannot be a ChartView delegate. This is basic iOS programming that you will learn more effectively elsewhere. There is a technique that you can, and indeed should, use when writing your own chart, or debugging one. You should always start from and/or refer to the demo. When starting a new chart, find the corresponding code in the demo, copy it to your class, and run and verify that it works just like it does in the demo. Check this version into source control. Now that you know you have a working version, you can begin modifying it. In this way you will know that any changes you make are your own issue, and you can go back to when it worked. In your specific case, go to ChartsDemo and look at PieChartViewController. Set a breakpoint in chartValueSelected. Then run it in the iOS simulator, and chose Pie Chart from the list. Click on a pie piece, and you will see that your break point is hit. This means that it is likely the issue you are having is not a charts issue. You can use this file as a starting point. |
Thanks @dxclancy At least you should be write below on your own: let pieChart = PieChartView()
pieChart.delegate = self and implement |
thanx alot . i am just new to delegates not a beginner in programming |
dxclancy. thanx brother for getting straight to the point and explaining me the concept. |
@liuxuan30 I just added manually marker using |
i have looked at almost the whole library . but i could not find how do we get the index of the slice selected . please help me with this . i am stuck at this from a weak . please help.
The text was updated successfully, but these errors were encountered: