XYMarkerView.swift 1.0 KB

1234567891011121314151617181920212223242526272829303132
  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. public class XYMarkerView: BalloonMarker {
  11. public var xAxisValueFormatter: IAxisValueFormatter
  12. fileprivate var yFormatter = NumberFormatter()
  13. public init(color: UIColor, font: UIFont, textColor: UIColor, insets: UIEdgeInsets,
  14. xAxisValueFormatter: IAxisValueFormatter) {
  15. self.xAxisValueFormatter = xAxisValueFormatter
  16. yFormatter.minimumFractionDigits = 1
  17. yFormatter.maximumFractionDigits = 1
  18. super.init(color: color, font: font, textColor: textColor, insets: insets)
  19. }
  20. public override func refreshContent(entry: ChartDataEntry, highlight: Highlight) {
  21. let string = "x: "
  22. + xAxisValueFormatter.stringForValue(entry.x, axis: XAxis())
  23. + ", y: "
  24. + yFormatter.string(from: NSNumber(floatLiteral: entry.y))!
  25. setLabel(string)
  26. }
  27. }