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

Accessibility Support for (most) Chart types #3520

Merged
merged 19 commits into from
Jul 6, 2018
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1691036
Adds accessibility for Pie Charts. (#1060)
mathewa6 May 10, 2018
2f00321
Formatting & cleanup in PieChartRenderer. (#1060)
mathewa6 May 12, 2018
74b418a
Added accessibility to base classes. (#1060)
mathewa6 May 14, 2018
4adff89
Extended NSUIView to abstract Platform accessibility. (#1060)
mathewa6 May 18, 2018
557d0d3
Merge branch 'master' of github.com:danielgindi/Charts into accessibi…
mathewa6 May 18, 2018
2bfca15
Minor file structure & accessibility fix. (#1060)
mathewa6 May 18, 2018
bce41d3
Fixed missing accessibility file.
mathewa6 May 19, 2018
b9f6a14
Added accessibility for Bar charts. (#1060)
mathewa6 May 20, 2018
0b15b6e
Added accessibility for Horizontal bars. (#1060)
mathewa6 May 21, 2018
44f7519
Added accessibility for Line charts. (#1060)
mathewa6 May 27, 2018
2329bd7
Added accessibility for Bubble charts. (#1060)
mathewa6 May 27, 2018
0a35b86
Added accessibility for Radar charts. (#1060)
mathewa6 May 29, 2018
5a3cc22
Merge branch 'master' of github.com:danielgindi/Charts
mathewa6 Jun 18, 2018
867a502
Bug fixes in Bubble and Line Chart accessibility. (#1060)
mathewa6 Jun 18, 2018
99aadf5
Added accessibility for CandleStick charts. (#1060)
mathewa6 Jun 18, 2018
afaf9e5
Fixed accessibility frame calculation on macOS. (#1060)
mathewa6 Jun 19, 2018
c785766
Unified accessible header creation for renderers. (#1060)
mathewa6 Jun 20, 2018
a77b5ef
Fixed incorrect accessibility frames for Bar chart. (#1060)
mathewa6 Jun 20, 2018
71f5c34
Minor change to adhere to UIAccessibility docs. (#1060)
mathewa6 Jun 29, 2018
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 @@ -98,6 +98,7 @@
9400725714D0DA707DDECD2E /* ViewPortJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA7BDB22C97F39A4B33E38A7 /* ViewPortJob.swift */; };
95B6D6F35684292A62DBEA74 /* LineChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A75AA73C5AA381DA517959 /* LineChartDataSet.swift */; };
967EE2EDDE3337C5C4337C59 /* IndexAxisValueFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10DD0A02E3CF611BD11EBA9B /* IndexAxisValueFormatter.swift */; };
97AD2D4620AF917100F9C24A /* Platform+Accessibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97AD2D4520AF917100F9C24A /* Platform+Accessibility.swift */; };
97E033CC0ABEF0F448DAFA8E /* DataApproximator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93EF9709CF635BEE70D1ABC5 /* DataApproximator.swift */; };
98E2EEF45E8933E4AD182D58 /* ChartViewBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30EFAD7920F76360ADB3B5F5 /* ChartViewBase.swift */; };
9A26C8DB1F87B01700367599 /* DataApproximator+N.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A26C8DA1F87B01700367599 /* DataApproximator+N.swift */; };
Expand Down Expand Up @@ -257,6 +258,7 @@
923206233CA89FD03565FF87 /* LineScatterCandleRadarRenderer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = LineScatterCandleRadarRenderer.swift; path = Source/Charts/Renderers/LineScatterCandleRadarRenderer.swift; sourceTree = "<group>"; };
9249AD9AEC8C85772365A128 /* ILineScatterCandleRadarChartDataSet.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ILineScatterCandleRadarChartDataSet.swift; path = Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift; sourceTree = "<group>"; };
93EF9709CF635BEE70D1ABC5 /* DataApproximator.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = DataApproximator.swift; path = Source/Charts/Filters/DataApproximator.swift; sourceTree = "<group>"; };
97AD2D4520AF917100F9C24A /* Platform+Accessibility.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Platform+Accessibility.swift"; path = "Source/Charts/Utils/Platform+Accessibility.swift"; sourceTree = "<group>"; };
998F2BFE318471AFC05B50AC /* IHighlighter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = IHighlighter.swift; path = Source/Charts/Highlight/IHighlighter.swift; sourceTree = "<group>"; };
9A26C8DA1F87B01700367599 /* DataApproximator+N.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "DataApproximator+N.swift"; path = "Source/Charts/Filters/DataApproximator+N.swift"; sourceTree = "<group>"; };
9D7184C8A5A60A3522AB9B05 /* BarChartDataProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BarChartDataProvider.swift; path = Source/Charts/Interfaces/BarChartDataProvider.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -584,6 +586,7 @@
3FDA09EF973925A110506799 /* ChartUtils.swift */,
5A4CFFFB65819121595F06F1 /* Fill.swift */,
3ED23C354AFE81818D78E645 /* Platform.swift */,
97AD2D4520AF917100F9C24A /* Platform+Accessibility.swift */,
FF475B9593B9898853814340 /* Transformer.swift */,
324C9127B53A8D39C8B49277 /* TransformerHorizontalBarChart.swift */,
72EAEBB7CF73E33565FC2896 /* ViewPortHandler.swift */,
Expand Down Expand Up @@ -923,6 +926,7 @@
24151B0729D77251A8494D70 /* LineRadarRenderer.swift in Sources */,
B6DCC229615EFE706F64A37D /* LineScatterCandleRadarRenderer.swift in Sources */,
795E100895C24049509F1EDE /* PieChartRenderer.swift in Sources */,
97AD2D4620AF917100F9C24A /* Platform+Accessibility.swift in Sources */,
69EA073EDF75D49ABE1715D6 /* RadarChartRenderer.swift in Sources */,
CEF68F42A5390A73113F3663 /* Renderer.swift in Sources */,
796D3E63A37A95FD9D1AB9A1 /* ChevronDownShapeRenderer.swift in Sources */,
Expand Down
6 changes: 6 additions & 0 deletions Source/Charts/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
attributes: attrs)
}

// MARK: - Accessibility

open override func accessibilityChildren() -> [Any]? {
return renderer?.accessibleChartElements
}

// MARK: - Highlighting

/// - returns: The array of currently highlighted values. This might an empty if nothing is highlighted.
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 @@ -34,7 +34,7 @@ open class Description: ComponentBase
}

/// The text to be shown as the description.
@objc open var text: String? = "Description Label"
@objc open var text: String?

/// Custom position for the description text in pixels on the screen.
open var position: CGPoint? = nil
Expand Down
16 changes: 16 additions & 0 deletions Source/Charts/Data/Implementations/Standard/ChartData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -756,4 +756,20 @@ open class ChartData: NSObject

return max
}

// MARK: - Accessibility

/// When the data entry labels are generated identifiers, set this property to prepend a string before each identifier
///
/// For example, if a label is "#3", settings this property to "Item" allows it to be spoken as "Item #3"
@objc open var accessibilityEntryLabelPrefix: String?

/// When the data entry value requires a unit, use this property to append the string representation of the unit to the value
///
/// For example, if a value is "44.1", setting this property to "m" allows it to be spoken as "44.1 m"
@objc open var accessibilityEntryLabelSuffix: String?

/// If the data entry value is a count, set this to true to allow plurals and other grammatical changes
/// **default**: false
@objc open var accessibilityEntryLabelSuffixIsCount: Bool = false
}
40 changes: 20 additions & 20 deletions Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,34 @@ open class PieChartDataSet: ChartDataSet, IPieChartDataSet
case insideSlice
case outsideSlice
}

private func initialize()
{
self.valueTextColor = NSUIColor.white
self.valueFont = NSUIFont.systemFont(ofSize: 13.0)
}

public required init()
{
super.init()
initialize()
}

public override init(values: [ChartDataEntry]?, label: String?)
{
super.init(values: values, label: label)
initialize()
}

internal override func calcMinMax(entry e: ChartDataEntry)
{
calcMinMaxY(entry: e)
}

// MARK: - Styling functions and accessors

private var _sliceSpace = CGFloat(0.0)

/// the space in pixels between the pie-slices
/// **default**: 0
/// **maximum**: 20
Expand All @@ -74,42 +74,42 @@ open class PieChartDataSet: ChartDataSet, IPieChartDataSet

/// When enabled, slice spacing will be 0.0 when the smallest value is going to be smaller than the slice spacing itself.
open var automaticallyDisableSliceSpacing: Bool = false

/// indicates the selection distance of a pie slice
open var selectionShift = CGFloat(18.0)

open var xValuePosition: ValuePosition = .insideSlice
open var yValuePosition: ValuePosition = .insideSlice

/// When valuePosition is OutsideSlice, indicates line color
open var valueLineColor: NSUIColor? = NSUIColor.black

/// When valuePosition is OutsideSlice, indicates line width
open var valueLineWidth: CGFloat = 1.0

/// When valuePosition is OutsideSlice, indicates offset as percentage out of the slice size
open var valueLinePart1OffsetPercentage: CGFloat = 0.75

/// When valuePosition is OutsideSlice, indicates length of first half of the line
open var valueLinePart1Length: CGFloat = 0.3

/// When valuePosition is OutsideSlice, indicates length of second half of the line
open var valueLinePart2Length: CGFloat = 0.4

/// When valuePosition is OutsideSlice, this allows variable line length
open var valueLineVariableLength: Bool = true

/// the font for the slice-text labels
open var entryLabelFont: NSUIFont? = nil

/// the color for the slice-text labels
open var entryLabelColor: NSUIColor? = nil

/// the color for the highlighted sector
open var highlightColor: NSUIColor? = nil

// MARK: - NSCopying

open override func copyWithZone(_ zone: NSZone?) -> AnyObject
{
let copy = super.copyWithZone(zone) as! PieChartDataSet
Expand Down
27 changes: 14 additions & 13 deletions Source/Charts/Data/Interfaces/IPieChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,46 @@ import CoreGraphics
public protocol IPieChartDataSet: IChartDataSet
{
// MARK: - Styling functions and accessors

/// the space in pixels between the pie-slices
/// **default**: 0
/// **maximum**: 20
var sliceSpace: CGFloat { get set }

/// When enabled, slice spacing will be 0.0 when the smallest value is going to be smaller than the slice spacing itself.
var automaticallyDisableSliceSpacing: Bool { get set }

/// indicates the selection distance of a pie slice
var selectionShift: CGFloat { get set }

var xValuePosition: PieChartDataSet.ValuePosition { get set }
var yValuePosition: PieChartDataSet.ValuePosition { get set }

/// When valuePosition is OutsideSlice, indicates line color
var valueLineColor: NSUIColor? { get set }

/// When valuePosition is OutsideSlice, indicates line width
var valueLineWidth: CGFloat { get set }

/// When valuePosition is OutsideSlice, indicates offset as percentage out of the slice size
var valueLinePart1OffsetPercentage: CGFloat { get set }

/// When valuePosition is OutsideSlice, indicates length of first half of the line
var valueLinePart1Length: CGFloat { get set }

/// When valuePosition is OutsideSlice, indicates length of second half of the line
var valueLinePart2Length: CGFloat { get set }

/// When valuePosition is OutsideSlice, this allows variable line length
var valueLineVariableLength: Bool { get set }

/// the font for the slice-text labels
var entryLabelFont: NSUIFont? { get set }

/// the color for the slice-text labels
var entryLabelColor: NSUIColor? { get set }

/// get/sets the color for the highlighted sector
var highlightColor: NSUIColor? { get set }

}
Loading