Description.swift 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // Description.swift
  3. // Charts
  4. //
  5. // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda
  6. // A port of MPAndroidChart for iOS
  7. // Licensed under Apache License 2.0
  8. //
  9. // https://github.com/danielgindi/Charts
  10. //
  11. import Foundation
  12. import CoreGraphics
  13. #if canImport(UIKit)
  14. import UIKit
  15. #endif
  16. #if canImport(Cocoa)
  17. import Cocoa
  18. #endif
  19. @objc(ChartDescription)
  20. open class Description: ComponentBase
  21. {
  22. public override init()
  23. {
  24. #if os(tvOS)
  25. // 23 is the smallest recommended font size on the TV
  26. font = .systemFont(ofSize: 23)
  27. #elseif os(OSX)
  28. font = .systemFont(ofSize: NSUIFont.systemFontSize)
  29. #else
  30. font = .systemFont(ofSize: 8.0)
  31. #endif
  32. super.init()
  33. }
  34. /// The text to be shown as the description.
  35. @objc open var text: String?
  36. /// Custom position for the description text in pixels on the screen.
  37. open var position: CGPoint? = nil
  38. /// The text alignment of the description text. Default RIGHT.
  39. @objc open var textAlign: NSTextAlignment = NSTextAlignment.right
  40. /// Font object used for drawing the description text.
  41. @objc open var font: NSUIFont
  42. /// Text color used for drawing the description text
  43. @objc open var textColor = NSUIColor.labelOrBlack
  44. }