2

Any one found solution for custom marker Image using charts library. i want to add custom marker like in the bellow picture , anyone can help me. Thanks

enter image description here

Malleswari
  • 427
  • 3
  • 11

1 Answers1

0

I have used custom image in one of my graph

Please check below code to add marker with custom image in it.

let marker = BalloonMarker(color: .clear,
                               font: UIFont.systemFont(ofSize: 10.0, weight: UIFont.Weight.bold),
                               textColor: .black,
                               insets: UIEdgeInsetsMake(2, 2, 2, 2))

marker.chartView = self
marker.image = UIImage.init(named: "dialog_popup")
marker.minimumSize = CGSize(width:42,height:42)
self.marker = marker
self.drawMarkers = true

By adding this code marker is enabled in your chart.

Now do one more change in BalloonMarker class:

add below line in draw() method of above class:

image!.draw(in: rect)

Hope this will helps!

CodeChanger
  • 7,953
  • 5
  • 49
  • 80