Skip to content

Commit 85573ee

Browse files
jjatieliuxuan30
authored andcommitted
Chartviewbase redundant ivar (#3045)
* Fixed using wrong axis (Issue #2257) * fix #1830. credit from #2049 (#2874) * fix #1830. credit from #2049 * add combined chart unit tests for iOS, tvOS (macOS only have build process) * use iterater rather than index * Removed redundant ivars in BarLineChartViewBase (#3043) * Removed redundant ivars in favour of proper access control * Moved initialization of axes to their declaration to keep the same optionality exposed. * Update 4.0.0 with master (#3135) * Replaced relevant `ChartUtils` methods with `Double` extensions (#2994) * Replaced relevant `ChartUtils` methods with `Double` extensions Improves readability. `nextUp` is built in and provides the same functionality. * Updated `ChartUtilsTests` to match changes * add option to build demo projects unit tests on iOS (#3121) * add option to build demo projects unit tests on iOS * add ChartsDemo-OSX build test. * Update ViewPortHandler.swift (#3143) fix a small bug * Refactored ChartUtils method into CGPoint extension (#3087) * Refactored ChartUtils method into CGPoint extension * Replaced ChartUtils.defaultValueFormatter() * Codestyle fixes * ChartViewBase cleanup For the most part, condensing logic and using `guard` where appropriate Removed optionality of many internal variables as they were only optional to allow for deferred initialization. This is now replaced with lazy vars. Removed empty initializer overrides. `fileprivate` is now `private` * Removed redundant ivars In favour of proper access control * Fixes after merge * Renamed `animator` to `chartAnimator` on `ChartViewBase` to no conflict with `NSView`'s `animator()` method. * pulled latest master * Code style fix * Removed AxisRendererBase.swift * Fixed demos
1 parent e126844 commit 85573ee

File tree

56 files changed

+723
-736
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+723
-736
lines changed

Charts.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
B13C74B4FF705D7B595D01EF /* AxisValueFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BD9DF16AF59680A3BB49452 /* AxisValueFormatter.swift */; };
111111
B539114951455C35BADAE3F3 /* PieChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4FB5E3761EF8B4D1E1E1014 /* PieChartDataSet.swift */; };
112112
B6C9F450D937B87224D29D5C /* FillFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 818AC6B12505B7C0A53D62F9 /* FillFormatter.swift */; };
113+
B6BF9A561F91993A00E62A5D /* CombinedChartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6BF9A551F91993A00E62A5D /* CombinedChartTests.swift */; };
113114
B6DCC229615EFE706F64A37D /* LineScatterCandleRadarRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 923206233CA89FD03565FF87 /* LineScatterCandleRadarRenderer.swift */; };
114115
B85DEB06B4C1AFFC8A0E3295 /* CircleShapeRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECE1B1623D3AF69CECAE8562 /* CircleShapeRenderer.swift */; };
115116
BEFD9518F3A74ACF8FA33308 /* Charts.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F9922F0641F7955DC6CD324 /* Charts.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -267,6 +268,7 @@
267268
B137428B41C143D5115726C4 /* Description.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Description.swift; path = Source/Charts/Components/Description.swift; sourceTree = "<group>"; };
268269
B1BA6B21CBDF77A15848994F /* RadarChartDataSet.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RadarChartDataSet.swift; path = Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift; sourceTree = "<group>"; };
269270
B44829AF0ADA583F1F0279B7 /* BubbleChartDataSet.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BubbleChartDataSet.swift; path = Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift; sourceTree = "<group>"; };
271+
B6BF9A551F91993A00E62A5D /* CombinedChartTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CombinedChartTests.swift; path = Tests/Charts/CombinedChartTests.swift; sourceTree = "<group>"; };
270272
BA157EFF2F952192C11DF937 /* AnimatedMoveViewJob.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AnimatedMoveViewJob.swift; path = Source/Charts/Jobs/AnimatedMoveViewJob.swift; sourceTree = "<group>"; };
271273
BA1A58428DC4780BAB4EAADC /* CandleStickChartView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = CandleStickChartView.swift; path = Source/Charts/Charts/CandleStickChartView.swift; sourceTree = "<group>"; };
272274
BC19DC2434D65FFB446A61B7 /* XAxisRendererRadarChart.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = XAxisRendererRadarChart.swift; path = Source/Charts/Renderers/XAxisRendererRadarChart.swift; sourceTree = "<group>"; };
@@ -549,6 +551,7 @@
549551
5C3F5E1A69EC06E86505F7B1 /* BarChartTests.swift */,
550552
7AB9062A28AAB9469752A954 /* ChartUtilsTests.swift */,
551553
2243BBFB1FF156D000B49D0B /* EquatableTests.swift */,
554+
B6BF9A551F91993A00E62A5D /* CombinedChartTests.swift */,
552555
D2E1819D72CD7B6C4A4E8048 /* LineChartTests.swift */,
553556
064989451F5C99C7006E8BB3 /* Snapshot.swift */,
554557
);
@@ -964,6 +967,7 @@
964967
3B11556EB7DC034E2FC958E4 /* BarChartTests.swift in Sources */,
965968
8E1192F7A7152E9DA92C56A9 /* ChartUtilsTests.swift in Sources */,
966969
2243BBFD1FF156EC00B49D0B /* EquatableTests.swift in Sources */,
970+
B6BF9A561F91993A00E62A5D /* CombinedChartTests.swift in Sources */,
967971
2BF85BEA981B359A65E9BF67 /* LineChartTests.swift in Sources */,
968972
064989461F5C99C7006E8BB3 /* Snapshot.swift in Sources */,
969973
224EFF991FBAAC4700CF9B3B /* (null) in Sources */,

ChartsDemo-OSX/ChartsDemo-OSX/Demos/BarDemoViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ open class BarDemoViewController: NSViewController
5151

5252
self.barChartView.gridBackgroundColor = NSUIColor.white
5353

54-
self.barChartView.chartDescription?.text = "Barchart Demo"
54+
self.barChartView.chartDescription.text = "Barchart Demo"
5555
}
5656

5757
@IBAction func save(_ sender: AnyObject)

ChartsDemo-OSX/ChartsDemo-OSX/Demos/LineDemoViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ open class LineDemoViewController: NSViewController
3939

4040
self.lineChartView.gridBackgroundColor = NSUIColor.white
4141

42-
self.lineChartView.chartDescription?.text = "Linechart Demo"
42+
self.lineChartView.chartDescription.text = "Linechart Demo"
4343
}
4444

4545
override open func viewWillAppear()

ChartsDemo-OSX/ChartsDemo-OSX/Demos/PieDemoViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ open class PieDemoViewController: NSViewController
4444

4545
self.pieChartView.data = data
4646

47-
self.pieChartView.chartDescription?.text = "Piechart Demo"
47+
self.pieChartView.chartDescription.text = "Piechart Demo"
4848
}
4949

5050
override open func viewWillAppear()

ChartsDemo-OSX/ChartsDemo-OSX/Demos/RadarDemoViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ open class RadarDemoViewController: NSViewController
3636
ds2.colors = [NSUIColor.blue]
3737
data.addDataSet(ds2)
3838
self.radarChartView.data = data
39-
self.radarChartView.chartDescription?.text = "Radarchart Demo"
39+
self.radarChartView.chartDescription.text = "Radarchart Demo"
4040

4141
}
4242

ChartsDemo/Objective-C/Demos/CombinedChartViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ - (BarChartData *)generateBarData
206206
[set1 setColor:[UIColor colorWithRed:60/255.f green:220/255.f blue:78/255.f alpha:1.f]];
207207
set1.valueTextColor = [UIColor colorWithRed:60/255.f green:220/255.f blue:78/255.f alpha:1.f];
208208
set1.valueFont = [UIFont systemFontOfSize:10.f];
209-
set1.axisDependency = AxisDependencyLeft;
209+
set1.axisDependency = AxisDependencyRight;
210210

211211
BarChartDataSet *set2 = [[BarChartDataSet alloc] initWithValues:entries2 label:@""];
212212
set2.stackLabels = @[@"Stack 1", @"Stack 2"];
@@ -216,7 +216,7 @@ - (BarChartData *)generateBarData
216216
];
217217
set2.valueTextColor = [UIColor colorWithRed:61/255.f green:165/255.f blue:255/255.f alpha:1.f];
218218
set2.valueFont = [UIFont systemFontOfSize:10.f];
219-
set2.axisDependency = AxisDependencyLeft;
219+
set2.axisDependency = AxisDependencyRight;
220220

221221
float groupSpace = 0.06f;
222222
float barSpace = 0.02f; // x2 dataset

ChartsDemo/Swift/DemoBaseViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class DemoBaseViewController: UIViewController, ChartViewDelegate {
234234
chartView.drawSlicesUnderHoleEnabled = false
235235
chartView.holeRadiusPercent = 0.58
236236
chartView.transparentCircleRadiusPercent = 0.61
237-
chartView.chartDescription?.enabled = false
237+
chartView.chartDescription.enabled = false
238238
chartView.setExtraOffsets(left: 5, top: 10, right: 5, bottom: 5)
239239

240240
chartView.drawCenterTextEnabled = true
@@ -269,11 +269,11 @@ class DemoBaseViewController: UIViewController, ChartViewDelegate {
269269
}
270270

271271
func setup(radarChartView chartView: RadarChartView) {
272-
chartView.chartDescription?.enabled = false
272+
chartView.chartDescription.enabled = false
273273
}
274274

275275
func setup(barLineChartView chartView: BarLineChartViewBase) {
276-
chartView.chartDescription?.enabled = false
276+
chartView.chartDescription.enabled = false
277277

278278
chartView.dragEnabled = true
279279
chartView.setScaleEnabled(true)

ChartsDemo/Swift/Demos/AnotherBarChartViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AnotherBarChartViewController: DemoBaseViewController {
3333

3434
chartView.delegate = self
3535

36-
chartView.chartDescription?.enabled = false
36+
chartView.chartDescription.enabled = false
3737
chartView.maxVisibleCount = 60
3838
chartView.pinchZoomEnabled = false
3939
chartView.drawBarShadowEnabled = false

ChartsDemo/Swift/Demos/BubbleChartViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class BubbleChartViewController: DemoBaseViewController {
3535

3636
chartView.delegate = self
3737

38-
chartView.chartDescription?.enabled = false
38+
chartView.chartDescription.enabled = false
3939

4040
chartView.dragEnabled = false
4141
chartView.setScaleEnabled(true)

ChartsDemo/Swift/Demos/CandleStickChartViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class CandleStickChartViewController: DemoBaseViewController {
3636

3737
chartView.delegate = self
3838

39-
chartView.chartDescription?.enabled = false
39+
chartView.chartDescription.enabled = false
4040

4141
chartView.dragEnabled = false
4242
chartView.setScaleEnabled(true)

0 commit comments

Comments
 (0)