I'm learning to use the iOS Charts and I wasn't sure if I should make 1 or two questions, first I have been trying to create a pop up when the user clicks over a value. I have been reading the code from the ChartsDemo but I don't really understand whats going on since it is in Objective-C, I've been reading some questions about this on this site, so I added the ChartViewDelegate
, also I have copied the BalloonMarker.swift file into my project and finally, I have seen that I need to add the chartValueSelected
function but I'm not sure if the BalloonMarker should be added inside the function, or where? the code of my function looks like this:
func chartValueSelected(chartView: ChartViewBase, entry: ChartDataEntry, dataSetIndex: Int, highlight: Highlight) {
let marker:BalloonMarker = BalloonMarker(color: UIColor.black, font: UIFont(name: "Helvetica", size: 12)!, textColor: UIColor.white, insets: UIEdgeInsets(top: 7.0, left: 7.0, bottom: 7.0, right: 7.0))
marker.minimumSize = CGSize(width: 75.0, height: 35.0)
chartView.marker = marker
}
But it says that BallonMaker is ambiguous without more context. Can anybody explain to me how to add this function? my chart alone works fine, so It's just about adding the value (It's a combined chart bar/line).
The second thing would be; my data comes from a struct that contains a Date (X Value), a Double (Y Value) and a comment (String), is it possible to add the String content to the popup with the x and y values?
Thanks
For Marker you need to add marker in Charts not in selected method
Please try to add below code and assign marker to your Chart Object.
let marker:BalloonMarker = BalloonMarker(color: UIColor.redColor(), font: UIFont(name: "Helvetica", size: 12)!, insets: UIEdgeInsets(top: 7.0, left: 7.0, bottom: 7.0, right: 7.0))
marker.minimumSize = CGSizeMake(75.0, 35.0)
chartView.marker = marker
Hope this will helps.