DateValueFormatter.swift 567 B

1234567891011121314151617181920212223
  1. //
  2. // DateValueFormatter.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 DateValueFormatter: NSObject, AxisValueFormatter {
  11. private let dateFormatter = DateFormatter()
  12. override init() {
  13. super.init()
  14. dateFormatter.dateFormat = "dd MMM HH:mm"
  15. }
  16. public func stringForValue(_ value: Double, axis: AxisBase?) -> String {
  17. return dateFormatter.string(from: Date(timeIntervalSince1970: value))
  18. }
  19. }