I would like to put an image that indicates this data point is the lowest point in the data. I made a picture to explain what I want. I am using BarChartView and RadarChartView.
I think this question is similar to my question but I need to get position to put UIImage. If I know the position, I can do it or do addSubview
. getMarkerPosition
function looks useful to determine the right position.
Also, ChartMarker
looks helpful. In the ChartsDemo
some chart views are using BalloonMarker
. It is almost what I want to do. Here is a quote from RadarChartViewController.m
.
BalloonMarker *marker = [[BalloonMarker alloc] initWithColor:[UIColor colorWithWhite:180/255. alpha:1.0] font:[UIFont systemFontOfSize:12.0] insets: UIEdgeInsetsMake(8.0, 8.0, 20.0, 8.0)];
marker.minimumSize = CGSizeMake(80.f, 40.f);
_chartView.marker = marker;
BalloonMarker is created and added to _chartView.marker
. Therefore, a marker comes up when an user clicks on a bar but I want to show a marker always. In other words, the library decides the right time to show and hide a marker . I couldn't find the way to pop up a marker actively.
I would be grateful if you could tell me the way to do this. Thank you.
In BarChartRenderer
class you can find method
public override func drawValues(context context: CGContext)
inside body of if (!dataSet.isStacked)
in the for-loop you can first define the minimum value using e.value
and corresponding valuePoint
variable, so after loop you will have coordinates where the minimum value will be drawn and adding some offset you can draw also your marker
let image = UIImage(named: "MARKER")
image?.drawInRect(CGRect(x: valuePoint.x, y: SOME_OFFSET + valuePoint.y + (val >= 0.0 ? posOffset : negOffset), width: 16, height: 16))
Or in
public func drawDataSet(context context: CGContext, dataSet: IBarChartDataSet, index: Int)
You can find barRect
of the smallest bar and play with that results.