Skip to content

Commit

Permalink
Chartviewbase redundant ivar (#3045)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jjatie authored and liuxuan30 committed Jan 6, 2018
1 parent e126844 commit 85573ee
Show file tree
Hide file tree
Showing 56 changed files with 723 additions and 736 deletions.
4 changes: 4 additions & 0 deletions Charts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
B13C74B4FF705D7B595D01EF /* AxisValueFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BD9DF16AF59680A3BB49452 /* AxisValueFormatter.swift */; };
B539114951455C35BADAE3F3 /* PieChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4FB5E3761EF8B4D1E1E1014 /* PieChartDataSet.swift */; };
B6C9F450D937B87224D29D5C /* FillFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 818AC6B12505B7C0A53D62F9 /* FillFormatter.swift */; };
B6BF9A561F91993A00E62A5D /* CombinedChartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6BF9A551F91993A00E62A5D /* CombinedChartTests.swift */; };
B6DCC229615EFE706F64A37D /* LineScatterCandleRadarRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 923206233CA89FD03565FF87 /* LineScatterCandleRadarRenderer.swift */; };
B85DEB06B4C1AFFC8A0E3295 /* CircleShapeRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECE1B1623D3AF69CECAE8562 /* CircleShapeRenderer.swift */; };
BEFD9518F3A74ACF8FA33308 /* Charts.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F9922F0641F7955DC6CD324 /* Charts.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -267,6 +268,7 @@
B137428B41C143D5115726C4 /* Description.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Description.swift; path = Source/Charts/Components/Description.swift; sourceTree = "<group>"; };
B1BA6B21CBDF77A15848994F /* RadarChartDataSet.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RadarChartDataSet.swift; path = Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift; sourceTree = "<group>"; };
B44829AF0ADA583F1F0279B7 /* BubbleChartDataSet.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BubbleChartDataSet.swift; path = Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift; sourceTree = "<group>"; };
B6BF9A551F91993A00E62A5D /* CombinedChartTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CombinedChartTests.swift; path = Tests/Charts/CombinedChartTests.swift; sourceTree = "<group>"; };
BA157EFF2F952192C11DF937 /* AnimatedMoveViewJob.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AnimatedMoveViewJob.swift; path = Source/Charts/Jobs/AnimatedMoveViewJob.swift; sourceTree = "<group>"; };
BA1A58428DC4780BAB4EAADC /* CandleStickChartView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = CandleStickChartView.swift; path = Source/Charts/Charts/CandleStickChartView.swift; sourceTree = "<group>"; };
BC19DC2434D65FFB446A61B7 /* XAxisRendererRadarChart.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = XAxisRendererRadarChart.swift; path = Source/Charts/Renderers/XAxisRendererRadarChart.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -549,6 +551,7 @@
5C3F5E1A69EC06E86505F7B1 /* BarChartTests.swift */,
7AB9062A28AAB9469752A954 /* ChartUtilsTests.swift */,
2243BBFB1FF156D000B49D0B /* EquatableTests.swift */,
B6BF9A551F91993A00E62A5D /* CombinedChartTests.swift */,
D2E1819D72CD7B6C4A4E8048 /* LineChartTests.swift */,
064989451F5C99C7006E8BB3 /* Snapshot.swift */,
);
Expand Down Expand Up @@ -964,6 +967,7 @@
3B11556EB7DC034E2FC958E4 /* BarChartTests.swift in Sources */,
8E1192F7A7152E9DA92C56A9 /* ChartUtilsTests.swift in Sources */,
2243BBFD1FF156EC00B49D0B /* EquatableTests.swift in Sources */,
B6BF9A561F91993A00E62A5D /* CombinedChartTests.swift in Sources */,
2BF85BEA981B359A65E9BF67 /* LineChartTests.swift in Sources */,
064989461F5C99C7006E8BB3 /* Snapshot.swift in Sources */,
224EFF991FBAAC4700CF9B3B /* (null) in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ open class BarDemoViewController: NSViewController

self.barChartView.gridBackgroundColor = NSUIColor.white

self.barChartView.chartDescription?.text = "Barchart Demo"
self.barChartView.chartDescription.text = "Barchart Demo"
}

@IBAction func save(_ sender: AnyObject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ open class LineDemoViewController: NSViewController

self.lineChartView.gridBackgroundColor = NSUIColor.white

self.lineChartView.chartDescription?.text = "Linechart Demo"
self.lineChartView.chartDescription.text = "Linechart Demo"
}

override open func viewWillAppear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ open class PieDemoViewController: NSViewController

self.pieChartView.data = data

self.pieChartView.chartDescription?.text = "Piechart Demo"
self.pieChartView.chartDescription.text = "Piechart Demo"
}

override open func viewWillAppear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ open class RadarDemoViewController: NSViewController
ds2.colors = [NSUIColor.blue]
data.addDataSet(ds2)
self.radarChartView.data = data
self.radarChartView.chartDescription?.text = "Radarchart Demo"
self.radarChartView.chartDescription.text = "Radarchart Demo"

}

Expand Down
4 changes: 2 additions & 2 deletions ChartsDemo/Objective-C/Demos/CombinedChartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ - (BarChartData *)generateBarData
[set1 setColor:[UIColor colorWithRed:60/255.f green:220/255.f blue:78/255.f alpha:1.f]];
set1.valueTextColor = [UIColor colorWithRed:60/255.f green:220/255.f blue:78/255.f alpha:1.f];
set1.valueFont = [UIFont systemFontOfSize:10.f];
set1.axisDependency = AxisDependencyLeft;
set1.axisDependency = AxisDependencyRight;

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

float groupSpace = 0.06f;
float barSpace = 0.02f; // x2 dataset
Expand Down
6 changes: 3 additions & 3 deletions ChartsDemo/Swift/DemoBaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class DemoBaseViewController: UIViewController, ChartViewDelegate {
chartView.drawSlicesUnderHoleEnabled = false
chartView.holeRadiusPercent = 0.58
chartView.transparentCircleRadiusPercent = 0.61
chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false
chartView.setExtraOffsets(left: 5, top: 10, right: 5, bottom: 5)

chartView.drawCenterTextEnabled = true
Expand Down Expand Up @@ -269,11 +269,11 @@ class DemoBaseViewController: UIViewController, ChartViewDelegate {
}

func setup(radarChartView chartView: RadarChartView) {
chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false
}

func setup(barLineChartView chartView: BarLineChartViewBase) {
chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false

chartView.dragEnabled = true
chartView.setScaleEnabled(true)
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo/Swift/Demos/AnotherBarChartViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AnotherBarChartViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false
chartView.maxVisibleCount = 60
chartView.pinchZoomEnabled = false
chartView.drawBarShadowEnabled = false
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo/Swift/Demos/BubbleChartViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BubbleChartViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false

chartView.dragEnabled = false
chartView.setScaleEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CandleStickChartViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false

chartView.dragEnabled = false
chartView.setScaleEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ColoredLineChartViewController: DemoBaseViewController {
chart.delegate = self
chart.backgroundColor = color

chart.chartDescription?.enabled = false
chart.chartDescription.enabled = false

chart.dragEnabled = true
chart.setScaleEnabled(true)
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo/Swift/Demos/CombinedChartViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CombinedChartViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false

chartView.drawBarShadowEnabled = false
chartView.highlightFullBarEnabled = false
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo/Swift/Demos/LineChart1ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class LineChart1ViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false
chartView.dragEnabled = true
chartView.setScaleEnabled(true)
chartView.pinchZoomEnabled = true
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo/Swift/Demos/LineChart2ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class LineChart2ViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false
chartView.dragEnabled = true
chartView.setScaleEnabled(true)
chartView.pinchZoomEnabled = true
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo/Swift/Demos/LineChartFilledViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LineChartFilledViewController: DemoBaseViewController {

chartView.drawBordersEnabled = true

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false

chartView.pinchZoomEnabled = false
chartView.dragEnabled = true
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo/Swift/Demos/LineChartTimeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class LineChartTimeViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false

chartView.dragEnabled = true
chartView.setScaleEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MultipleBarChartViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false

chartView.pinchZoomEnabled = false
chartView.drawBarShadowEnabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MultipleLinesChartViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false

chartView.leftAxis.enabled = false
chartView.rightAxis.drawAxisLineEnabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class NegativeStackedBarChartViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false

chartView.drawBarShadowEnabled = false
chartView.drawValueAboveBarEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PositiveNegativeBarChartViewController: DemoBaseViewController {
chartView.drawBarShadowEnabled = false
chartView.drawValueAboveBarEnabled = true

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false

chartView.rightAxis.enabled = false

Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo/Swift/Demos/RadarChartViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class RadarChartViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false
chartView.webLineWidth = 1
chartView.innerWebLineWidth = 1
chartView.webColor = .lightGray
Expand Down
4 changes: 2 additions & 2 deletions ChartsDemo/Swift/Demos/ScatterChartViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class ScatterChartViewController: DemoBaseViewController {
.toggleData]

chartView.delegate = self
chartView.chartDescription?.enabled = false

chartView.chartDescription.enabled = false

chartView.dragEnabled = true
chartView.setScaleEnabled(true)
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo/Swift/Demos/SinusBarChartViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SinusBarChartViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false

chartView.drawBarShadowEnabled = false
chartView.drawValueAboveBarEnabled = false
Expand Down
2 changes: 1 addition & 1 deletion ChartsDemo/Swift/Demos/StackedBarChartViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class StackedBarChartViewController: DemoBaseViewController {

chartView.delegate = self

chartView.chartDescription?.enabled = false
chartView.chartDescription.enabled = false

chartView.maxVisibleCount = 40
chartView.drawBarShadowEnabled = false
Expand Down
64 changes: 49 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ def type
end

def project_name
'Charts.xcodeproj'
'ChartsDemo/ChartsDemo.xcodeproj'
end

def macos_project_name
'ChartsDemo-OSX/ChartsDemo-OSX.xcodeproj'
end

def configuration
Expand All @@ -29,6 +33,19 @@ def build_schemes
]
end

def build_demo_schemes
%i[
ChartsDemo
ChartsDemo-Swift
]
end

def build_macos_demo_schemes
[
'ChartsDemo-OSX'
]
end

def test_schemes
[
'ChartsTests'
Expand Down Expand Up @@ -74,33 +91,43 @@ def xcodebuild(type, name, scheme, configuration, sdk, destination, tasks, xcpre
sh "set -o pipefail && xcodebuild #{project_type} '#{name}' -scheme '#{scheme}' -configuration '#{configuration}' -sdk #{sdk} -destination #{destination} #{tasks} | bundle exec xcpretty -c #{xcprety_args}"
end

def run_xcodebuild(schemes_to_execute, tasks, destination, is_test, xcprety_args)
def run_xcodebuild(tasks, destination, is_build_demo, xcprety_args)
sdk = destination[:sdk]
device = destination[:device]
uuid = destination[:uuid]

is_test = tasks.include?('test')
is_macos = sdk == 'macosx'

project = is_macos ? macos_project_name : project_name

schemes_to_execute = []
if is_test
schemes_to_execute = test_schemes
elsif is_build_demo
schemes_to_execute = is_macos ? build_macos_demo_schemes : build_demo_schemes
else
schemes_to_execute = build_schemes
end

open_simulator_and_sleep uuid if is_test

schemes_to_execute.each do |scheme|
xcodebuild type, project_name, scheme, configuration, sdk, device, tasks, xcprety_args
xcodebuild type, project, scheme, configuration, sdk, device, tasks, xcprety_args
end
end

def execute(tasks, platform, xcprety_args: '')
is_test = tasks.include?('test')

def execute(tasks, platform, is_build_demo = false, xcprety_args: '')
# platform specific settings
destination = devices[platform]

schemes = is_test ? test_schemes : build_schemes

# check if xcodebuild needs to be run on multiple devices
if destination.is_a?(Array)
destination.each do |destination|
run_xcodebuild schemes, tasks, destination, is_test, xcprety_args
run_xcodebuild tasks, destination, is_build_demo, xcprety_args
end
else
run_xcodebuild schemes, tasks, destination, is_test, xcprety_args
run_xcodebuild tasks, destination, is_build_demo, xcprety_args
end
end

Expand All @@ -122,11 +149,18 @@ end
desc 'Run CI tasks. Build and test or build depending on the platform.'
task :ci, [:platform] do |_task, args|
platform = arg_to_key(args[:platform]) if args.key?(:platform)

if test_platforms.include?(platform)
execute 'clean test', platform
elsif build_platforms.include?(platform)
execute 'clean build', platform
is_build_demo = test_platforms.include?(platform) || build_platforms.include?(platform)

if test_platforms.include?(platform) # iOS and tvOS
if platform == :iOS
execute 'clean', platform, is_build_demo
execute 'build', platform, is_build_demo
execute 'test', platform # not use demo specifically
else
execute 'clean test', platform
end
elsif build_platforms.include?(platform) # macOS
execute 'clean build', platform, is_build_demo
else
test_platforms.each do |platform|
execute 'clean test', platform
Expand Down
Loading

0 comments on commit 85573ee

Please sign in to comment.