Skip to content

Commit

Permalink
For #3917. make init(label: String?) convenient initializer (#3973)
Browse files Browse the repository at this point in the history
* fix #3917. make `init(label: String?)` to be a convenient init to enable auto inheritance.

* add UT for default dataSet label
  • Loading branch information
liuxuan30 authored and jjatie committed Apr 30, 2019
1 parent cd1120b commit 899fe1d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ open class ChartDataSet: ChartBaseDataSet
super.init()
}

public override init(label: String?)
public override convenience init(label: String?)
{
entries = []

super.init(label: label)
self.init(entries: nil, label: label)
}

@objc public init(entries: [ChartDataEntry]?, label: String?)
Expand Down
10 changes: 10 additions & 0 deletions Tests/Charts/BarChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ class BarChartTests: FBSnapshotTestCase
let dataSet = setupDefaultDataSet(chartDataEntries: dataEntries)
let chart = setupDefaultChart(dataSets: [dataSet])
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)

}

func testDefaultBarDataSetLabels()
{
let dataEntries = setupDefaultValuesDataEntries()
let dataSet = BarChartDataSet(entries: dataEntries)
dataSet.drawIconsEnabled = false
let chart = setupDefaultChart(dataSets: [dataSet])
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testZeroValues()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 899fe1d

Please sign in to comment.