XYMarkerView.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // XYMarkerView.swift
  3. // ChartsDemo-iOS
  4. //
  5. // Created by Jacob Christie on 2017-07-09.
  6. // Copyright © 2017 jc. All rights reserved.
  7. //
  8. import Foundation
  9. import Charts
  10. #if canImport(UIKit)
  11. import UIKit
  12. #endif
  13. public class XYMarkerView: BalloonMarker {
  14. public var xAxisValueFormatter: IAxisValueFormatter
  15. fileprivate var yFormatter = NumberFormatter()
  16. public var isSeleted:Bool = false{
  17. didSet{
  18. if self.isSeleted == true {
  19. self.rightView?.isHidden = false
  20. self.leftView?.isHidden = false
  21. self.circleView?.isHidden = false
  22. }else{
  23. self.rightView?.isHidden = true
  24. self.leftView?.isHidden = true
  25. self.circleView?.isHidden = true
  26. }
  27. }
  28. }
  29. public init(color: UIColor, font: UIFont, textColor: UIColor, insets: UIEdgeInsets,
  30. xAxisValueFormatter: IAxisValueFormatter) {
  31. self.xAxisValueFormatter = xAxisValueFormatter
  32. yFormatter.minimumFractionDigits = 1
  33. yFormatter.maximumFractionDigits = 1
  34. super.init(color: color, font: font, textColor: textColor, insets: insets)
  35. }
  36. public override func refreshContent(entry: ChartDataEntry, highlight: Highlight) {
  37. let string = "x: "
  38. + xAxisValueFormatter.stringForValue(entry.x, axis: XAxis())
  39. + ", y: "
  40. + yFormatter.string(from: NSNumber(floatLiteral: entry.y))!
  41. setLabel(string)
  42. }
  43. }