Skip to content

Commit

Permalink
For ChartsOrg#3917. make init(label: String?) convenient initializer (C…
Browse files Browse the repository at this point in the history
…hartsOrg#3973)

* fix ChartsOrg#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 SwiftPolar committed Mar 20, 2023
1 parent 7032e81 commit ed3a2ff
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 ed3a2ff

Please sign in to comment.