Tophat Gordon Tophat Gordon - 1 year ago 375
Swift Question

Create a MarkerView when user clicks on Chart

I have searched and searched for how to display the MarkerView when the user clicks on a bar in a bar chart using Charts (was iOS-charts) for Swift.

The documentation states the library is capable of "Highlighting values (with customizable popup-views)" using MarkerViews, but I don't know how to show one.

I want a little tool tip to display, like the image below, when the user clicks on a bar in the bar chart.

Tool tip on bar graph

I have the chartValueSelected function ready which fires when a bar is selected.

Answer Source

So you are using Charts right?

Did you check BallonMarker.swift?



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)


BalloonMarker *marker = [[BalloonMarker alloc] initWithColor:[UIColor colorWithRed:14.0/255.0 alpha:1.0] font:[UIFont systemFontOfSize:12.0] insets: UIEdgeInsetsMake(7.0, 7.0, 7.0, 7.0)];
marker.minimumSize = CGSizeMake(75.f, 35.f);
_chartView.marker = marker;