XYMarkerView.swift 978 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // XYMarkerView.swift
  3. // ChartsDemo
  4. // Copyright © 2016 dcg. All rights reserved.
  5. //
  6. import Foundation
  7. import Charts
  8. #if canImport(UIKit)
  9. import UIKit
  10. #endif
  11. open class XYMarkerView: BalloonMarker
  12. {
  13. @objc open var xAxisValueFormatter: AxisValueFormatter?
  14. fileprivate var yFormatter = NumberFormatter()
  15. @objc public init(color: UIColor, font: UIFont, textColor: UIColor, insets: UIEdgeInsets,
  16. xAxisValueFormatter: AxisValueFormatter)
  17. {
  18. super.init(color: color, font: font, textColor: textColor, insets: insets)
  19. self.xAxisValueFormatter = xAxisValueFormatter
  20. yFormatter.minimumFractionDigits = 1
  21. yFormatter.maximumFractionDigits = 1
  22. }
  23. open override func refreshContent(entry: ChartDataEntry, highlight: Highlight)
  24. {
  25. setLabel("x: " + xAxisValueFormatter!.stringForValue(entry.x, axis: nil) + ", y: " + yFormatter.string(from: NSNumber(floatLiteral: entry.y))!)
  26. }
  27. }