Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark Mode: Primary Labels #4175

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Charts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
C33E1AF5471A60BA42DAF52E /* RadarHighlighter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F368CF209744D8F3B85B1028 /* RadarHighlighter.swift */; };
C3F0DDB7F0A922F0BB7EDB8A /* IBarChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A53A9E42FC07FFDACA937C1 /* IBarChartDataSet.swift */; };
C7B150D740255670DEB9F455 /* Charts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65AD9E95D9ED4DC0BD73A743 /* Charts.framework */; };
C9AA360A2355F01F00C97D93 /* Platform+Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9AA36092355F01F00C97D93 /* Platform+Color.swift */; };
CB785FE9B6B312408D17BC3B /* ChartUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FDA09EF973925A110506799 /* ChartUtils.swift */; };
CC7F8198A13249B5DEBBF25E /* AnimatedViewPortJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 710D7C9B2F1DB4A331EE405A /* AnimatedViewPortJob.swift */; };
CEF68F42A5390A73113F3663 /* Renderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F66B32AD8A878CBD6DB6ED2 /* Renderer.swift */; };
Expand Down Expand Up @@ -289,6 +290,7 @@
C75935E899183DDFA181E2CC /* AxisRendererBase.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AxisRendererBase.swift; path = Source/Charts/Renderers/AxisRendererBase.swift; sourceTree = "<group>"; };
C8C9A105A7DB64F39DDA648B /* ComponentBase.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ComponentBase.swift; path = Source/Charts/Components/ComponentBase.swift; sourceTree = "<group>"; };
C8FB6219B143F8F7DA762950 /* TriangleShapeRenderer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = TriangleShapeRenderer.swift; path = Source/Charts/Renderers/Scatter/TriangleShapeRenderer.swift; sourceTree = "<group>"; };
C9AA36092355F01F00C97D93 /* Platform+Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Platform+Color.swift"; path = "Source/Charts/Utils/Platform+Color.swift"; sourceTree = "<group>"; };
C9FE42E868A225C116537368 /* ChartBaseDataSet.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ChartBaseDataSet.swift; path = Source/Charts/Data/Implementations/ChartBaseDataSet.swift; sourceTree = "<group>"; };
CB1DD1A0F64266A10EE94194 /* ScatterChartDataSet.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ScatterChartDataSet.swift; path = Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift; sourceTree = "<group>"; };
D2E1819D72CD7B6C4A4E8048 /* LineChartTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = LineChartTests.swift; path = Tests/Charts/LineChartTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -590,6 +592,7 @@
5A4CFFFB65819121595F06F1 /* Fill.swift */,
3ED23C354AFE81818D78E645 /* Platform.swift */,
97AD2D4520AF917100F9C24A /* Platform+Accessibility.swift */,
C9AA36092355F01F00C97D93 /* Platform+Color.swift */,
FF475B9593B9898853814340 /* Transformer.swift */,
324C9127B53A8D39C8B49277 /* TransformerHorizontalBarChart.swift */,
72EAEBB7CF73E33565FC2896 /* ViewPortHandler.swift */,
Expand Down Expand Up @@ -848,6 +851,7 @@
3395682A1E27756651FF6F4D /* BarChartData.swift in Sources */,
45C459FA25DFCBE62FA6A06C /* BarChartDataEntry.swift in Sources */,
17E994DA88777AA1D8CCFC58 /* BarChartDataSet.swift in Sources */,
C9AA360A2355F01F00C97D93 /* Platform+Color.swift in Sources */,
7C9CE6718D18859A35146098 /* BarLineScatterCandleBubbleChartData.swift in Sources */,
53A91F6F86740E26FE733639 /* BarLineScatterCandleBubbleChartDataSet.swift in Sources */,
E68CA3DC66EB638C956E09B8 /* BubbleChartData.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
// Copyright Β© 2017 jc. All rights reserved.
//

#if canImport(UIKit)
liuxuan30 marked this conversation as resolved.
Show resolved Hide resolved
import UIKit
#endif
import UIKit
import Charts

class PiePolylineChartViewController: DemoBaseViewController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ for index in 0..<ITEM_COUNT
//: ### BubbleChartDataSet
let set = BubbleChartDataSet(values: entries, label: "Bubble DataSet")
set.colors = ChartColorTemplates.vordiplom()
set.valueTextColor = NSUIColor.black
set.valueTextColor = NSUIColor.label
set.valueFont = NSUIFont.systemFont(ofSize: CGFloat(10.0))
set.drawValuesEnabled = true
set.normalizeSizeEnabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ rightAxis.granularityEnabled = false
//: ### Legend
let legend = chartView.legend
legend.font = NSUIFont(name: "HelveticaNeue-Light", size: CGFloat(12.0))!
legend.textColor = NSUIColor.black
legend.textColor = NSUIColor.label
legend.form = .square
legend.drawInside = false
legend.orientation = .horizontal
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
@objc open var noDataFont = NSUIFont.systemFont(ofSize: 12)

/// color of the no data text
@objc open var noDataTextColor: NSUIColor = NSUIColor.black
@objc open var noDataTextColor: NSUIColor = .label

/// alignment of the no data text
@objc open var noDataTextAlignment: NSTextAlignment = .left
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Charts/PieChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ open class PieChartView: PieRadarChartViewBase

attrString = NSMutableAttributedString(string: newValue!)
attrString?.setAttributes([
.foregroundColor: NSUIColor.black,
.foregroundColor: NSUIColor.label,
.font: NSUIFont.systemFont(ofSize: 12.0),
.paragraphStyle: paragraphStyle
], range: NSMakeRange(0, attrString!.length))
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Components/AxisBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ open class AxisBase: ComponentBase
private var _axisValueFormatter: IAxisValueFormatter?

@objc open var labelFont = NSUIFont.systemFont(ofSize: 10.0)
@objc open var labelTextColor = NSUIColor.black
@objc open var labelTextColor = NSUIColor.label

@objc open var axisLineColor = NSUIColor.gray
@objc open var axisLineWidth = CGFloat(0.5)
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Components/ChartLimitLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ open class ChartLimitLine: ComponentBase
@objc open var lineDashPhase = CGFloat(0.0)
@objc open var lineDashLengths: [CGFloat]?

@objc open var valueTextColor = NSUIColor.black
@objc open var valueTextColor = NSUIColor.label
@objc open var valueFont = NSUIFont.systemFont(ofSize: 13.0)

@objc open var drawLabelEnabled = true
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Components/Description.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ open class Description: ComponentBase
@objc open var font: NSUIFont

/// Text color used for drawing the description text
@objc open var textColor = NSUIColor.black
@objc open var textColor = NSUIColor.label
}
2 changes: 1 addition & 1 deletion Source/Charts/Components/Legend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ open class Legend: ComponentBase
@objc open var direction: Direction = Direction.leftToRight

@objc open var font: NSUIFont = NSUIFont.systemFont(ofSize: 10.0)
@objc open var textColor = NSUIColor.black
@objc open var textColor = NSUIColor.label

/// The form/shape of the legend forms
@objc open var form = Form.square
Expand Down
4 changes: 2 additions & 2 deletions Source/Charts/Data/Implementations/ChartBaseDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet, NSCopying

// default color
colors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0))
valueColors.append(NSUIColor.black)
valueColors.append(.label)
}

@objc public init(label: String?)
Expand All @@ -30,7 +30,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet, NSCopying

// default color
colors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0))
valueColors.append(NSUIColor.black)
valueColors.append(.label)

self.label = label
}
Expand Down
30 changes: 30 additions & 0 deletions Source/Charts/Utils/Platform+Color.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Platform+Color.swift
// Charts
//
// Created by Jacob Christie on 2019-10-15.
//

#if canImport(UIKit)
import UIKit

public typealias NSUIColor = UIColor
extension UIColor
{
@available(iOS, introduced: 8.0, obsoleted: 13.0)
@available(tvOS, introduced: 9.0, obsoleted: 13.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API not working

static var label: UIColor { .black }
}
#endif

#if canImport(AppKit)

import AppKit

public typealias NSUIColor = NSColor
extension NSColor
{
@available(macOS, introduced: 10.11, obsoleted: 10.14)
static var label: NSColor { .black }
}
#endif
2 changes: 0 additions & 2 deletions Source/Charts/Utils/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Foundation
#endif

public typealias NSUIFont = UIFont
public typealias NSUIColor = UIColor
public typealias NSUIEvent = UIEvent
public typealias NSUITouch = UITouch
public typealias NSUIImage = UIImage
Expand Down Expand Up @@ -218,7 +217,6 @@ import Cocoa
import Quartz

public typealias NSUIFont = NSFont
public typealias NSUIColor = NSColor
public typealias NSUIEvent = NSEvent
public typealias NSUITouch = NSTouch
public typealias NSUIImage = NSImage
Expand Down