diff --git a/.gitignore b/.gitignore index 08553fa8d1..8ba8e0ead7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,13 @@ # Xcode # +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated build/ +DerivedData/ + +## Various settings *.pbxuser !default.pbxuser *.mode1v3 @@ -12,23 +18,57 @@ build/ !default.mode2v3 *.perspectivev3 !default.perspectivev3 -xcuserdata +xcuserdata/ + +## Other *.xccheckout *.moved-aside +*.xcuserstate + +## Obj-C/Swift specific DerivedData *.hmap *.ipa -*.xcuserstate +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +.build/ project.xcworkspace # CocoaPods # # We recommend against adding the Pods directory to your .gitignore. However # you should judge for yourself, the pros and cons are mentioned at: -# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control # # Pods/ +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output Carthage Charts.framework.zip ChartsRealm.framework.zip diff --git a/.swift-version b/.swift-version deleted file mode 100644 index 9f55b2ccb5..0000000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -3.0 diff --git a/.travis.yml b/.travis.yml index 55be7baa43..3f56fe5082 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,23 @@ -osx_image: xcode8 +osx_image: xcode8.3 language: objective-c - rvm: - - 2.2 - +- 2.2 env: global: - - LANG=en_US.UTF-8 - + - LANG=en_US.UTF-8 + - secure: HRl5Cg3/LmTJYCSDGtV8Fiqf6OgWXR6C5YkNviOElU9YmcCTvnmE7MCm+gK8hJNIQ2mWCBTlxTC7jJxeYlx0D+JQ6IhRc75B4zXgbtth6HCzlvhWDcBbNU/K+JPDjy2EAoVgvf8Xseq6GqM4WcVg2Pwr9PS3aaH/SKDE6yVoPXRM2wXRAxIdxayqm/RQgG88jAKgg+Ub5DKW/c9NLLbUf/WdY9SgQDJtqeZCMv7G3/IzW34KZgVPsqSrPByzZXbf7KgYkYLQlscH4mcUctk1qxhdCae//zcgUZo/utpXWbPXQqtvDpuqrg9IRvoGxa/D1I7dLSJsVnk4aP7RW18vn4HJ82C2AiEp+lU2TQE9y5lXcGssZVIa5aZNTWL90HVer3Kg6AnHffvdCSZ/UHsMZJFURUXL9fRIlWVGuEDeQOqlV6lUmEtp/BiEdV4D5PuCyT6snsmEwkc51goyqh6uS6XhJyqYEQdxdoybznwp91tVmASsRybppIGHTkcWN5csF4zQt40tEwd8LoqM+bBUo0wxKiKsNsecL4JA+YDYs2saZY9U3s8jAaIon+qDu071fPRaPEvBhYHYDhy4cTvBXibyGUYGHkrgLu0w19wDfHcJKt2In58yOmaCCLNoTGp/ZLNVRyZ8VDlj/NdJ2dWpMsL2Aj7OxU065kCL2FlvuRU= matrix: - - PLATFORM="iOS" - - PLATFORM="tvOS" - - PLATFORM="macOS" - + - PLATFORM="iOS" + - PLATFORM="tvOS" + - PLATFORM="macOS" cache: - - bundler - +- bundler before_install: - - brew update - - brew upgrade carthage || true - - carthage version - - carthage bootstrap --platform $PLATFORM - +- brew update +- brew upgrade carthage || true +- carthage version +- carthage bootstrap --platform $PLATFORM script: - - bundle exec rake ci[$PLATFORM] - +- bundle exec rake ci[$PLATFORM] after_success: - - bash <(curl -s https://codecov.io/bash) - +- bash <(curl -s https://codecov.io/bash) diff --git a/Cartfile b/Cartfile index b2fb29b34e..e69de29bb2 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +0,0 @@ -github "realm/realm-cocoa" ~> 1.1 \ No newline at end of file diff --git a/Cartfile.resolved b/Cartfile.resolved index 705065c9b3..e6cc748142 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1 @@ -github "facebook/ios-snapshot-test-case" "da629211c17a4c507e2e866e8a19ed3122af770b" -github "realm/realm-cocoa" "v1.1.0" +github "facebook/ios-snapshot-test-case" "c1808fb4435ffc3db2203e7623935f39fc31aa8f" diff --git a/Charts.podspec b/Charts.podspec index 8e10b9359c..22d8f68630 100644 --- a/Charts.podspec +++ b/Charts.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Charts" - s.version = "3.0.1" + s.version = "3.0.2" s.summary = "Charts is a powerful & easy to use chart library for iOS, tvOS and OSX (and Android)" s.homepage = "https://github.com/danielgindi/Charts" s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" } @@ -14,10 +14,4 @@ Pod::Spec.new do |s| s.subspec "Core" do |ss| ss.source_files = "Source/Charts/**/*.swift" end - - s.subspec "Realm" do |ss| - ss.source_files = "Source/ChartsRealm/**/*.swift" - ss.dependency "Charts/Core" - ss.dependency "RealmSwift", "~> 1.1" - end end diff --git a/Charts.xcodeproj/project.pbxproj b/Charts.xcodeproj/project.pbxproj index 293966f73f..cd1b497477 100644 --- a/Charts.xcodeproj/project.pbxproj +++ b/Charts.xcodeproj/project.pbxproj @@ -142,25 +142,11 @@ 06B120C41D811B8900D14B02 /* Transformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120401D811B8900D14B02 /* Transformer.swift */; }; 06B120C51D811B8900D14B02 /* TransformerHorizontalBarChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120411D811B8900D14B02 /* TransformerHorizontalBarChart.swift */; }; 06B120C61D811B8900D14B02 /* ViewPortHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120421D811B8900D14B02 /* ViewPortHandler.swift */; }; - 06B120EB1D811E8E00D14B02 /* RealmBarDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120DE1D811E8E00D14B02 /* RealmBarDataSet.swift */; }; - 06B120EC1D811E8E00D14B02 /* RealmBarLineScatterCandleBubbleDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120DF1D811E8E00D14B02 /* RealmBarLineScatterCandleBubbleDataSet.swift */; }; - 06B120ED1D811E8E00D14B02 /* RealmBaseDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120E01D811E8E00D14B02 /* RealmBaseDataSet.swift */; }; - 06B120EE1D811E8E00D14B02 /* RealmBubbleDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120E11D811E8E00D14B02 /* RealmBubbleDataSet.swift */; }; - 06B120EF1D811E8E00D14B02 /* RealmCandleDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120E21D811E8E00D14B02 /* RealmCandleDataSet.swift */; }; - 06B120F01D811E8E00D14B02 /* RealmLineDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120E31D811E8E00D14B02 /* RealmLineDataSet.swift */; }; - 06B120F11D811E8E00D14B02 /* RealmLineRadarDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120E41D811E8E00D14B02 /* RealmLineRadarDataSet.swift */; }; - 06B120F21D811E8E00D14B02 /* RealmLineScatterCandleRadarDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120E51D811E8E00D14B02 /* RealmLineScatterCandleRadarDataSet.swift */; }; - 06B120F31D811E8E00D14B02 /* RealmPieDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120E61D811E8E00D14B02 /* RealmPieDataSet.swift */; }; - 06B120F41D811E8E00D14B02 /* RealmRadarDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120E71D811E8E00D14B02 /* RealmRadarDataSet.swift */; }; - 06B120F51D811E8E00D14B02 /* RealmScatterDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B120E81D811E8E00D14B02 /* RealmScatterDataSet.swift */; }; - 06B120F91D811E9600D14B02 /* ChartsRealm.h in Headers */ = {isa = PBXBuildFile; fileRef = 06B120F71D811E9600D14B02 /* ChartsRealm.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 06B121151D81214300D14B02 /* Charts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06165F241D8110E600722320 /* Charts.framework */; }; - 06B3C0F11D99F82700B1DF43 /* ChartsRealm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06B120D51D811E6200D14B02 /* ChartsRealm.framework */; }; 06B3C0F71D99F85400B1DF43 /* BarChartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B3C0F31D99F85400B1DF43 /* BarChartTests.swift */; }; 06B3C0F81D99F85400B1DF43 /* LineChartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B3C0F41D99F85400B1DF43 /* LineChartTests.swift */; }; - 06B3C0F91D99F85400B1DF43 /* ChartsRealmTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B3C0F61D99F85400B1DF43 /* ChartsRealmTest.swift */; }; 5B56A9CD1D905EB300F58178 /* Description.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B56A9CC1D905EB300F58178 /* Description.swift */; }; 5BF8813B1DDC4DF70033370C /* IndexAxisValueFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BF8813A1DDC4DF70033370C /* IndexAxisValueFormatter.swift */; }; + D8A58A411DCE2EF8007BB012 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D8A58A401DCE2EF8007BB012 /* Media.xcassets */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -171,13 +157,6 @@ remoteGlobalIDString = 06165F231D8110E600722320; remoteInfo = Charts; }; - 06B3C0EF1D99F82300B1DF43 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 06165F1B1D8110E600722320 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 06B120D41D811E6200D14B02; - remoteInfo = ChartsRealm; - }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -319,26 +298,12 @@ 06B120401D811B8900D14B02 /* Transformer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Transformer.swift; sourceTree = ""; }; 06B120411D811B8900D14B02 /* TransformerHorizontalBarChart.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransformerHorizontalBarChart.swift; sourceTree = ""; }; 06B120421D811B8900D14B02 /* ViewPortHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewPortHandler.swift; sourceTree = ""; }; - 06B120D51D811E6200D14B02 /* ChartsRealm.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ChartsRealm.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 06B120DE1D811E8E00D14B02 /* RealmBarDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmBarDataSet.swift; sourceTree = ""; }; - 06B120DF1D811E8E00D14B02 /* RealmBarLineScatterCandleBubbleDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmBarLineScatterCandleBubbleDataSet.swift; sourceTree = ""; }; - 06B120E01D811E8E00D14B02 /* RealmBaseDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmBaseDataSet.swift; sourceTree = ""; }; - 06B120E11D811E8E00D14B02 /* RealmBubbleDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmBubbleDataSet.swift; sourceTree = ""; }; - 06B120E21D811E8E00D14B02 /* RealmCandleDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmCandleDataSet.swift; sourceTree = ""; }; - 06B120E31D811E8E00D14B02 /* RealmLineDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmLineDataSet.swift; sourceTree = ""; }; - 06B120E41D811E8E00D14B02 /* RealmLineRadarDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmLineRadarDataSet.swift; sourceTree = ""; }; - 06B120E51D811E8E00D14B02 /* RealmLineScatterCandleRadarDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmLineScatterCandleRadarDataSet.swift; sourceTree = ""; }; - 06B120E61D811E8E00D14B02 /* RealmPieDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmPieDataSet.swift; sourceTree = ""; }; - 06B120E71D811E8E00D14B02 /* RealmRadarDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmRadarDataSet.swift; sourceTree = ""; }; - 06B120E81D811E8E00D14B02 /* RealmScatterDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmScatterDataSet.swift; sourceTree = ""; }; - 06B120F71D811E9600D14B02 /* ChartsRealm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChartsRealm.h; path = "Source/Supporting Files/ChartsRealm.h"; sourceTree = ""; }; - 06B120F81D811E9600D14B02 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = "Source/Supporting Files/Info.plist"; sourceTree = ""; }; 06B121111D81201C00D14B02 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = "Tests/Supporting Files/Info.plist"; sourceTree = SOURCE_ROOT; }; 06B3C0F31D99F85400B1DF43 /* BarChartTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BarChartTests.swift; sourceTree = ""; }; 06B3C0F41D99F85400B1DF43 /* LineChartTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LineChartTests.swift; sourceTree = ""; }; - 06B3C0F61D99F85400B1DF43 /* ChartsRealmTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartsRealmTest.swift; sourceTree = ""; }; 5B56A9CC1D905EB300F58178 /* Description.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Description.swift; sourceTree = ""; }; 5BF8813A1DDC4DF70033370C /* IndexAxisValueFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IndexAxisValueFormatter.swift; sourceTree = ""; }; + D8A58A401DCE2EF8007BB012 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Media.xcassets; path = Charts/ChartsTests/Media.xcassets; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -353,19 +318,10 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 06B3C0F11D99F82700B1DF43 /* ChartsRealm.framework in Frameworks */, 06165F2F1D8110E600722320 /* Charts.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; - 06B120D11D811E6200D14B02 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 06B121151D81214300D14B02 /* Charts.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -374,7 +330,6 @@ children = ( 063FF0401D8CC9940094A042 /* Carthage.xcconfig */, 06500D381D81115900156E8A /* Charts */, - 06B120CD1D811D9D00D14B02 /* ChartsRealm */, 06165F321D8110E700722320 /* ChartsTests */, 06165F251D8110E600722320 /* Products */, ); @@ -385,7 +340,6 @@ children = ( 06165F241D8110E600722320 /* Charts.framework */, 06165F2E1D8110E600722320 /* ChartsTests.xctest */, - 06B120D51D811E6200D14B02 /* ChartsRealm.framework */, ); name = Products; sourceTree = ""; @@ -394,7 +348,6 @@ isa = PBXGroup; children = ( 06B3C0F21D99F85400B1DF43 /* Charts */, - 06B3C0F51D99F85400B1DF43 /* ChartsRealm */, 06761B5D1D98176000D5CE09 /* ChartUtilsTests.swift */, 06B1210D1D811FF200D14B02 /* Supporting Files */, ); @@ -691,55 +644,11 @@ path = Source/Charts/Utils; sourceTree = ""; }; - 06B120CD1D811D9D00D14B02 /* ChartsRealm */ = { - isa = PBXGroup; - children = ( - 06B120CE1D811DAE00D14B02 /* Classes */, - 06B120CF1D811DB400D14B02 /* Supporting Files */, - ); - name = ChartsRealm; - sourceTree = ""; - }; - 06B120CE1D811DAE00D14B02 /* Classes */ = { - isa = PBXGroup; - children = ( - 06B120DD1D811E8E00D14B02 /* Data */, - ); - name = Classes; - sourceTree = ""; - }; - 06B120CF1D811DB400D14B02 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 06B120F71D811E9600D14B02 /* ChartsRealm.h */, - 06B120F81D811E9600D14B02 /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; - 06B120DD1D811E8E00D14B02 /* Data */ = { - isa = PBXGroup; - children = ( - 06B120DE1D811E8E00D14B02 /* RealmBarDataSet.swift */, - 06B120DF1D811E8E00D14B02 /* RealmBarLineScatterCandleBubbleDataSet.swift */, - 06B120E01D811E8E00D14B02 /* RealmBaseDataSet.swift */, - 06B120E11D811E8E00D14B02 /* RealmBubbleDataSet.swift */, - 06B120E21D811E8E00D14B02 /* RealmCandleDataSet.swift */, - 06B120E31D811E8E00D14B02 /* RealmLineDataSet.swift */, - 06B120E41D811E8E00D14B02 /* RealmLineRadarDataSet.swift */, - 06B120E51D811E8E00D14B02 /* RealmLineScatterCandleRadarDataSet.swift */, - 06B120E61D811E8E00D14B02 /* RealmPieDataSet.swift */, - 06B120E71D811E8E00D14B02 /* RealmRadarDataSet.swift */, - 06B120E81D811E8E00D14B02 /* RealmScatterDataSet.swift */, - ); - name = Data; - path = Source/ChartsRealm/Data; - sourceTree = ""; - }; 06B1210D1D811FF200D14B02 /* Supporting Files */ = { isa = PBXGroup; children = ( 06B121111D81201C00D14B02 /* Info.plist */, + D8A58A401DCE2EF8007BB012 /* Media.xcassets */, ); name = "Supporting Files"; sourceTree = ""; @@ -754,15 +663,6 @@ path = Tests/Charts; sourceTree = SOURCE_ROOT; }; - 06B3C0F51D99F85400B1DF43 /* ChartsRealm */ = { - isa = PBXGroup; - children = ( - 06B3C0F61D99F85400B1DF43 /* ChartsRealmTest.swift */, - ); - name = ChartsRealm; - path = Tests/ChartsRealm; - sourceTree = SOURCE_ROOT; - }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -774,14 +674,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 06B120D21D811E6200D14B02 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 06B120F91D811E9600D14B02 /* ChartsRealm.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ @@ -811,12 +703,11 @@ 06165F2A1D8110E600722320 /* Sources */, 06165F2B1D8110E600722320 /* Frameworks */, 06165F2C1D8110E600722320 /* Resources */, - 06500E641D8116FC00156E8A /* Copy Carthage Frameworks */, + B6355D621EA9B71800B74B2E /* Copy Carthage Frameworks */, ); buildRules = ( ); dependencies = ( - 06B3C0F01D99F82300B1DF43 /* PBXTargetDependency */, 06165F311D8110E600722320 /* PBXTargetDependency */, ); name = ChartsTests; @@ -824,25 +715,6 @@ productReference = 06165F2E1D8110E600722320 /* ChartsTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; - 06B120D41D811E6200D14B02 /* ChartsRealm */ = { - isa = PBXNativeTarget; - buildConfigurationList = 06B120DA1D811E6200D14B02 /* Build configuration list for PBXNativeTarget "ChartsRealm" */; - buildPhases = ( - 061DF29D1D93774D0002B03B /* Build Dependencies */, - 06B120D01D811E6200D14B02 /* Sources */, - 06B120D11D811E6200D14B02 /* Frameworks */, - 06B120D21D811E6200D14B02 /* Headers */, - 06B120D31D811E6200D14B02 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = ChartsRealm; - productName = ChartsRealm; - productReference = 06B120D51D811E6200D14B02 /* ChartsRealm.framework */; - productType = "com.apple.product-type.framework"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -858,9 +730,6 @@ 06165F2D1D8110E600722320 = { CreatedOnToolsVersion = 7.3.1; }; - 06B120D41D811E6200D14B02 = { - CreatedOnToolsVersion = 7.3.1; - }; }; }; buildConfigurationList = 06165F1E1D8110E600722320 /* Build configuration list for PBXProject "Charts" */; @@ -876,7 +745,6 @@ projectRoot = ""; targets = ( 06165F231D8110E600722320 /* Charts */, - 06B120D41D811E6200D14B02 /* ChartsRealm */, 06165F2D1D8110E600722320 /* ChartsTests */, ); }; @@ -894,34 +762,13 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 06B120D31D811E6200D14B02 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( + D8A58A411DCE2EF8007BB012 /* Media.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 061DF29D1D93774D0002B03B /* Build Dependencies */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "", - ); - name = "Build Dependencies"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "exec \"${SRCROOT}/scripts/build-dependencies.sh\"\n"; - }; 064DBAE11D93813D002584CD /* Build Dependencies */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -936,21 +783,20 @@ shellPath = /bin/sh; shellScript = "exec \"${SRCROOT}/scripts/build-dependencies.sh\"\n"; }; - 06500E641D8116FC00156E8A /* Copy Carthage Frameworks */ = { + B6355D621EA9B71800B74B2E /* Copy Carthage Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( FBSnapshotTestCase, - Realm, ); name = "Copy Carthage Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "exec \"${SRCROOT}/scripts/copy-carthage-frameworks.sh\"\n"; + shellScript = " exec \"${SRCROOT}/scripts/copy-carthage-frameworks.sh\""; }; /* End PBXShellScriptBuildPhase section */ @@ -1100,31 +946,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 06B3C0F91D99F85400B1DF43 /* ChartsRealmTest.swift in Sources */, 06B3C0F81D99F85400B1DF43 /* LineChartTests.swift in Sources */, 06B3C0F71D99F85400B1DF43 /* BarChartTests.swift in Sources */, 06761B5E1D98176000D5CE09 /* ChartUtilsTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - 06B120D01D811E6200D14B02 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 06B120EC1D811E8E00D14B02 /* RealmBarLineScatterCandleBubbleDataSet.swift in Sources */, - 06B120F31D811E8E00D14B02 /* RealmPieDataSet.swift in Sources */, - 06B120F21D811E8E00D14B02 /* RealmLineScatterCandleRadarDataSet.swift in Sources */, - 06B120F41D811E8E00D14B02 /* RealmRadarDataSet.swift in Sources */, - 06B120EB1D811E8E00D14B02 /* RealmBarDataSet.swift in Sources */, - 06B120F11D811E8E00D14B02 /* RealmLineRadarDataSet.swift in Sources */, - 06B120EF1D811E8E00D14B02 /* RealmCandleDataSet.swift in Sources */, - 06B120EE1D811E8E00D14B02 /* RealmBubbleDataSet.swift in Sources */, - 06B120F01D811E8E00D14B02 /* RealmLineDataSet.swift in Sources */, - 06B120ED1D811E8E00D14B02 /* RealmBaseDataSet.swift in Sources */, - 06B120F51D811E8E00D14B02 /* RealmScatterDataSet.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -1133,11 +960,6 @@ target = 06165F231D8110E600722320 /* Charts */; targetProxy = 06165F301D8110E600722320 /* PBXContainerItemProxy */; }; - 06B3C0F01D99F82300B1DF43 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 06B120D41D811E6200D14B02 /* ChartsRealm */; - targetProxy = 06B3C0EF1D99F82300B1DF43 /* PBXContainerItemProxy */; - }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -1250,6 +1072,7 @@ 06165F391D8110E700722320 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1268,6 +1091,7 @@ 06165F3A1D8110E700722320 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1312,46 +1136,6 @@ }; name = Release; }; - 06B120DB1D811E6200D14B02 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 063FF0401D8CC9940094A042 /* Carthage.xcconfig */; - buildSettings = { - COMBINE_HIDPI_IMAGES = YES; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_VERSION = A; - INFOPLIST_FILE = "$(SRCROOT)/Source/Supporting Files/Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - OTHER_SWIFT_FLAGS = "-DNEEDS_CHARTS"; - PRODUCT_BUNDLE_IDENTIFIER = com.dcg.ChartsRealm; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 06B120DC1D811E6200D14B02 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 063FF0401D8CC9940094A042 /* Carthage.xcconfig */; - buildSettings = { - COMBINE_HIDPI_IMAGES = YES; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_VERSION = A; - INFOPLIST_FILE = "$(SRCROOT)/Source/Supporting Files/Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - OTHER_SWIFT_FLAGS = "-DNEEDS_CHARTS"; - PRODUCT_BUNDLE_IDENTIFIER = com.dcg.ChartsRealm; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -1382,15 +1166,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 06B120DA1D811E6200D14B02 /* Build configuration list for PBXNativeTarget "ChartsRealm" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 06B120DB1D811E6200D14B02 /* Debug */, - 06B120DC1D811E6200D14B02 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ }; rootObject = 06165F1B1D8110E600722320 /* Project object */; diff --git a/Charts.xcodeproj/xcshareddata/xcschemes/Charts.xcscheme b/Charts.xcodeproj/xcshareddata/xcschemes/Charts.xcscheme index 76f7cb0101..4002aea0ad 100644 --- a/Charts.xcodeproj/xcshareddata/xcschemes/Charts.xcscheme +++ b/Charts.xcodeproj/xcshareddata/xcschemes/Charts.xcscheme @@ -1,6 +1,6 @@ + + + + + + + + diff --git a/Charts.xcodeproj/xcshareddata/xcschemes/ChartsRealm.xcscheme b/Charts.xcodeproj/xcshareddata/xcschemes/ChartsRealm.xcscheme deleted file mode 100644 index 1d07df42e4..0000000000 --- a/Charts.xcodeproj/xcshareddata/xcschemes/ChartsRealm.xcscheme +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Charts.xcodeproj/xcshareddata/xcschemes/ChartsTests.xcscheme b/Charts.xcodeproj/xcshareddata/xcschemes/ChartsTests.xcscheme index 50082a65e3..1e75bd68d3 100644 --- a/Charts.xcodeproj/xcshareddata/xcschemes/ChartsTests.xcscheme +++ b/Charts.xcodeproj/xcshareddata/xcschemes/ChartsTests.xcscheme @@ -1,6 +1,6 @@ set in chartView.data.dataSets) + { + set.drawIconsEnabled = !set.isDrawIconsEnabled; + } + + [chartView setNeedsDisplay]; + } + if ([key isEqualToString:@"toggleHighlight"]) { chartView.data.highlightEnabled = !chartView.data.isHighlightEnabled; diff --git a/ChartsDemo/Classes/DemoListViewController.m b/ChartsDemo/Classes/DemoListViewController.m index 0c2a6ac763..d1f2f0dc78 100644 --- a/ChartsDemo/Classes/DemoListViewController.m +++ b/ChartsDemo/Classes/DemoListViewController.m @@ -33,7 +33,7 @@ #import "LineChartTimeViewController.h" #import "LineChartFilledViewController.h" #import "HalfPieChartViewController.h" -#import "RealmDemoListViewController.h" +#import "RealmDemosViewController.h" @interface DemoListViewController () @@ -173,7 +173,7 @@ - (void)viewDidLoad @{ @"title": @"Realm.io database", @"subtitle": @"This demonstrates how to use this library with Realm.io mobile database.", - @"class": RealmDemoListViewController.class + @"class": RealmDemosViewController.class } ]; //FIXME: Add TimeLineChart diff --git a/ChartsDemo/Classes/Demos/BarChartViewController.m b/ChartsDemo/Classes/Demos/BarChartViewController.m index b0dc8c0029..2792d00a6c 100644 --- a/ChartsDemo/Classes/Demos/BarChartViewController.m +++ b/ChartsDemo/Classes/Demos/BarChartViewController.m @@ -33,6 +33,7 @@ - (void)viewDidLoad self.options = @[ @{@"key": @"toggleValues", @"label": @"Toggle Values"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @@ -138,7 +139,11 @@ - (void)setDataCount:(int)count range:(double)range { double mult = (range + 1); double val = (double) (arc4random_uniform(mult)); - [yVals addObject:[[BarChartDataEntry alloc] initWithX:(double)i y:val]]; + if (arc4random_uniform(100) < 25) { + [yVals addObject:[[BarChartDataEntry alloc] initWithX:i y:val icon: [UIImage imageNamed:@"icon"]]]; + } else { + [yVals addObject:[[BarChartDataEntry alloc] initWithX:i y:val]]; + } } BarChartDataSet *set1 = nil; @@ -153,6 +158,7 @@ - (void)setDataCount:(int)count range:(double)range { set1 = [[BarChartDataSet alloc] initWithValues:yVals label:@"The year 2017"]; [set1 setColors:ChartColorTemplates.material]; + set1.drawIconsEnabled = NO; NSMutableArray *dataSets = [[NSMutableArray alloc] init]; [dataSets addObject:set1]; diff --git a/ChartsDemo/Classes/Demos/BubbleChartViewController.m b/ChartsDemo/Classes/Demos/BubbleChartViewController.m index e311f67b26..c12ad9271b 100644 --- a/ChartsDemo/Classes/Demos/BubbleChartViewController.m +++ b/ChartsDemo/Classes/Demos/BubbleChartViewController.m @@ -32,6 +32,7 @@ - (void)viewDidLoad self.options = @[ @{@"key": @"toggleValues", @"label": @"Toggle Values"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @@ -103,11 +104,11 @@ - (void)setDataCount:(int)count range:(double)range { double val = (double) (arc4random_uniform(range)); double size = (double) (arc4random_uniform(range)); - [yVals1 addObject:[[BubbleChartDataEntry alloc] initWithX:i y:val size:size]]; + [yVals1 addObject:[[BubbleChartDataEntry alloc] initWithX:i y:val size:size icon: [UIImage imageNamed:@"icon"]]]; val = (double) (arc4random_uniform(range)); size = (double) (arc4random_uniform(range)); - [yVals2 addObject:[[BubbleChartDataEntry alloc] initWithX:i y:val size:size]]; + [yVals2 addObject:[[BubbleChartDataEntry alloc] initWithX:i y:val size:size icon: [UIImage imageNamed:@"icon"]]]; val = (double) (arc4random_uniform(range)); size = (double) (arc4random_uniform(range)); @@ -115,11 +116,16 @@ - (void)setDataCount:(int)count range:(double)range } BubbleChartDataSet *set1 = [[BubbleChartDataSet alloc] initWithValues:yVals1 label:@"DS 1"]; + set1.drawIconsEnabled = NO; [set1 setColor:ChartColorTemplates.colorful[0] alpha:0.50f]; [set1 setDrawValuesEnabled:YES]; + BubbleChartDataSet *set2 = [[BubbleChartDataSet alloc] initWithValues:yVals2 label:@"DS 2"]; + set1.drawIconsEnabled = NO; + set2.iconsOffset = CGPointMake(0, 15); [set2 setColor:ChartColorTemplates.colorful[1] alpha:0.50f]; [set2 setDrawValuesEnabled:YES]; + BubbleChartDataSet *set3 = [[BubbleChartDataSet alloc] initWithValues:yVals3 label:@"DS 3"]; [set3 setColor:ChartColorTemplates.colorful[2] alpha:0.50f]; [set3 setDrawValuesEnabled:YES]; diff --git a/ChartsDemo/Classes/Demos/CandleStickChartViewController.m b/ChartsDemo/Classes/Demos/CandleStickChartViewController.m index d4e03a40a2..2fe219de28 100644 --- a/ChartsDemo/Classes/Demos/CandleStickChartViewController.m +++ b/ChartsDemo/Classes/Demos/CandleStickChartViewController.m @@ -32,6 +32,7 @@ - (void)viewDidLoad self.options = @[ @{@"key": @"toggleValues", @"label": @"Toggle Values"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @@ -100,13 +101,15 @@ - (void)setDataCount:(int)count range:(double)range double open = (double) (arc4random_uniform(6)) + 1.0; double close = (double) (arc4random_uniform(6)) + 1.0; BOOL even = i % 2 == 0; - [yVals1 addObject:[[CandleChartDataEntry alloc] initWithX:i shadowH:val + high shadowL:val - low open:even ? val + open : val - open close:even ? val - close : val + close]]; + [yVals1 addObject:[[CandleChartDataEntry alloc] initWithX:i shadowH:val + high shadowL:val - low open:even ? val + open : val - open close:even ? val - close : val + close icon: [UIImage imageNamed:@"icon"]]]; } CandleChartDataSet *set1 = [[CandleChartDataSet alloc] initWithValues:yVals1 label:@"Data Set"]; set1.axisDependency = AxisDependencyLeft; [set1 setColor:[UIColor colorWithWhite:80/255.f alpha:1.f]]; + set1.drawIconsEnabled = NO; + set1.shadowColor = UIColor.darkGrayColor; set1.shadowWidth = 0.7; set1.decreasingColor = UIColor.redColor; diff --git a/ChartsDemo/Classes/Demos/HorizontalBarChartViewController.m b/ChartsDemo/Classes/Demos/HorizontalBarChartViewController.m index e59c7976e2..dac6e26e07 100644 --- a/ChartsDemo/Classes/Demos/HorizontalBarChartViewController.m +++ b/ChartsDemo/Classes/Demos/HorizontalBarChartViewController.m @@ -32,6 +32,7 @@ - (void)viewDidLoad self.options = @[ @{@"key": @"toggleValues", @"label": @"Toggle Values"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @@ -119,7 +120,7 @@ - (void)setDataCount:(int)count range:(double)range { double mult = (range + 1); double val = (double) (arc4random_uniform(mult)); - [yVals addObject:[[BarChartDataEntry alloc] initWithX:i * spaceForBar y:val]]; + [yVals addObject:[[BarChartDataEntry alloc] initWithX:i * spaceForBar y:val icon: [UIImage imageNamed:@"icon"]]]; } BarChartDataSet *set1 = nil; @@ -134,6 +135,8 @@ - (void)setDataCount:(int)count range:(double)range { set1 = [[BarChartDataSet alloc] initWithValues:yVals label:@"DataSet"]; + set1.drawIconsEnabled = NO; + NSMutableArray *dataSets = [[NSMutableArray alloc] init]; [dataSets addObject:set1]; diff --git a/ChartsDemo/Classes/Demos/LineChart1ViewController.m b/ChartsDemo/Classes/Demos/LineChart1ViewController.m index 528c9facd9..15fd13a2ac 100644 --- a/ChartsDemo/Classes/Demos/LineChart1ViewController.m +++ b/ChartsDemo/Classes/Demos/LineChart1ViewController.m @@ -36,6 +36,7 @@ - (void)viewDidLoad @{@"key": @"toggleCircles", @"label": @"Toggle Circles"}, @{@"key": @"toggleCubic", @"label": @"Toggle Cubic"}, @{@"key": @"toggleHorizontalCubic", @"label": @"Toggle Horizontal Cubic"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleStepped", @"label": @"Toggle Stepped"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @@ -137,7 +138,7 @@ - (void)setDataCount:(int)count range:(double)range for (int i = 0; i < count; i++) { double val = arc4random_uniform(range) + 3; - [values addObject:[[ChartDataEntry alloc] initWithX:i y:val]]; + [values addObject:[[ChartDataEntry alloc] initWithX:i y:val icon: [UIImage imageNamed:@"icon"]]]; } LineChartDataSet *set1 = nil; @@ -152,6 +153,8 @@ - (void)setDataCount:(int)count range:(double)range { set1 = [[LineChartDataSet alloc] initWithValues:values label:@"DataSet 1"]; + set1.drawIconsEnabled = NO; + set1.lineDashLengths = @[@5.f, @2.5f]; set1.highlightLineDashLengths = @[@5.f, @2.5f]; [set1 setColor:UIColor.blackColor]; diff --git a/ChartsDemo/Classes/Demos/NegativeStackedBarChartViewController.m b/ChartsDemo/Classes/Demos/NegativeStackedBarChartViewController.m index e969e6806e..da934ad7b7 100644 --- a/ChartsDemo/Classes/Demos/NegativeStackedBarChartViewController.m +++ b/ChartsDemo/Classes/Demos/NegativeStackedBarChartViewController.m @@ -28,6 +28,7 @@ - (void)viewDidLoad self.options = @[ @{@"key": @"toggleValues", @"label": @"Toggle Values"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @@ -58,7 +59,6 @@ - (void)viewDidLoad _chartView.pinchZoomEnabled = NO; _chartView.drawBarShadowEnabled = NO; - _chartView.drawValueAboveBarEnabled = YES; _chartView.leftAxis.enabled = NO; _chartView.rightAxis.axisMaximum = 25.0; @@ -112,7 +112,7 @@ - (void)setChartData [yValues addObject:[[BarChartDataEntry alloc] initWithX:15 yValues:@[ @-12, @13 ]]]; [yValues addObject:[[BarChartDataEntry alloc] initWithX:25 yValues:@[ @-15, @15 ]]]; [yValues addObject:[[BarChartDataEntry alloc] initWithX:35 yValues:@[ @-17, @17 ]]]; - [yValues addObject:[[BarChartDataEntry alloc] initWithX:45 yValues:@[ @-19, @20 ]]]; + [yValues addObject:[[BarChartDataEntry alloc] initWithX:45 yValues:@[ @-19, @20 ] icon: [UIImage imageNamed:@"icon"]]]; [yValues addObject:[[BarChartDataEntry alloc] initWithX:55 yValues:@[ @-19, @19 ]]]; [yValues addObject:[[BarChartDataEntry alloc] initWithX:65 yValues:@[ @-16, @16 ]]]; [yValues addObject:[[BarChartDataEntry alloc] initWithX:75 yValues:@[ @-13, @14 ]]]; @@ -138,6 +138,9 @@ - (void)setChartData customFormatter.minimumFractionDigits = 1; set = [[BarChartDataSet alloc] initWithValues:yValues label:@"Age Distribution"]; + + set.drawIconsEnabled = NO; + set.valueFormatter = [[ChartDefaultValueFormatter alloc] initWithFormatter:customFormatter]; set.valueFont = [UIFont systemFontOfSize:7.f]; set.axisDependency = AxisDependencyRight; diff --git a/ChartsDemo/Classes/Demos/PieChartViewController.m b/ChartsDemo/Classes/Demos/PieChartViewController.m index b453f2a50e..0799e4640e 100644 --- a/ChartsDemo/Classes/Demos/PieChartViewController.m +++ b/ChartsDemo/Classes/Demos/PieChartViewController.m @@ -35,6 +35,7 @@ - (void)viewDidLoad @{@"key": @"toggleXValues", @"label": @"Toggle X-Values"}, @{@"key": @"togglePercent", @"label": @"Toggle Percent"}, @{@"key": @"toggleHole", @"label": @"Toggle Hole"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @{@"key": @"animateXY", @"label": @"Animate XY"}, @@ -93,11 +94,15 @@ - (void)setDataCount:(int)count range:(double)range for (int i = 0; i < count; i++) { - [values addObject:[[PieChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + mult / 5) label:parties[i % parties.count]]]; + [values addObject:[[PieChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + mult / 5) label:parties[i % parties.count] icon: [UIImage imageNamed:@"icon"]]]; } PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithValues:values label:@"Election Results"]; + + dataSet.drawIconsEnabled = NO; + dataSet.sliceSpace = 2.0; + dataSet.iconsOffset = CGPointMake(0, 40); // add a lot of colors diff --git a/ChartsDemo/Classes/Demos/StackedBarChartViewController.m b/ChartsDemo/Classes/Demos/StackedBarChartViewController.m index 345c4b3d95..2f3e728132 100644 --- a/ChartsDemo/Classes/Demos/StackedBarChartViewController.m +++ b/ChartsDemo/Classes/Demos/StackedBarChartViewController.m @@ -32,6 +32,7 @@ - (void)viewDidLoad self.options = @[ @{@"key": @"toggleValues", @"label": @"Toggle Values"}, + @{@"key": @"toggleIcons", @"label": @"Toggle Icons"}, @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, @{@"key": @"animateX", @"label": @"Animate X"}, @{@"key": @"animateY", @"label": @"Animate Y"}, @@ -111,7 +112,7 @@ - (void)setDataCount:(int)count range:(double)range double val2 = (double) (arc4random_uniform(mult) + mult / 3); double val3 = (double) (arc4random_uniform(mult) + mult / 3); - [yVals addObject:[[BarChartDataEntry alloc] initWithX:i yValues:@[@(val1), @(val2), @(val3)]]]; + [yVals addObject:[[BarChartDataEntry alloc] initWithX:i yValues:@[@(val1), @(val2), @(val3)] icon: [UIImage imageNamed:@"icon"]]]; } BarChartDataSet *set1 = nil; @@ -125,6 +126,9 @@ - (void)setDataCount:(int)count range:(double)range else { set1 = [[BarChartDataSet alloc] initWithValues:yVals label:@"Statistics Vienna 2014"]; + + set1.drawIconsEnabled = NO; + set1.colors = @[ChartColorTemplates.material[0], ChartColorTemplates.material[1], ChartColorTemplates.material[2]]; set1.stackLabels = @[@"Births", @"Divorces", @"Marriages"]; diff --git a/ChartsDemo/Classes/Formatters/DayAxisValueFormatter.m b/ChartsDemo/Classes/Formatters/DayAxisValueFormatter.m index 5180b9e41d..814456cc59 100644 --- a/ChartsDemo/Classes/Formatters/DayAxisValueFormatter.m +++ b/ChartsDemo/Classes/Formatters/DayAxisValueFormatter.m @@ -84,14 +84,18 @@ - (int)daysForMonth:(int)month year:(int)year if (month == 1) { - int x400 = month % 400; - if (x400 < 0) + BOOL is29Feb = NO; + + if (year < 1582) + { + is29Feb = (year < 1 ? year + 1 : year) % 4 == 0; + } + else if (year > 1582) { - x400 = -x400; + is29Feb = year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); } - BOOL is29 = (month % 4) == 0 && x400 != 100 && x400 != 200 && x400 != 300; - return is29 ? 29 : 28; + return is29Feb ? 29 : 28; } if (month == 3 || month == 5 || month == 8 || month == 10) diff --git a/ChartsDemo/Classes/RealmBase/RealmDemoBaseViewController.h b/ChartsDemo/Classes/RealmBase/RealmDemoBaseViewController.h deleted file mode 100644 index 55cd4dcbd9..0000000000 --- a/ChartsDemo/Classes/RealmBase/RealmDemoBaseViewController.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// RealmDemoBaseViewController.h -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import -#import "DemoBaseViewController.h" - -@interface RealmDemoBaseViewController : DemoBaseViewController - -- (void)writeRandomDataToDbWithObjectCount:(NSInteger)objectCount; -- (void)writeRandomStackedDataToDbWithObjectCount:(NSInteger)objectCount; -- (void)writeRandomCandleDataToDbWithObjectCount:(NSInteger)objectCount; -- (void)writeRandomBubbleDataToDbWithObjectCount:(NSInteger)objectCount; -- (void)writeRandomPieDataToDb; - -- (void)styleData:(ChartData *)data; - -@end diff --git a/ChartsDemo/Classes/RealmBase/RealmDemoBaseViewController.m b/ChartsDemo/Classes/RealmBase/RealmDemoBaseViewController.m deleted file mode 100644 index a62a14f2bc..0000000000 --- a/ChartsDemo/Classes/RealmBase/RealmDemoBaseViewController.m +++ /dev/null @@ -1,207 +0,0 @@ -// -// RealmDemoBaseViewController.m -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import "RealmDemoBaseViewController.h" -#import -#import "RealmDemoData.h" - -@interface RealmDemoBaseViewController () - -@end - -@implementation RealmDemoBaseViewController - -- (id)initWithCoder:(NSCoder *)aDecoder -{ - self = [super initWithCoder:aDecoder]; - if (self) - { - [self initialize]; - } - return self; -} - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) - { - [self initialize]; - } - return self; -} - -- (void)initialize -{ - self.edgesForExtendedLayout = UIRectEdgeNone; - - NSURL *defaultRealmPath = [RLMRealmConfiguration defaultConfiguration].fileURL; - [[NSFileManager defaultManager] removeItemAtURL:defaultRealmPath error:nil]; -} - -static float randomFloatBetween(float from, float to) -{ - return from + ((float)rand()/(float)RAND_MAX) * (to - from); -} - -- (void)writeRandomDataToDbWithObjectCount:(NSInteger)objectCount -{ - RLMRealm *realm = [RLMRealm defaultRealm]; - - [realm beginWriteTransaction]; - - [realm deleteObjects:RealmDemoData.allObjects]; - - for (int i = 0; i < objectCount; i++) - { - RealmDemoData *d = [[RealmDemoData alloc] initWithXValue:i yValue:randomFloatBetween(40.f, 100.f)]; - [realm addObject:d]; - } - - [realm commitWriteTransaction]; -} - -- (void)writeRandomStackedDataToDbWithObjectCount:(NSInteger)objectCount -{ - RLMRealm *realm = [RLMRealm defaultRealm]; - - [realm beginWriteTransaction]; - - [realm deleteObjects:RealmDemoData.allObjects]; - - for (int i = 0; i < objectCount; i++) - { - float val1 = randomFloatBetween(34.f, 46.f); - float val2 = randomFloatBetween(34.f, 46.f); - - NSArray *stack = @[@(val1), @(val2), @(100.f - val1 - val2)]; - - RealmDemoData *d = [[RealmDemoData alloc] initWithXValue:i stackValues:stack]; - [realm addObject:d]; - } - - [realm commitWriteTransaction]; -} - -- (void)writeRandomCandleDataToDbWithObjectCount:(NSInteger)objectCount -{ - RLMRealm *realm = [RLMRealm defaultRealm]; - - [realm beginWriteTransaction]; - - [realm deleteObjects:RealmDemoData.allObjects]; - - for (int i = 0; i < objectCount; i++) - { - float mult = 50; - float val = randomFloatBetween(mult, mult + 40); - - float high = randomFloatBetween(8, 17); - float low = randomFloatBetween(8, 17); - - float open = randomFloatBetween(1, 7); - float close = randomFloatBetween(1, 7); - - BOOL even = i % 2 == 0; - - RealmDemoData *d = [[RealmDemoData alloc] initWithXValue:i - high:val + high - low:val - low - open:even ? val + open : val - open - close:even ? val - close : val + close]; - - [realm addObject:d]; - } - - [realm commitWriteTransaction]; -} - -- (void)writeRandomBubbleDataToDbWithObjectCount:(NSInteger)objectCount -{ - RLMRealm *realm = [RLMRealm defaultRealm]; - - [realm beginWriteTransaction]; - - [realm deleteObjects:RealmDemoData.allObjects]; - - for (int i = 0; i < objectCount; i++) - { - RealmDemoData *d = [[RealmDemoData alloc] initWithXValue:i - yValue:randomFloatBetween(30.f, 130.f) - bubbleSize:randomFloatBetween(15.f, 35.f)]; - [realm addObject:d]; - } - - [realm commitWriteTransaction]; -} - -- (void)writeRandomPieDataToDb -{ - RLMRealm *realm = [RLMRealm defaultRealm]; - - [realm beginWriteTransaction]; - - [realm deleteObjects:RealmDemoData.allObjects]; - - float value1 = randomFloatBetween(15.f, 23.f); - float value2 = randomFloatBetween(15.f, 23.f); - float value3 = randomFloatBetween(15.f, 23.f); - float value4 = randomFloatBetween(15.f, 23.f); - float value5 = 100.f - value1 - value2 - value3 - value4; - - NSArray *values = @[ - @(value1), @(value2), @(value3), @(value4), - @(value5) - ]; - NSArray *xValues = @[ - @"iOS", - @"Android", - @"WP 10", - @"BlackBerry", - @"Other" - ]; - - for (int i = 0; i < values.count; i++) - { - RealmDemoData *d = [[RealmDemoData alloc] initWithYValue:randomFloatBetween(values[i].floatValue, 23.f) - label:xValues[i]]; - [realm addObject:d]; - } - - [realm commitWriteTransaction]; -} - -- (void)setupBarLineChartView:(BarLineChartViewBase *)chartView -{ - [super setupBarLineChartView:chartView]; - - NSNumberFormatter *percentFormatter = [[NSNumberFormatter alloc] init]; - percentFormatter.positiveSuffix = @"%"; - percentFormatter.negativeSuffix = @"%"; - - ChartYAxis *leftAxis = chartView.leftAxis; - leftAxis.labelFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:8.f]; - leftAxis.labelTextColor = UIColor.darkGrayColor; - leftAxis.valueFormatter = [[ChartDefaultAxisValueFormatter alloc] initWithFormatter:percentFormatter]; -} - -- (void)styleData:(ChartData *)data -{ - NSNumberFormatter *percentFormatter = [[NSNumberFormatter alloc] init]; - percentFormatter.positiveSuffix = @"%"; - percentFormatter.negativeSuffix = @"%"; - - data.valueFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:8.f]; - data.valueTextColor = UIColor.darkGrayColor; - data.valueFormatter = [[ChartDefaultValueFormatter alloc] initWithFormatter:percentFormatter]; -} - -@end diff --git a/ChartsDemo/Classes/RealmBase/RealmDemoData.h b/ChartsDemo/Classes/RealmBase/RealmDemoData.h deleted file mode 100644 index 51f4477e51..0000000000 --- a/ChartsDemo/Classes/RealmBase/RealmDemoData.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// RealmDemoData.h -// ChartsDemo -// Copyright © 2015 dcg. All rights reserved. -// - -#import -#import "RealmFloat.h" - -@interface RealmDemoData : RLMObject - -- (id)initWithYValue:(double)yValue; - -- (id)initWithXValue:(double)xValue - yValue:(double)yValue; - -- (id)initWithXValue:(double)xValue - stackValues:(NSArray *)stackValues; - -- (id)initWithXValue:(double)xValue - high:(double)high - low:(double)low - open:(double)open - close:(double)close; - -- (id)initWithXValue:(double)xValue - yValue:(double)yValue - bubbleSize:(double)bubbleSize; - -/// Constructor for pie chart -- (id)initWithYValue:(double)yValue - label:(NSString *)label; - -@property (nonatomic, assign) double xValue; -@property (nonatomic, assign) double yValue; - -@property (nonatomic, assign) double open; -@property (nonatomic, assign) double close; -@property (nonatomic, assign) double high; -@property (nonatomic, assign) double low; - -@property (nonatomic, assign) double bubbleSize; - -@property (nonatomic, strong) RLMArray *stackValues; - -@property (nonatomic, strong) NSString *label; - -@property (nonatomic, strong) NSString *someStringField; - -@end \ No newline at end of file diff --git a/ChartsDemo/Classes/RealmBase/RealmDemoData.m b/ChartsDemo/Classes/RealmBase/RealmDemoData.m deleted file mode 100644 index a13ec429be..0000000000 --- a/ChartsDemo/Classes/RealmBase/RealmDemoData.m +++ /dev/null @@ -1,107 +0,0 @@ -// -// RealmDemoData.m -// ChartsDemo -// Copyright © 2015 dcg. All rights reserved. -// - -#import "RealmDemoData.h" - -@implementation RealmDemoData - -- (id)initWithYValue:(double)yValue -{ - self = [super init]; - - if (self) - { - self.yValue = yValue; - } - - return self; -} - -- (id)initWithXValue:(double)xValue - yValue:(double)yValue -{ - self = [super init]; - - if (self) - { - self.xValue = xValue; - self.yValue = yValue; - } - - return self; -} - -- (id)initWithXValue:(double)xValue - stackValues:(NSArray *)stackValues -{ - self = [super init]; - - if (self) - { - self.xValue = xValue; - self.stackValues = [[RLMArray alloc] initWithObjectClassName:@"RealmFloat"]; - - for (NSNumber *value in stackValues) - { - [self.stackValues addObject:[[RealmFloat alloc] initWithFloatValue:value.floatValue]]; - } - } - - return self; -} - -- (id)initWithXValue:(double)xValue - high:(double)high - low:(double)low - open:(double)open - close:(double)close -{ - self = [super init]; - - if (self) - { - self.xValue = xValue; - self.yValue = (high + low) / 2.f; - self.high = high; - self.low = low; - self.open = open; - self.close = close; - } - - return self; -} - -- (id)initWithXValue:(double)xValue - yValue:(double)yValue - bubbleSize:(double)bubbleSize -{ - self = [super init]; - - if (self) - { - self.xValue = xValue; - self.yValue = yValue; - self.bubbleSize = bubbleSize; - } - - return self; -} - -- (id)initWithYValue:(double)yValue - label:(NSString *)label -{ - self = [super init]; - - if (self) - { - self.yValue = yValue; - self.label = label; - } - - return self; -} - -@end diff --git a/ChartsDemo/Classes/RealmBase/RealmFloat.h b/ChartsDemo/Classes/RealmBase/RealmFloat.h deleted file mode 100644 index a45469a5ad..0000000000 --- a/ChartsDemo/Classes/RealmBase/RealmFloat.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// RealmFloat.h -// ChartsDemo -// Copyright © 2015 dcg. All rights reserved. -// - -#import - -@interface RealmFloat : RLMObject - -@property (nonatomic, assign) float floatValue; - -- (id)initWithFloatValue:(float)value; - -@end - -RLM_ARRAY_TYPE(RealmFloat) \ No newline at end of file diff --git a/ChartsDemo/Classes/RealmBase/RealmFloat.m b/ChartsDemo/Classes/RealmBase/RealmFloat.m deleted file mode 100644 index 187ca3d135..0000000000 --- a/ChartsDemo/Classes/RealmBase/RealmFloat.m +++ /dev/null @@ -1,23 +0,0 @@ -// -// RealmFloat.m -// ChartsDemo -// Copyright © 2015 dcg. All rights reserved. -// - -#import "RealmFloat.h" - -@implementation RealmFloat - -- (id)initWithFloatValue:(float)value -{ - self = [super init]; - - if (self) - { - self.floatValue = value; - } - - return self; -} - -@end diff --git a/ChartsDemo/Classes/RealmBase/Score.h b/ChartsDemo/Classes/RealmBase/Score.h deleted file mode 100644 index aad4bf10bc..0000000000 --- a/ChartsDemo/Classes/RealmBase/Score.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// Score.h -// ChartsDemo -// Copyright © 2015 dcg. All rights reserved. -// - -#import - -@interface Score : RLMObject - -@property (nonatomic, assign) float totalScore; -@property (nonatomic, assign) double scoreNr; -@property (nonatomic, strong) NSString *playerName; - -- (id)initWithTotalScore:(float)totalScore - scoreNr:(double)scoreNr - playerName:(NSString *)playerName; - -@end diff --git a/ChartsDemo/Classes/RealmBase/Score.m b/ChartsDemo/Classes/RealmBase/Score.m deleted file mode 100644 index dcc6d9aceb..0000000000 --- a/ChartsDemo/Classes/RealmBase/Score.m +++ /dev/null @@ -1,27 +0,0 @@ -// -// Score.m -// ChartsDemo -// Copyright © 2015 dcg. All rights reserved. -// - -#import "Score.h" - -@implementation Score - -- (id)initWithTotalScore:(float)totalScore - scoreNr:(double)scoreNr - playerName:(NSString *)playerName -{ - self = [super init]; - - if (self) - { - self.totalScore = totalScore; - self.scoreNr = scoreNr; - self.playerName = playerName; - } - - return self; -} - -@end diff --git a/ChartsDemo/Classes/RealmDemoListViewController.m b/ChartsDemo/Classes/RealmDemoListViewController.m deleted file mode 100644 index f53b99ed13..0000000000 --- a/ChartsDemo/Classes/RealmDemoListViewController.m +++ /dev/null @@ -1,138 +0,0 @@ -// -// RealmDemoListViewController.m -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import "RealmDemoListViewController.h" -#import "RealmLineChartViewController.h" -#import "RealmBarChartViewController.h" -#import "RealmHorizontalBarChartViewController.h" -#import "RealmScatterChartViewController.h" -#import "RealmCandleChartViewController.h" -#import "RealmBubbleChartViewController.h" -#import "RealmPieChartViewController.h" -#import "RealmRadarChartViewController.h" -#import "RealmWikiExampleChartViewController.h" - -@interface RealmDemoListViewController () - -@property (nonatomic, strong) IBOutlet UITableView *tableView; -@property (nonatomic, strong) NSArray *itemDefs; -@end - -@implementation RealmDemoListViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - self.title = @"Charts Demonstration"; - - self.itemDefs = @[ - @{ - @"title": @"Realm.io database Line Chart", - @"subtitle": @"This demonstrates how to use this library with Realm.io mobile database.", - @"class": RealmLineChartViewController.class - }, - @{ - @"title": @"Realm.io database Bar Chart", - @"subtitle": @"This demonstrates how to use this library with Realm.io mobile database.", - @"class": RealmBarChartViewController.class - }, - @{ - @"title": @"Realm.io database Horizontal Bar Chart", - @"subtitle": @"This demonstrates how to use this library with Realm.io mobile database.", - @"class": RealmHorizontalBarChartViewController.class - }, - @{ - @"title": @"Realm.io database Scatter Chart", - @"subtitle": @"This demonstrates how to use this library with Realm.io mobile database.", - @"class": RealmScatterChartViewController.class - }, - @{ - @"title": @"Realm.io database CandleStick Chart", - @"subtitle": @"This demonstrates how to use this library with Realm.io mobile database.", - @"class": RealmCandleChartViewController.class - }, - @{ - @"title": @"Realm.io database Bubble Chart", - @"subtitle": @"This demonstrates how to use this library with Realm.io mobile database.", - @"class": RealmBubbleChartViewController.class - }, - @{ - @"title": @"Realm.io database Pie Chart", - @"subtitle": @"This demonstrates how to use this library with Realm.io mobile database.", - @"class": RealmPieChartViewController.class - }, - @{ - @"title": @"Realm.io database Radar Chart", - @"subtitle": @"This demonstrates how to use this library with Realm.io mobile database.", - @"class": RealmRadarChartViewController.class - }, - @{ - @"title": @"Realm.io Wiki", - @"subtitle": @"This is the code related to the entry about realm.io in the Wiki.", - @"class": RealmWikiExampleChartViewController.class - }, - ]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -#pragma mark - UITableViewDataSource, UITableViewDelegate - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView -{ - return 1; -} - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section -{ - return self.itemDefs.count; -} - -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath -{ - return 70.f; -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ - NSDictionary *def = self.itemDefs[indexPath.row]; - - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; - if (!cell) - { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"]; - } - - cell.textLabel.text = def[@"title"]; - cell.detailTextLabel.text = def[@"subtitle"]; - cell.detailTextLabel.numberOfLines = 0; - - return cell; -} - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - NSDictionary *def = self.itemDefs[indexPath.row]; - - Class vcClass = def[@"class"]; - UIViewController *vc = [[vcClass alloc] init]; - - [self.navigationController pushViewController:vc animated:YES]; - - [tableView deselectRowAtIndexPath:indexPath animated:YES]; -} - -@end diff --git a/ChartsDemo/Classes/RealmDemoListViewController.xib b/ChartsDemo/Classes/RealmDemoListViewController.xib deleted file mode 100644 index ade95ac392..0000000000 --- a/ChartsDemo/Classes/RealmDemoListViewController.xib +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChartsDemo/Classes/RealmDemos/RealmBarChartViewController.h b/ChartsDemo/Classes/RealmDemos/RealmBarChartViewController.h deleted file mode 100644 index b3a9a1bee7..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmBarChartViewController.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// RealmBarChartViewController.h -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import -#import "RealmDemoBaseViewController.h" -#import - -@interface RealmBarChartViewController : RealmDemoBaseViewController - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmBarChartViewController.m b/ChartsDemo/Classes/RealmDemos/RealmBarChartViewController.m deleted file mode 100644 index ca65053833..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmBarChartViewController.m +++ /dev/null @@ -1,98 +0,0 @@ -// -// RealmBarChartViewController.m -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import "RealmBarChartViewController.h" -#import "ChartsDemo-Swift.h" -#import -#import "RealmDemoData.h" - -@interface RealmBarChartViewController () - -@property (nonatomic, strong) IBOutlet BarChartView *chartView; - -@end - -@implementation RealmBarChartViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - [self writeRandomDataToDbWithObjectCount:20]; - - self.title = @"Realm.io Bar Chart"; - - self.options = @[ - @{@"key": @"toggleValues", @"label": @"Toggle Values"}, - @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, - @{@"key": @"animateX", @"label": @"Animate X"}, - @{@"key": @"animateY", @"label": @"Animate Y"}, - @{@"key": @"animateXY", @"label": @"Animate XY"}, - @{@"key": @"saveToGallery", @"label": @"Save to Camera Roll"}, - @{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"}, - @{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"}, - ]; - - _chartView.delegate = self; - - [self setupBarLineChartView:_chartView]; - - [self setData]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (void)setData -{ - - RLMRealm *realm = [RLMRealm defaultRealm]; - - RLMResults *results = [RealmDemoData allObjectsInRealm:realm]; - - RealmBarDataSet *set = [[RealmBarDataSet alloc] initWithResults:results xValueField:@"xValue" yValueField:@"yValue"]; - set.colors = @[[ChartColorTemplates colorFromString:@"#FF5722"], - [ChartColorTemplates colorFromString:@"#03A9F4"]]; - set.label = @"Realm BarDataSet"; - - NSArray> *dataSets = @[set]; - - BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets]; - [self styleData:data]; - - [_chartView zoomWithScaleX:5.f scaleY:1.f x:0.f y:0.f]; - _chartView.fitBars = YES; - _chartView.data = data; - - [_chartView animateWithYAxisDuration:1.4 easingOption:ChartEasingOptionEaseInOutQuart]; -} - -- (void)optionTapped:(NSString *)key -{ - [super handleOption:key forChartView:_chartView]; -} - -#pragma mark - ChartViewDelegate - -- (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartDataEntry * __nonnull)entry highlight:(ChartHighlight * __nonnull)highlight -{ - NSLog(@"chartValueSelected"); -} - -- (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView -{ - NSLog(@"chartValueNothingSelected"); -} - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmBarChartViewController.xib b/ChartsDemo/Classes/RealmDemos/RealmBarChartViewController.xib deleted file mode 100644 index f0e5e79f17..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmBarChartViewController.xib +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChartsDemo/Classes/RealmDemos/RealmBubbleChartViewController.h b/ChartsDemo/Classes/RealmDemos/RealmBubbleChartViewController.h deleted file mode 100644 index bcbefd8a7c..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmBubbleChartViewController.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// RealmBubbleChartViewController.h -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import -#import "RealmDemoBaseViewController.h" -#import - -@interface RealmBubbleChartViewController : RealmDemoBaseViewController - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmBubbleChartViewController.m b/ChartsDemo/Classes/RealmDemos/RealmBubbleChartViewController.m deleted file mode 100644 index 3734186de8..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmBubbleChartViewController.m +++ /dev/null @@ -1,100 +0,0 @@ -// -// RealmBubbleChartViewController.m -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import "RealmBubbleChartViewController.h" -#import "ChartsDemo-Swift.h" -#import -#import "RealmDemoData.h" - -@interface RealmBubbleChartViewController () - -@property (nonatomic, strong) IBOutlet BubbleChartView *chartView; - -@end - -@implementation RealmBubbleChartViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - [self writeRandomBubbleDataToDbWithObjectCount:10]; - - self.title = @"Realm.io Bubble Chart"; - - self.options = @[ - @{@"key": @"toggleValues", @"label": @"Toggle Values"}, - @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, - @{@"key": @"animateX", @"label": @"Animate X"}, - @{@"key": @"animateY", @"label": @"Animate Y"}, - @{@"key": @"animateXY", @"label": @"Animate XY"}, - @{@"key": @"saveToGallery", @"label": @"Save to Camera Roll"}, - @{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"}, - @{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"}, - ]; - - _chartView.delegate = self; - - [self setupBarLineChartView:_chartView]; - - _chartView.xAxis.drawGridLinesEnabled = NO; - _chartView.leftAxis.drawGridLinesEnabled = NO; - _chartView.pinchZoomEnabled = YES; - - [self setData]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (void)setData -{ - - RLMRealm *realm = [RLMRealm defaultRealm]; - - RLMResults *results = [RealmDemoData allObjectsInRealm:realm]; - - RealmBubbleDataSet *set = [[RealmBubbleDataSet alloc] initWithResults:results xValueField:@"xValue" yValueField:@"yValue" sizeField:@"bubbleSize"]; - - set.label = @"Realm BubbleDataSet"; - [set setColors:ChartColorTemplates.colorful alpha:0.43f]; - - NSArray> *dataSets = @[set]; - - BubbleChartData *data = [[BubbleChartData alloc] initWithDataSets:dataSets]; - [self styleData:data]; - - _chartView.data = data; - - [_chartView animateWithYAxisDuration:1.4 easingOption:ChartEasingOptionEaseInOutQuart]; -} - -- (void)optionTapped:(NSString *)key -{ - [super handleOption:key forChartView:_chartView]; -} - -#pragma mark - ChartViewDelegate - -- (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartDataEntry * __nonnull)entry highlight:(ChartHighlight * __nonnull)highlight -{ - NSLog(@"chartValueSelected"); -} - -- (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView -{ - NSLog(@"chartValueNothingSelected"); -} - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmBubbleChartViewController.xib b/ChartsDemo/Classes/RealmDemos/RealmBubbleChartViewController.xib deleted file mode 100644 index ee0a5d3893..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmBubbleChartViewController.xib +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChartsDemo/Classes/RealmDemos/RealmCandleChartViewController.h b/ChartsDemo/Classes/RealmDemos/RealmCandleChartViewController.h deleted file mode 100644 index 7a855935e1..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmCandleChartViewController.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// RealmCandleChartViewController.h -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import -#import "RealmDemoBaseViewController.h" -#import - -@interface RealmCandleChartViewController : RealmDemoBaseViewController - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmCandleChartViewController.m b/ChartsDemo/Classes/RealmDemos/RealmCandleChartViewController.m deleted file mode 100644 index e3bce81e10..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmCandleChartViewController.m +++ /dev/null @@ -1,120 +0,0 @@ -// -// RealmCandleChartViewController.m -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import "RealmCandleChartViewController.h" -#import "ChartsDemo-Swift.h" -#import -#import "RealmDemoData.h" - -@interface RealmCandleChartViewController () - -@property (nonatomic, strong) IBOutlet CandleStickChartView *chartView; - -@end - -@implementation RealmCandleChartViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - [self writeRandomCandleDataToDbWithObjectCount:50]; - - self.title = @"Realm.io CandleStick Chart"; - - self.options = @[ - @{@"key": @"toggleValues", @"label": @"Toggle Values"}, - @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, - @{@"key": @"animateX", @"label": @"Animate X"}, - @{@"key": @"animateY", @"label": @"Animate Y"}, - @{@"key": @"animateXY", @"label": @"Animate XY"}, - @{@"key": @"saveToGallery", @"label": @"Save to Camera Roll"}, - @{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"}, - @{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"}, - @{@"key": @"toggleShadowColorSameAsCandle", @"label": @"Toggle shadow same color"}, - ]; - - - _chartView.delegate = self; - - [self setupBarLineChartView:_chartView]; - - _chartView.leftAxis.drawGridLinesEnabled = NO; - _chartView.xAxis.drawGridLinesEnabled = NO; - - [self setData]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (void)setData -{ - - RLMRealm *realm = [RLMRealm defaultRealm]; - - RLMResults *results = [RealmDemoData allObjectsInRealm:realm]; - - RealmCandleDataSet *set = [[RealmCandleDataSet alloc] initWithResults:results xValueField:@"xValue" highField:@"high" lowField:@"low" openField:@"open" closeField:@"close"]; - - set.label = @"Realm CandleDataSet"; - set.shadowColor = UIColor.darkGrayColor; - set.shadowWidth = 0.7f; - set.decreasingColor = UIColor.redColor; - set.decreasingFilled = YES; - set.increasingColor = [UIColor colorWithRed:122/255.f green:242/255.f blue:84/255.f alpha:1.f]; - set.increasingFilled = NO; - set.neutralColor = UIColor.blueColor; - - NSArray> *dataSets = @[set]; - - CandleChartData *data = [[CandleChartData alloc] initWithDataSets:dataSets]; - [self styleData:data]; - - [_chartView zoomWithScaleX:5.f scaleY:1.f x:0.f y:0.f]; - _chartView.data = data; - - [_chartView animateWithYAxisDuration:1.4 easingOption:ChartEasingOptionEaseInOutQuart]; -} - -- (void)optionTapped:(NSString *)key -{ - if ([key isEqualToString:@"toggleShadowColorSameAsCandle"]) - { - for (id set in _chartView.data.dataSets) - { - set.shadowColorSameAsCandle = !set.shadowColorSameAsCandle; - } - - [_chartView.data notifyDataChanged]; - [_chartView notifyDataSetChanged]; - return; - } - - [super handleOption:key forChartView:_chartView]; -} - -#pragma mark - ChartViewDelegate - -- (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartDataEntry * __nonnull)entry highlight:(ChartHighlight * __nonnull)highlight -{ - NSLog(@"chartValueSelected"); -} - -- (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView -{ - NSLog(@"chartValueNothingSelected"); -} - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmCandleChartViewController.xib b/ChartsDemo/Classes/RealmDemos/RealmCandleChartViewController.xib deleted file mode 100644 index 5a7f6bb96f..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmCandleChartViewController.xib +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChartsDemo/Classes/RealmDemos/RealmHorizontalBarChartViewController.h b/ChartsDemo/Classes/RealmDemos/RealmHorizontalBarChartViewController.h deleted file mode 100644 index eea6557527..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmHorizontalBarChartViewController.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// RealmHorizontalBarChartViewController.h -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import -#import "RealmDemoBaseViewController.h" -#import - -@interface RealmHorizontalBarChartViewController : RealmDemoBaseViewController - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmHorizontalBarChartViewController.m b/ChartsDemo/Classes/RealmDemos/RealmHorizontalBarChartViewController.m deleted file mode 100644 index e7a398c853..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmHorizontalBarChartViewController.m +++ /dev/null @@ -1,111 +0,0 @@ -// -// RealmHorizontalBarChartViewController.m -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import "RealmHorizontalBarChartViewController.h" -#import "ChartsDemo-Swift.h" -#import -#import "RealmDemoData.h" - -@interface RealmHorizontalBarChartViewController () - -@property (nonatomic, strong) IBOutlet HorizontalBarChartView *chartView; - -@end - -@implementation RealmHorizontalBarChartViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - [self writeRandomStackedDataToDbWithObjectCount:50]; - - self.title = @"Realm.io Horizontal Bar Chart"; - - self.options = @[ - @{@"key": @"toggleValues", @"label": @"Toggle Values"}, - @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, - @{@"key": @"animateX", @"label": @"Animate X"}, - @{@"key": @"animateY", @"label": @"Animate Y"}, - @{@"key": @"animateXY", @"label": @"Animate XY"}, - @{@"key": @"saveToGallery", @"label": @"Save to Camera Roll"}, - @{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"}, - @{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"}, - ]; - - _chartView.delegate = self; - - [self setupBarLineChartView:_chartView]; - - _chartView.leftAxis.axisMinimum = 0.0; - _chartView.drawValueAboveBarEnabled = NO; - - [self setData]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (void)setData -{ - - RLMRealm *realm = [RLMRealm defaultRealm]; - - RLMResults *results = [RealmDemoData allObjectsInRealm:realm]; - - // RealmBarDataSet *set = [[RealmBarDataSet alloc] initWithResults:results yValueField:@@"yValue" xValueField:@"xIndex"]; - RealmBarDataSet *set = [[RealmBarDataSet alloc] initWithResults:results xValueField:@"xValue" yValueField:@"stackValues" stackValueField:@"floatValue"]; // stacked entries - - set.colors = @[ - [ChartColorTemplates colorFromString:@"#8BC34A"], - [ChartColorTemplates colorFromString:@"#FFC107"], - [ChartColorTemplates colorFromString:@"#9E9E9E"], - ]; - - set.label = @"Mobile OS Distribution"; - set.stackLabels = @[ - @"iOS", - @"Android", - @"Other" - ]; - - NSArray> *dataSets = @[set]; - - BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets]; - [self styleData:data]; - data.valueTextColor = UIColor.whiteColor; - - _chartView.data = data; - - [_chartView animateWithYAxisDuration:1.4 easingOption:ChartEasingOptionEaseInOutQuart]; -} - -- (void)optionTapped:(NSString *)key -{ - [super handleOption:key forChartView:_chartView]; -} - -#pragma mark - ChartViewDelegate - -- (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartDataEntry * __nonnull)entry highlight:(ChartHighlight * __nonnull)highlight -{ - NSLog(@"chartValueSelected"); -} - -- (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView -{ - NSLog(@"chartValueNothingSelected"); -} - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmHorizontalBarChartViewController.xib b/ChartsDemo/Classes/RealmDemos/RealmHorizontalBarChartViewController.xib deleted file mode 100644 index cd05831c2c..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmHorizontalBarChartViewController.xib +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChartsDemo/Classes/RealmDemos/RealmLineChartViewController.h b/ChartsDemo/Classes/RealmDemos/RealmLineChartViewController.h deleted file mode 100644 index e64e77923b..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmLineChartViewController.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// RealmLineChartViewController.h -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import -#import "RealmDemoBaseViewController.h" -#import - -@interface RealmLineChartViewController : RealmDemoBaseViewController - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmLineChartViewController.m b/ChartsDemo/Classes/RealmDemos/RealmLineChartViewController.m deleted file mode 100644 index f08ed8786a..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmLineChartViewController.m +++ /dev/null @@ -1,157 +0,0 @@ -// -// RealmLineChartViewController.m -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import "RealmLineChartViewController.h" -#import "ChartsDemo-Swift.h" -#import -#import "RealmDemoData.h" - -@interface RealmLineChartViewController () - -@property (nonatomic, strong) IBOutlet LineChartView *chartView; - -@end - -@implementation RealmLineChartViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - [self writeRandomDataToDbWithObjectCount:40]; - - self.title = @"Realm.io Line Chart"; - - self.options = @[ - @{@"key": @"toggleValues", @"label": @"Toggle Values"}, - @{@"key": @"toggleFilled", @"label": @"Toggle Filled"}, - @{@"key": @"toggleCircles", @"label": @"Toggle Circles"}, - @{@"key": @"toggleCubic", @"label": @"Toggle Cubic"}, - @{@"key": @"toggleStepped", @"label": @"Toggle Stepped"}, - @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, - @{@"key": @"animateX", @"label": @"Animate X"}, - @{@"key": @"animateY", @"label": @"Animate Y"}, - @{@"key": @"animateXY", @"label": @"Animate XY"}, - @{@"key": @"saveToGallery", @"label": @"Save to Camera Roll"}, - @{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"}, - @{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"}, - ]; - - _chartView.delegate = self; - - [self setupBarLineChartView:_chartView]; - - // enable description text - _chartView.chartDescription.enabled = YES; - - _chartView.leftAxis.axisMaximum = 150.f; - _chartView.leftAxis.axisMinimum = 0.f; - _chartView.leftAxis.drawGridLinesEnabled = NO; - _chartView.xAxis.drawGridLinesEnabled = NO; - - [self setData]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (void)setData -{ - - RLMRealm *realm = [RLMRealm defaultRealm]; - - RLMResults *results = [RealmDemoData allObjectsInRealm:realm]; - - RealmLineDataSet *set = [[RealmLineDataSet alloc] initWithResults:results xValueField:@"xValue" yValueField:@"yValue"]; - - set.label = @"Realm LineDataSet"; - set.drawCircleHoleEnabled = NO; - set.color = [ChartColorTemplates colorFromString:@"#FF5722"]; - [set setCircleColor:[ChartColorTemplates colorFromString:@"#FF5722"]]; - set.lineWidth = 1.8f; - set.circleRadius = 3.6f; - - NSArray> *dataSets = @[set]; - - LineChartData *data = [[LineChartData alloc] initWithDataSets:dataSets]; - [self styleData:data]; - - [_chartView zoomWithScaleX:5.f scaleY:1.f x:0.f y:0.f]; - _chartView.data = data; - - [_chartView animateWithYAxisDuration:1.4 easingOption:ChartEasingOptionEaseInOutQuart]; -} - -- (void)optionTapped:(NSString *)key -{ - if ([key isEqualToString:@"toggleFilled"]) - { - for (id set in _chartView.data.dataSets) - { - set.drawFilledEnabled = !set.isDrawFilledEnabled; - } - - [_chartView setNeedsDisplay]; - return; - } - - if ([key isEqualToString:@"toggleCircles"]) - { - for (id set in _chartView.data.dataSets) - { - set.drawCirclesEnabled = !set.isDrawCirclesEnabled; - } - - [_chartView setNeedsDisplay]; - return; - } - - if ([key isEqualToString:@"toggleCubic"]) - { - for (id set in _chartView.data.dataSets) - { - set.mode = set.mode == LineChartModeCubicBezier ? LineChartModeLinear : LineChartModeCubicBezier; - } - - [_chartView setNeedsDisplay]; - return; - } - - if ([key isEqualToString:@"toggleStepped"]) - { - for (id set in _chartView.data.dataSets) - { - set.drawSteppedEnabled = !set.isDrawSteppedEnabled; - } - - [_chartView setNeedsDisplay]; - return; - } - - [super handleOption:key forChartView:_chartView]; -} - -#pragma mark - ChartViewDelegate - -- (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartDataEntry * __nonnull)entry highlight:(ChartHighlight * __nonnull)highlight -{ - NSLog(@"chartValueSelected"); -} - -- (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView -{ - NSLog(@"chartValueNothingSelected"); -} - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmLineChartViewController.xib b/ChartsDemo/Classes/RealmDemos/RealmLineChartViewController.xib deleted file mode 100644 index eb63464d80..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmLineChartViewController.xib +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChartsDemo/Classes/RealmDemos/RealmPieChartViewController.h b/ChartsDemo/Classes/RealmDemos/RealmPieChartViewController.h deleted file mode 100644 index f27a95e6de..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmPieChartViewController.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// RealmPieChartViewController.h -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import -#import "RealmDemoBaseViewController.h" -#import - -@interface RealmPieChartViewController : RealmDemoBaseViewController - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmPieChartViewController.m b/ChartsDemo/Classes/RealmDemos/RealmPieChartViewController.m deleted file mode 100644 index aef4731448..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmPieChartViewController.m +++ /dev/null @@ -1,172 +0,0 @@ -// -// RealmPieChartViewController.m -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import "RealmPieChartViewController.h" -#import "ChartsDemo-Swift.h" -#import -#import "RealmDemoData.h" - -@interface RealmPieChartViewController () - -@property (nonatomic, strong) IBOutlet PieChartView *chartView; - -@end - -@implementation RealmPieChartViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - [self writeRandomPieDataToDb]; - - self.title = @"Realm.io Pie Chart"; - - self.options = @[ - @{@"key": @"toggleValues", @"label": @"Toggle Y-Values"}, - @{@"key": @"toggleXValues", @"label": @"Toggle X-Values"}, - @{@"key": @"togglePercent", @"label": @"Toggle Percent"}, - @{@"key": @"toggleHole", @"label": @"Toggle Hole"}, - @{@"key": @"animateX", @"label": @"Animate X"}, - @{@"key": @"animateY", @"label": @"Animate Y"}, - @{@"key": @"animateXY", @"label": @"Animate XY"}, - @{@"key": @"spin", @"label": @"Spin"}, - @{@"key": @"drawCenter", @"label": @"Draw CenterText"}, - @{@"key": @"saveToGallery", @"label": @"Save to Camera Roll"} - ]; - - _chartView.delegate = self; - - [self setupPieChartView:_chartView]; - - NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; - paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail; - paragraphStyle.alignment = NSTextAlignmentCenter; - - NSMutableAttributedString *centerText = [[NSMutableAttributedString alloc] initWithString:@"Realm.io\nmobile database"]; - [centerText addAttributes:@{ - NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Light" size:22.f], - NSForegroundColorAttributeName: [UIColor colorWithRed:240/255.f green:115/255.f blue:126/255.f alpha:1.f] - } range:NSMakeRange(0, 8)]; - [centerText addAttributes:@{ - NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-LightItalic" size:8.5f], - NSForegroundColorAttributeName: [UIColor colorWithRed:51/255.f green:181/255.f blue:229/255.f alpha:1.f] - } range:NSMakeRange(9, centerText.length - 9)]; - _chartView.centerAttributedText = centerText; - - [self setData]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (void)setData -{ - - RLMRealm *realm = [RLMRealm defaultRealm]; - - RLMResults *results = [RealmDemoData allObjectsInRealm:realm]; - - RealmPieDataSet *set = [[RealmPieDataSet alloc] initWithResults:results yValueField:@"yValue" labelField:@"label"]; - - set.valueFont = [UIFont systemFontOfSize:9.f]; - set.colors = ChartColorTemplates.vordiplom; - set.label = @"Example market share"; - set.sliceSpace = 2.f; - - NSArray> *dataSets = @[set]; - - PieChartData *data = [[PieChartData alloc] initWithDataSets:dataSets]; - [self styleData:data]; - data.valueTextColor = UIColor.whiteColor; - data.valueFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:12.f]; - - _chartView.data = data; - [_chartView animateWithYAxisDuration:1.4 easingOption:ChartEasingOptionEaseInOutQuart]; -} - -- (void)optionTapped:(NSString *)key -{ - if ([key isEqualToString:@"toggleXValues"]) - { - _chartView.drawSliceTextEnabled = !_chartView.isDrawSliceTextEnabled; - - [_chartView setNeedsDisplay]; - return; - } - - if ([key isEqualToString:@"togglePercent"]) - { - _chartView.usePercentValuesEnabled = !_chartView.isUsePercentValuesEnabled; - - [_chartView setNeedsDisplay]; - return; - } - - if ([key isEqualToString:@"toggleHole"]) - { - _chartView.drawHoleEnabled = !_chartView.isDrawHoleEnabled; - - [_chartView setNeedsDisplay]; - return; - } - - if ([key isEqualToString:@"drawCenter"]) - { - _chartView.drawCenterTextEnabled = !_chartView.isDrawCenterTextEnabled; - - [_chartView setNeedsDisplay]; - return; - } - - if ([key isEqualToString:@"animateX"]) - { - [_chartView animateWithXAxisDuration:1.4]; - return; - } - - if ([key isEqualToString:@"animateY"]) - { - [_chartView animateWithYAxisDuration:1.4]; - return; - } - - if ([key isEqualToString:@"animateXY"]) - { - [_chartView animateWithXAxisDuration:1.4 yAxisDuration:1.4]; - return; - } - - if ([key isEqualToString:@"spin"]) - { - [_chartView spinWithDuration:2.0 fromAngle:_chartView.rotationAngle toAngle:_chartView.rotationAngle + 360.f]; - return; - } - - [super handleOption:key forChartView:_chartView]; -} - -#pragma mark - ChartViewDelegate - -- (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartDataEntry * __nonnull)entry highlight:(ChartHighlight * __nonnull)highlight -{ - NSLog(@"chartValueSelected"); -} - -- (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView -{ - NSLog(@"chartValueNothingSelected"); -} - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmPieChartViewController.xib b/ChartsDemo/Classes/RealmDemos/RealmPieChartViewController.xib deleted file mode 100644 index f484cb2b55..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmPieChartViewController.xib +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChartsDemo/Classes/RealmDemos/RealmRadarChartViewController.h b/ChartsDemo/Classes/RealmDemos/RealmRadarChartViewController.h deleted file mode 100644 index b59eeff6bb..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmRadarChartViewController.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// RealmRadarChartViewController.h -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import -#import "RealmDemoBaseViewController.h" -#import - -@interface RealmRadarChartViewController : RealmDemoBaseViewController - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmRadarChartViewController.m b/ChartsDemo/Classes/RealmDemos/RealmRadarChartViewController.m deleted file mode 100644 index 2193c56673..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmRadarChartViewController.m +++ /dev/null @@ -1,167 +0,0 @@ -// -// RealmRadarChartViewController.m -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import "RealmRadarChartViewController.h" -#import "ChartsDemo-Swift.h" -#import -#import "RealmDemoData.h" - -@interface RealmRadarChartViewController () - -@property (nonatomic, strong) IBOutlet RadarChartView *chartView; - -@end - -@implementation RealmRadarChartViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - [self writeRandomDataToDbWithObjectCount:7]; - - self.title = @"Realm.io Radar Chart"; - - self.options = @[ - @{@"key": @"toggleValues", @"label": @"Toggle Values"}, - @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, - @{@"key": @"toggleXLabels", @"label": @"Toggle X-Values"}, - @{@"key": @"toggleYLabels", @"label": @"Toggle Y-Values"}, - @{@"key": @"toggleRotate", @"label": @"Toggle Rotate"}, - @{@"key": @"toggleFill", @"label": @"Toggle Fill"}, - @{@"key": @"animateX", @"label": @"Animate X"}, - @{@"key": @"animateY", @"label": @"Animate Y"}, - @{@"key": @"animateXY", @"label": @"Animate XY"}, - @{@"key": @"spin", @"label": @"Spin"}, - @{@"key": @"saveToGallery", @"label": @"Save to Camera Roll"} - ]; - - _chartView.delegate = self; - - [self setupRadarChartView:_chartView]; - - _chartView.yAxis.enabled = NO; - _chartView.xAxis.enabled = NO; - _chartView.webAlpha = 0.7f; - _chartView.innerWebColor = UIColor.darkGrayColor; - _chartView.webColor = UIColor.grayColor; - - [self setData]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (void)setData -{ - - RLMRealm *realm = [RLMRealm defaultRealm]; - - RLMResults *results = [RealmDemoData allObjectsInRealm:realm]; - - // RealmRadarDataSet *set = [[RealmRadarDataSet alloc] initWithResults:results yValueField:@"stackValues" xValueField:@"xIndex"]; // normal entries - RealmRadarDataSet *set = [[RealmRadarDataSet alloc] initWithResults:results yValueField:@"yValue"]; // stacked entries - - set.label = @"Realm RadarDataSet"; - set.drawFilledEnabled = YES; - [set setColor:[ChartColorTemplates colorFromString:@"#009688"]]; - [set setFillColor:[ChartColorTemplates colorFromString:@"#009688"]]; - set.fillAlpha = 0.5f; - set.lineWidth = 2.f; - - NSArray> *dataSets = @[set]; - - RadarChartData *data = [[RadarChartData alloc] initWithDataSets:dataSets]; - [self styleData:data]; - - _chartView.data = data; - [_chartView animateWithYAxisDuration:1.4 easingOption:ChartEasingOptionEaseInOutQuart]; -} - -- (void)optionTapped:(NSString *)key -{ - if ([key isEqualToString:@"toggleXLabels"]) - { - _chartView.xAxis.drawLabelsEnabled = !_chartView.xAxis.isDrawLabelsEnabled; - - [_chartView.data notifyDataChanged]; - [_chartView notifyDataSetChanged]; - [_chartView setNeedsDisplay]; - return; - } - - if ([key isEqualToString:@"toggleYLabels"]) - { - _chartView.yAxis.drawLabelsEnabled = !_chartView.yAxis.isDrawLabelsEnabled; - [_chartView setNeedsDisplay]; - return; - } - - if ([key isEqualToString:@"toggleRotate"]) - { - _chartView.rotationEnabled = !_chartView.isRotationEnabled; - return; - } - - if ([key isEqualToString:@"toggleFill"]) - { - for (RadarChartDataSet *set in _chartView.data.dataSets) - { - set.drawFilledEnabled = !set.isDrawFilledEnabled; - } - - [_chartView setNeedsDisplay]; - return; - } - - if ([key isEqualToString:@"animateX"]) - { - [_chartView animateWithXAxisDuration:1.4]; - return; - } - - if ([key isEqualToString:@"animateY"]) - { - [_chartView animateWithYAxisDuration:1.4]; - return; - } - - if ([key isEqualToString:@"animateXY"]) - { - [_chartView animateWithXAxisDuration:1.4 yAxisDuration:1.4]; - return; - } - - if ([key isEqualToString:@"spin"]) - { - [_chartView spinWithDuration:2.0 fromAngle:_chartView.rotationAngle toAngle:_chartView.rotationAngle + 360.f easingOption:ChartEasingOptionEaseInCubic]; - return; - } - - [super handleOption:key forChartView:_chartView]; -} - -#pragma mark - ChartViewDelegate - -- (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartDataEntry * __nonnull)entry highlight:(ChartHighlight * __nonnull)highlight -{ - NSLog(@"chartValueSelected"); -} - -- (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView -{ - NSLog(@"chartValueNothingSelected"); -} - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmRadarChartViewController.xib b/ChartsDemo/Classes/RealmDemos/RealmRadarChartViewController.xib deleted file mode 100644 index 961185f450..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmRadarChartViewController.xib +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChartsDemo/Classes/RealmDemos/RealmScatterChartViewController.h b/ChartsDemo/Classes/RealmDemos/RealmScatterChartViewController.h deleted file mode 100644 index a977226fee..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmScatterChartViewController.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// RealmScatterChartViewController.h -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import -#import "RealmDemoBaseViewController.h" -#import - -@interface RealmScatterChartViewController : RealmDemoBaseViewController - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmScatterChartViewController.m b/ChartsDemo/Classes/RealmDemos/RealmScatterChartViewController.m deleted file mode 100644 index 5d6e29deb9..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmScatterChartViewController.m +++ /dev/null @@ -1,103 +0,0 @@ -// -// RealmScatterChartViewController.m -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import "RealmScatterChartViewController.h" -#import "ChartsDemo-Swift.h" -#import -#import "RealmDemoData.h" - -@interface RealmScatterChartViewController () - -@property (nonatomic, strong) IBOutlet ScatterChartView *chartView; - -@end - -@implementation RealmScatterChartViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - [self writeRandomDataToDbWithObjectCount:45]; - - self.title = @"Realm.io Scatter Chart"; - - self.options = @[ - @{@"key": @"toggleValues", @"label": @"Toggle Values"}, - @{@"key": @"toggleHighlight", @"label": @"Toggle Highlight"}, - @{@"key": @"animateX", @"label": @"Animate X"}, - @{@"key": @"animateY", @"label": @"Animate Y"}, - @{@"key": @"animateXY", @"label": @"Animate XY"}, - @{@"key": @"saveToGallery", @"label": @"Save to Camera Roll"}, - @{@"key": @"togglePinchZoom", @"label": @"Toggle PinchZoom"}, - @{@"key": @"toggleAutoScaleMinMax", @"label": @"Toggle auto scale min/max"}, - ]; - - _chartView.delegate = self; - - [self setupBarLineChartView:_chartView]; - - _chartView.leftAxis.drawGridLinesEnabled = NO; - _chartView.xAxis.drawGridLinesEnabled = NO; - _chartView.pinchZoomEnabled = YES; - - [self setData]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (void)setData -{ - - RLMRealm *realm = [RLMRealm defaultRealm]; - - RLMResults *results = [RealmDemoData allObjectsInRealm:realm]; - - RealmScatterDataSet *set = [[RealmScatterDataSet alloc] initWithResults:results xValueField:@"xValue" yValueField:@"yValue"]; - - set.label = @"Realm ScatterDataSet"; - set.scatterShapeSize = 9.f; - [set setColor:[ChartColorTemplates colorFromString:@"#CDDC39"]]; - [set setScatterShape:ScatterShapeCircle]; - - NSArray> *dataSets = @[set]; - - ScatterChartData *data = [[ScatterChartData alloc] initWithDataSets:dataSets]; - [self styleData:data]; - - [_chartView zoomWithScaleX:5.f scaleY:1.f x:0.f y:0.f]; - _chartView.data = data; - - [_chartView animateWithYAxisDuration:1.4 easingOption:ChartEasingOptionEaseInOutQuart]; -} - -- (void)optionTapped:(NSString *)key -{ - [super handleOption:key forChartView:_chartView]; -} - -#pragma mark - ChartViewDelegate - -- (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartDataEntry * __nonnull)entry highlight:(ChartHighlight * __nonnull)highlight -{ - NSLog(@"chartValueSelected"); -} - -- (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView -{ - NSLog(@"chartValueNothingSelected"); -} - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmScatterChartViewController.xib b/ChartsDemo/Classes/RealmDemos/RealmScatterChartViewController.xib deleted file mode 100644 index d9bd05d95d..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmScatterChartViewController.xib +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChartsDemo/Classes/RealmDemos/RealmWikiExampleChartViewController.h b/ChartsDemo/Classes/RealmDemos/RealmWikiExampleChartViewController.h deleted file mode 100644 index 5d0b5246c4..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmWikiExampleChartViewController.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// RealmWikiExampleChartViewController.h -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import -#import "RealmDemoBaseViewController.h" -#import - -@interface RealmWikiExampleChartViewController : RealmDemoBaseViewController - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmWikiExampleChartViewController.m b/ChartsDemo/Classes/RealmDemos/RealmWikiExampleChartViewController.m deleted file mode 100644 index 87df3202d2..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmWikiExampleChartViewController.m +++ /dev/null @@ -1,173 +0,0 @@ -// -// RealmWikiExampleChartViewController.m -// ChartsDemo -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import "RealmWikiExampleChartViewController.h" -#import "ChartsDemo-Swift.h" -#import -#import "Score.h" - -@interface RealmWikiExampleChartViewController () -{ - RLMResults *results; -} - -@property (nonatomic, strong) IBOutlet LineChartView *lineChartView; -@property (nonatomic, strong) IBOutlet BarChartView *barChartView; - -@end - -@implementation RealmWikiExampleChartViewController - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - self.title = @"Realm.io Wiki Example"; - - _lineChartView.delegate = self; - _barChartView.delegate = self; - - [self setupBarLineChartView:_lineChartView]; - [self setupBarLineChartView:_barChartView]; - - _lineChartView.extraBottomOffset = 5.f; - _barChartView.extraBottomOffset = 5.f; - - _lineChartView.leftAxis.drawGridLinesEnabled = NO; - _lineChartView.xAxis.drawGridLinesEnabled = NO; - _lineChartView.xAxis.labelCount = 5; - _lineChartView.xAxis.granularity = 1.0; - _barChartView.leftAxis.drawGridLinesEnabled = NO; - _barChartView.xAxis.drawGridLinesEnabled = NO; - _barChartView.xAxis.labelCount = 5; - _barChartView.xAxis.granularity = 1.0; - - // setup realm - RLMRealm *realm = [RLMRealm defaultRealm]; - - [realm beginWriteTransaction]; - - // clear previous scores that might exist from previous viewing of this VC - [realm deleteObjects:Score.allObjects]; - - // write some demo-data into the realm.io database - Score *score1 = [[Score alloc] initWithTotalScore:100.f scoreNr:0.0 playerName:@"Peter"]; - [realm addObject:score1]; - - Score *score2 = [[Score alloc] initWithTotalScore:110.f scoreNr:1.0 playerName:@"Lisa"]; - [realm addObject:score2]; - - Score *score3 = [[Score alloc] initWithTotalScore:130.f scoreNr:2.0 playerName:@"Dennis"]; - [realm addObject:score3]; - - Score *score4 = [[Score alloc] initWithTotalScore:70.f scoreNr:3.0 playerName:@"Luke"]; - [realm addObject:score4]; - - Score *score5 = [[Score alloc] initWithTotalScore:80.f scoreNr:4.0 playerName:@"Sarah"]; - [realm addObject:score5]; - - // commit changes to realm db - [realm commitWriteTransaction]; - - // add data to the chart - [self setData]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (void)setData -{ - RLMRealm *realm = [RLMRealm defaultRealm]; - - results = [Score allObjectsInRealm:realm]; - - _lineChartView.xAxis.valueFormatter = self; - _barChartView.xAxis.valueFormatter = self; - - // Line chart - RealmLineDataSet *lineDataSet = [[RealmLineDataSet alloc] initWithResults:(RLMResults *)results xValueField:@"scoreNr" yValueField:@"totalScore"]; - lineDataSet.drawCubicEnabled = NO; - lineDataSet.label = @"Result Scores"; - lineDataSet.drawCircleHoleEnabled = NO; - [lineDataSet setColor:[ChartColorTemplates colorFromString:@"#FF5722"]]; - [lineDataSet setCircleColor:[ChartColorTemplates colorFromString:@"#FF5722"]]; - lineDataSet.lineWidth = 1.8f; - lineDataSet.circleRadius = 3.6f; - - NSArray> *lineDataSets = @[lineDataSet]; - - LineChartData *lineData = [[LineChartData alloc] initWithDataSets:lineDataSets]; - [self styleData:lineData]; - - // set data - _lineChartView.data = lineData; - [_lineChartView animateWithYAxisDuration:1.4 - easingOption:ChartEasingOptionEaseInOutQuart]; - - // Bar chart - RealmBarDataSet *barDataSet = [[RealmBarDataSet alloc] initWithResults:(RLMResults *)results xValueField:@"scoreNr" yValueField:@"totalScore"]; - barDataSet.colors = @[ - [ChartColorTemplates colorFromString:@"#FF5722"], - [ChartColorTemplates colorFromString:@"#03A9F4"], - ]; - barDataSet.label = @"Realm BarDataSet"; - - NSArray> *barDataSets = @[barDataSet]; - - BarChartData *barData = [[BarChartData alloc] initWithDataSets:barDataSets]; - [self styleData:barData]; - - _barChartView.data = barData; - _barChartView.fitBars = YES; - [_barChartView notifyDataSetChanged]; - [_barChartView animateWithYAxisDuration:1.4 - easingOption:ChartEasingOptionEaseInOutQuart]; -} - -#pragma mark - ChartViewDelegate - -- (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartDataEntry * __nonnull)entry highlight:(ChartHighlight * __nonnull)highlight -{ - if (chartView == _lineChartView) - { - NSLog(@"chartValueSelected in Line Chart"); - } - else - { - NSLog(@"chartValueSelected in Bar Chart"); - } -} - -- (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView -{ - if (chartView == _lineChartView) - { - NSLog(@"chartValueNothingSelected in Line Chart"); - } - else - { - NSLog(@"chartValueNothingSelected in Bar Chart"); - } -} - -#pragma mark - IAxisValueFormatter - -- (NSString *)stringForValue:(double)value - axis:(ChartAxisBase *)axis -{ - return ((Score *)results[(int)value]).playerName; -} - -@end diff --git a/ChartsDemo/Classes/RealmDemos/RealmWikiExampleChartViewController.xib b/ChartsDemo/Classes/RealmDemos/RealmWikiExampleChartViewController.xib deleted file mode 100644 index 9805c72afe..0000000000 --- a/ChartsDemo/Classes/RealmDemos/RealmWikiExampleChartViewController.xib +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ChartsDemo/Classes/RealmDemoListViewController.h b/ChartsDemo/Classes/RealmDemosViewController.h similarity index 60% rename from ChartsDemo/Classes/RealmDemoListViewController.h rename to ChartsDemo/Classes/RealmDemosViewController.h index 3b8a274e5b..d73426e995 100644 --- a/ChartsDemo/Classes/RealmDemoListViewController.h +++ b/ChartsDemo/Classes/RealmDemosViewController.h @@ -1,5 +1,5 @@ // -// RealmDemoListViewController.h +// RealmDemosViewController.h // ChartsDemo // // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda @@ -10,9 +10,9 @@ // #import +#import "DemoBaseViewController.h" +#import -@interface RealmDemoListViewController : UIViewController - +@interface RealmDemosViewController : DemoBaseViewController @end - diff --git a/ChartsDemo/Classes/RealmDemosViewController.m b/ChartsDemo/Classes/RealmDemosViewController.m new file mode 100644 index 0000000000..52b7811661 --- /dev/null +++ b/ChartsDemo/Classes/RealmDemosViewController.m @@ -0,0 +1,35 @@ +// +// RealmDemosViewController.m +// ChartsDemo +// +// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda +// A port of MPAndroidChart for iOS +// Licensed under Apache License 2.0 +// +// https://github.com/danielgindi/Charts +// + +#import "RealmDemosViewController.h" +#import "ChartsDemo-Swift.h" + +@interface RealmDemosViewController () + +@end + +@implementation RealmDemosViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + self.title = @"Realm demos"; + +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +@end diff --git a/ChartsDemo/Classes/RealmDemosViewController.xib b/ChartsDemo/Classes/RealmDemosViewController.xib new file mode 100644 index 0000000000..0d3788dd13 --- /dev/null +++ b/ChartsDemo/Classes/RealmDemosViewController.xib @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Realm demos are now part of the separate ChartsRealm repo. + +Please go to https://github.com/danielgindi/ChartsRealm and follow the instructions there. + + + + + + + + + + + + + + + + diff --git a/ChartsDemo/Resources/Images.xcassets/Contents.json b/ChartsDemo/Resources/Images.xcassets/Contents.json new file mode 100644 index 0000000000..da4a164c91 --- /dev/null +++ b/ChartsDemo/Resources/Images.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ChartsDemo/Resources/Images.xcassets/icon.imageset/Contents.json b/ChartsDemo/Resources/Images.xcassets/icon.imageset/Contents.json new file mode 100644 index 0000000000..8c89aaaae3 --- /dev/null +++ b/ChartsDemo/Resources/Images.xcassets/icon.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "star-2.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "star-1.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "star.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ChartsDemo/Resources/Images.xcassets/icon.imageset/star-1.png b/ChartsDemo/Resources/Images.xcassets/icon.imageset/star-1.png new file mode 100644 index 0000000000..c7811ef2b8 Binary files /dev/null and b/ChartsDemo/Resources/Images.xcassets/icon.imageset/star-1.png differ diff --git a/ChartsDemo/Resources/Images.xcassets/icon.imageset/star-2.png b/ChartsDemo/Resources/Images.xcassets/icon.imageset/star-2.png new file mode 100644 index 0000000000..c7811ef2b8 Binary files /dev/null and b/ChartsDemo/Resources/Images.xcassets/icon.imageset/star-2.png differ diff --git a/ChartsDemo/Resources/Images.xcassets/icon.imageset/star.png b/ChartsDemo/Resources/Images.xcassets/icon.imageset/star.png new file mode 100644 index 0000000000..c7811ef2b8 Binary files /dev/null and b/ChartsDemo/Resources/Images.xcassets/icon.imageset/star.png differ diff --git a/ChartsDemo/Supporting Files/Info.plist b/ChartsDemo/Supporting Files/Info.plist index fb4115c84c..4a1b14c07a 100644 --- a/ChartsDemo/Supporting Files/Info.plist +++ b/ChartsDemo/Supporting Files/Info.plist @@ -32,5 +32,7 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + NSPhotoLibraryUsageDescription + This app requires access to the photo library to store shots of charts there. diff --git a/Gemfile.lock b/Gemfile.lock index 00fbd8858e..8cc5c06c8f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,7 @@ GEM remote: https://rubygems.org/ specs: + CFPropertyList (2.3.4) activesupport (4.2.7.1) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) @@ -8,16 +9,16 @@ GEM thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) claide (1.0.1) - cocoapods (1.1.0) + cocoapods (1.1.1) activesupport (>= 4.0.2, < 5) claide (>= 1.0.1, < 2.0) - cocoapods-core (= 1.1.0) + cocoapods-core (= 1.1.1) cocoapods-deintegrate (>= 1.0.1, < 2.0) cocoapods-downloader (>= 1.1.2, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) cocoapods-stats (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.1.0, < 2.0) + cocoapods-trunk (>= 1.1.1, < 2.0) cocoapods-try (>= 1.1.0, < 2.0) colored (~> 1.2) escape (~> 0.0.4) @@ -25,18 +26,18 @@ GEM gh_inspector (~> 1.0) molinillo (~> 0.5.1) nap (~> 1.0) - xcodeproj (>= 1.3.2, < 2.0) - cocoapods-core (1.1.0) + xcodeproj (>= 1.3.3, < 2.0) + cocoapods-core (1.1.1) activesupport (>= 4.0.2, < 5) fuzzy_match (~> 2.0.4) nap (~> 1.0) cocoapods-deintegrate (1.0.1) - cocoapods-downloader (1.1.2) + cocoapods-downloader (1.1.3) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.0) cocoapods-stats (1.0.0) - cocoapods-trunk (1.1.0) + cocoapods-trunk (1.1.2) nap (>= 0.8, < 2.0) netrc (= 0.7.8) cocoapods-try (1.1.0) @@ -44,22 +45,25 @@ GEM escape (0.0.4) fourflusher (2.0.1) fuzzy_match (2.0.4) - gh_inspector (1.0.2) + gh_inspector (1.0.3) i18n (0.7.0) - json (1.8.3) - minitest (5.9.1) - molinillo (0.5.1) + json (1.8.5) + minitest (5.10.1) + molinillo (0.5.5) + nanaimo (0.2.3) nap (1.1.0) netrc (0.7.8) - rake (11.3.0) + rake (12.0.0) rouge (1.11.1) thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) - xcodeproj (1.3.2) + xcodeproj (1.4.2) + CFPropertyList (~> 2.3.3) activesupport (>= 3) claide (>= 1.0.1, < 2.0) colored (~> 1.2) + nanaimo (~> 0.2.3) xcpretty (0.2.4) rouge (~> 1.8) @@ -72,4 +76,4 @@ DEPENDENCIES xcpretty BUNDLED WITH - 1.13.5 + 1.13.7 diff --git a/README.md b/README.md index 9e7075870d..6043cd4e6f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ -**Version 3.0.1**, synced to [MPAndroidChart #345b4bc](https://github.com/PhilJay/MPAndroidChart/commit/345b4bc) +**Version 3.0.2**, synced to [MPAndroidChart #f6a398b](https://github.com/PhilJay/MPAndroidChart/commit/f6a398b) ![alt tag](https://raw.github.com/danielgindi/Charts/master/Assets/feature_graphic.png) ![Supported Platforms](https://img.shields.io/cocoapods/p/Charts.svg) [![Releases](https://img.shields.io/github/release/danielgindi/Charts.svg)](https://github.com/danielgindi/Charts/releases) [![Latest pod release](https://img.shields.io/cocoapods/v/Charts.svg)](http://cocoapods.org/pods/charts) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Build Status](https://travis-ci.org/danielgindi/Charts.svg?branch=master)](https://travis-ci.org/danielgindi/Charts) [![codecov](https://codecov.io/gh/danielgindi/Charts/branch/master/graph/badge.svg)](https://codecov.io/gh/danielgindi/Charts) [![Join the chat at https://gitter.im/danielgindi/Charts](https://badges.gitter.im/danielgindi/Charts.svg)](https://gitter.im/danielgindi/Charts?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ### Just a heads up: Charts 3.0 has some breaking changes. Please read [the release/migration notes](https://github.com/danielgindi/Charts/releases/tag/v3.0.0). +### Another heads up: ChartsRealm is now in a [separate repo](https://github.com/danielgindi/ChartsRealm). Pods is also now `Charts` and `ChartsRealm`, instead of ~`Charts/Core`~ and ~`Charts/Realm`~ -* Xcode 8.0 / Swift 3.0 (For Swift 2.3 support please use [Charts 2.3.0](https://github.com/danielgindi/Charts/tree/v2.3.0)) +* Xcode 8.0 / Swift 3.1 * iOS >= 8.0 (Use as an **Embedded** Framework) * tvOS >= 9.0 * macOS >= 10.11 @@ -25,8 +26,7 @@ I've chosen to write it in `Swift` as it can be highly optimized by the compiler * Usually it is specified here a few lines above. * In most cases it will be the latest Xcode version. * Make sure that your project supports Swift 3.0 -* Run `carthage checkout` in the project folder, to fetch dependencies (i.e Realm). - * Realm is not required for using Charts - it is just a feature. But as the demo demonstrates Realm - you have to have it when running the demo. +* Optional: Run `carthage checkout` in the project folder, to fetch dependencies (i.e testing dependencies). * If you don't have Carthage - you can get it [here](https://github.com/Carthage/Carthage/releases). @@ -39,9 +39,11 @@ In order to correctly compile: 3. `@import Charts` 4. When using Swift in an ObjC project: - You need to import your Bridging Header. Usually it is "*YourProject-Swift.h*", so in ChartsDemo it's "*ChartsDemo-Swift.h*". Do not try to actually include "*ChartsDemo-Swift.h*" in your project :-) - - Under "Build Options", mark "Embedded Content Contains Swift Code" + - (Xcode 8.1 and earlier) Under "Build Options", mark "Embedded Content Contains Swift Code" + - (Xcode 8.2+) Under "Build Options", mark "Always Embed Swift Standard Libraries" 5. When using [Realm.io](https://realm.io/): - Note that the Realm framework is not linked with Charts - it is only there for *optional* bindings. Which means that you need to have the framework in your project, and in a compatible version to whatever is compiled with Charts. We will do our best to always compile against the latest version. + - You'll need to add `ChartsRealm` as a dependency too. ## 3rd party tutorials @@ -53,8 +55,6 @@ In order to correctly compile: #### Can't compile? * Please note the difference between installing a compiled framework from CocoaPods or Carthage, and copying the source code. -* If you are using [Realm](https://realm.io/), please also `#import ` -* If you are compiling the source code and want to use Realm, please make sure to include the code from `ChartsRealm` project. * Please read the **Usage** section again. * Search in the issues * Try to politely ask in the issues section @@ -67,11 +67,7 @@ In order to correctly compile: ## CocoaPods Install Add `pod 'Charts'` to your Podfile. "Charts" is the name of the library. - -For [Realm](https://realm.io/) support you can specify the subspec in your Podfile as follows: -``` -pod 'Charts/Realm' -``` +For [Realm](https://realm.io/) support, please add `pod 'ChartsRealm'` too. **Note:** ~~`pod 'ios-charts'`~~ is not the correct library, and refers to a different project by someone else. @@ -80,11 +76,11 @@ pod 'Charts/Realm' Charts now include Carthage prebuilt binaries. ```carthage -github "danielgindi/Charts" == 3.0.1 -github "danielgindi/Charts" ~> 3.0.1 +github "danielgindi/Charts" == 3.0.2 +github "danielgindi/Charts" ~> 3.0.2 ``` -In order to build the binaries for a new release, use `carthage build --no-skip-current && carthage archive Charts && carthage archive ChartsRealm`. +In order to build the binaries for a new release, use `carthage build --no-skip-current && carthage archive Charts`. ## 3rd party bindings @@ -129,7 +125,7 @@ Features - Animations (build up animations, on both x- and y-axis) - Limit lines (providing additional information, maximums, ...) - Fully customizable (paints, typefaces, legends, colors, background, gestures, dashed lines, ...) - - Plotting data directly from [**Realm.io**](https://realm.io) mobile database + - Plotting data directly from [**Realm.io**](https://realm.io) mobile database ([here](https://github.com/danielgindi/ChartsRealm)) **Chart types:** diff --git a/Rakefile b/Rakefile index 77b714c57f..daf8b1bcb7 100644 --- a/Rakefile +++ b/Rakefile @@ -26,7 +26,6 @@ end def build_schemes %w( Charts - ChartsRealm ) end @@ -41,7 +40,7 @@ def devices iOS: { sdk: 'iphonesimulator', device: "name='iPhone 7'", - uuid: '5F911B30-5F23-403B-9697-1DFDC24773C8' + name: 'iPhone 7' }, macOS: { sdk: 'macosx', @@ -51,7 +50,7 @@ def devices tvOS: { sdk: 'appletvsimulator', device: "name='Apple TV 1080p'", - uuid: '273D776F-196E-4F2A-AEF2-E1E3EAE99B47' + name: 'Apple TV 1080p' } } end @@ -143,4 +142,4 @@ end desc 'updated the podspec on cocoapods' task :update_pod do sh "bundle exec pod trunk push Charts.podspec --allow-warnings" -end \ No newline at end of file +end diff --git a/Source/Charts/Animation/ChartAnimationEasing.swift b/Source/Charts/Animation/ChartAnimationEasing.swift index 6afdd2a6e9..58b0b632d8 100644 --- a/Source/Charts/Animation/ChartAnimationEasing.swift +++ b/Source/Charts/Animation/ChartAnimationEasing.swift @@ -211,17 +211,17 @@ internal struct EasingFunctions internal static let EaseInSine = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in var position: TimeInterval = elapsed / duration - return Double( -cos(position * M_PI_2) + 1.0 ) + return Double( -cos(position * Double.pi / 2) + 1.0 ) } internal static let EaseOutSine = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in var position: TimeInterval = elapsed / duration - return Double( sin(position * M_PI_2) ) + return Double( sin(position * Double.pi / 2) ) } internal static let EaseInOutSine = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in var position: TimeInterval = elapsed / duration - return Double( -0.5 * (cos(M_PI * position) - 1.0) ) + return Double( -0.5 * (cos(Double.pi * position) - 1.0) ) } internal static let EaseInExpo = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in @@ -286,9 +286,9 @@ internal struct EasingFunctions } var p = duration * 0.3 - var s = p / (2.0 * M_PI) * asin(1.0) + var s = p / (2.0 * Double.pi) * asin(1.0) position -= 1.0 - return Double( -(pow(2.0, 10.0 * position) * sin((position * duration - s) * (2.0 * M_PI) / p)) ) + return Double( -(pow(2.0, 10.0 * position) * sin((position * duration - s) * (2.0 * Double.pi) / p)) ) } internal static let EaseOutElastic = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in @@ -304,8 +304,8 @@ internal struct EasingFunctions } var p = duration * 0.3 - var s = p / (2.0 * M_PI) * asin(1.0) - return Double( pow(2.0, -10.0 * position) * sin((position * duration - s) * (2.0 * M_PI) / p) + 1.0 ) + var s = p / (2.0 * Double.pi) * asin(1.0) + return Double( pow(2.0, -10.0 * position) * sin((position * duration - s) * (2.0 * Double.pi) / p) + 1.0 ) } internal static let EaseInOutElastic = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in @@ -321,14 +321,14 @@ internal struct EasingFunctions } var p = duration * (0.3 * 1.5) - var s = p / (2.0 * M_PI) * asin(1.0) + var s = p / (2.0 * Double.pi) * asin(1.0) if position < 1.0 { position -= 1.0 - return Double( -0.5 * (pow(2.0, 10.0 * position) * sin((position * duration - s) * (2.0 * M_PI) / p)) ) + return Double( -0.5 * (pow(2.0, 10.0 * position) * sin((position * duration - s) * (2.0 * Double.pi) / p)) ) } position -= 1.0 - return Double( pow(2.0, -10.0 * position) * sin((position * duration - s) * (2.0 * M_PI) / p) * 0.5 + 1.0 ) + return Double( pow(2.0, -10.0 * position) * sin((position * duration - s) * (2.0 * Double.pi) / p) * 0.5 + 1.0 ) } internal static let EaseInBack = { (elapsed: TimeInterval, duration: TimeInterval) -> Double in diff --git a/Source/Charts/Charts/BarLineChartViewBase.swift b/Source/Charts/Charts/BarLineChartViewBase.swift index 66aa8db60b..747120718f 100644 --- a/Source/Charts/Charts/BarLineChartViewBase.swift +++ b/Source/Charts/Charts/BarLineChartViewBase.swift @@ -174,14 +174,22 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD // execute all drawing commands drawGridBackground(context: context) + + if _autoScaleMinMaxEnabled + { + autoScale() + } + if _leftAxis.isEnabled { _leftYAxisRenderer?.computeAxis(min: _leftAxis._axisMinimum, max: _leftAxis._axisMaximum, inverted: _leftAxis.isInverted) } + if _rightAxis.isEnabled { _rightYAxisRenderer?.computeAxis(min: _rightAxis._axisMinimum, max: _rightAxis._axisMaximum, inverted: _rightAxis.isInverted) } + if _xAxis.isEnabled { _xAxisRenderer?.computeAxis(min: _xAxis._axisMinimum, max: _xAxis._axisMaximum, inverted: false) @@ -191,25 +199,22 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD _leftYAxisRenderer?.renderAxisLine(context: context) _rightYAxisRenderer?.renderAxisLine(context: context) - if _autoScaleMinMaxEnabled - { - autoScale() - } - // The renderers are responsible for clipping, to account for line-width center etc. _xAxisRenderer?.renderGridLines(context: context) _leftYAxisRenderer?.renderGridLines(context: context) _rightYAxisRenderer?.renderGridLines(context: context) - if _xAxis.isDrawLimitLinesBehindDataEnabled + if _xAxis.isEnabled && _xAxis.isDrawLimitLinesBehindDataEnabled { _xAxisRenderer?.renderLimitLines(context: context) } - if _leftAxis.isDrawLimitLinesBehindDataEnabled + + if _leftAxis.isEnabled && _leftAxis.isDrawLimitLinesBehindDataEnabled { _leftYAxisRenderer?.renderLimitLines(context: context) } - if _rightAxis.isDrawLimitLinesBehindDataEnabled + + if _rightAxis.isEnabled && _rightAxis.isDrawLimitLinesBehindDataEnabled { _rightYAxisRenderer?.renderLimitLines(context: context) } @@ -229,15 +234,17 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD renderer!.drawExtras(context: context) - if !_xAxis.isDrawLimitLinesBehindDataEnabled + if _xAxis.isEnabled && !_xAxis.isDrawLimitLinesBehindDataEnabled { _xAxisRenderer?.renderLimitLines(context: context) } - if !_leftAxis.isDrawLimitLinesBehindDataEnabled + + if _leftAxis.isEnabled && !_leftAxis.isDrawLimitLinesBehindDataEnabled { _leftYAxisRenderer?.renderLimitLines(context: context) } - if !_rightAxis.isDrawLimitLinesBehindDataEnabled + + if _rightAxis.isEnabled && !_rightAxis.isDrawLimitLinesBehindDataEnabled { _rightYAxisRenderer?.renderLimitLines(context: context) } @@ -281,8 +288,16 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD _xAxis.calculate(min: data.xMin, max: data.xMax) // calculate axis range (min / max) according to provided data - _leftAxis.calculate(min: data.getYMin(axis: .left), max: data.getYMax(axis: .left)) - _rightAxis.calculate(min: data.getYMin(axis: .right), max: data.getYMax(axis: .right)) + + if _leftAxis.isEnabled + { + _leftAxis.calculate(min: data.getYMin(axis: .left), max: data.getYMax(axis: .left)) + } + + if _rightAxis.isEnabled + { + _rightAxis.calculate(min: data.getYMin(axis: .right), max: data.getYMax(axis: .right)) + } calculateOffsets() } @@ -944,7 +959,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD /// MARK: Viewport modifiers - /// Zooms in by 1.4, into the charts center. center. + /// Zooms in by 1.4, into the charts center. open func zoomIn() { let center = _viewPortHandler.contentCenter @@ -957,7 +972,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD setNeedsDisplay() } - /// Zooms out by 0.7, from the charts center. center. + /// Zooms out by 0.7, from the charts center. open func zoomOut() { let center = _viewPortHandler.contentCenter @@ -969,6 +984,17 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD calculateOffsets() setNeedsDisplay() } + + /// Zooms out to original size. + open func resetZoom() + { + let matrix = _viewPortHandler.resetZoom() + let _ = _viewPortHandler.refresh(newMatrix: matrix, chart: self, invalidate: false) + + // Range might have changed, which means that Y-axis labels could have changed in size, affecting Y-axis size. So we need to recalculate offsets. + calculateOffsets() + setNeedsDisplay() + } /// Zooms in or out by the given scale factor. x and y are the coordinates /// (in pixels) of the zoom center. diff --git a/Source/Charts/Charts/ChartViewBase.swift b/Source/Charts/Charts/ChartViewBase.swift index 695a622996..eaa5e8f8d7 100755 --- a/Source/Charts/Charts/ChartViewBase.swift +++ b/Source/Charts/Charts/ChartViewBase.swift @@ -155,7 +155,10 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate /// flag that indicates if offsets calculation has already been done or not fileprivate var _offsetsCalculated = false - + + /// if `true` , when call clear(), also set lastHighlighted to nil + open var clearLastHighlightedEnabled = false + /// array of Highlight objects that reference the highlighted slices in the chart internal var _indicesToHighlight = [Highlight]() @@ -197,10 +200,6 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate public override init(frame: CGRect) { super.init(frame: frame) - - #if os(iOS) - self.backgroundColor = NSUIColor.clear - #endif initialize() } @@ -218,6 +217,10 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate internal func initialize() { + #if os(iOS) + self.backgroundColor = NSUIColor.clear + #endif + _animator = Animator() _animator.delegate = self @@ -276,6 +279,10 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate _data = nil _offsetsCalculated = false _indicesToHighlight.removeAll() + if clearLastHighlightedEnabled + { + lastHighlighted = nil + } setNeedsDisplay() } diff --git a/Source/Charts/Charts/RadarChartView.swift b/Source/Charts/Charts/RadarChartView.swift index 4aa9321d23..84cf460ce1 100644 --- a/Source/Charts/Charts/RadarChartView.swift +++ b/Source/Charts/Charts/RadarChartView.swift @@ -121,7 +121,10 @@ open class RadarChartView: PieRadarChartViewBase renderer!.drawExtras(context: context) } - _yAxisRenderer.renderLimitLines(context: context) + if _yAxis.isEnabled && _yAxis.isDrawLimitLinesBehindDataEnabled + { + _yAxisRenderer.renderLimitLines(context: context) + } renderer!.drawData(context: context) @@ -129,7 +132,12 @@ open class RadarChartView: PieRadarChartViewBase { renderer!.drawHighlighted(context: context, indices: _indicesToHighlight) } - + + if _yAxis.isEnabled && !_yAxis.isDrawLimitLinesBehindDataEnabled + { + _yAxisRenderer.renderLimitLines(context: context) + } + _yAxisRenderer.renderAxisLabels(context: context) renderer!.drawValues(context: context) diff --git a/Source/Charts/Components/Legend.swift b/Source/Charts/Components/Legend.swift index 42a544b8f5..e50e76c117 100644 --- a/Source/Charts/Components/Legend.swift +++ b/Source/Charts/Components/Legend.swift @@ -289,7 +289,7 @@ open class Legend: ComponentBase /// this is currently supported only for `orientation == Horizontal`. /// you may want to set maxSizePercent when word wrapping, to set the point where the text wraps. /// - /// **default**: false + /// **default**: true open var wordWrapEnabled = true /// if this is set, then word wrapping the legend is enabled. diff --git a/Source/Charts/Components/YAxis.swift b/Source/Charts/Components/YAxis.swift index 1af1e6c327..54dfe4b924 100644 --- a/Source/Charts/Components/YAxis.swift +++ b/Source/Charts/Components/YAxis.swift @@ -38,6 +38,9 @@ open class YAxis: AxisBase case right } + /// indicates if the bottom y-label entry is drawn or not + open var drawBottomYLabelEntryEnabled = true + /// indicates if the top y-label entry is drawn or not open var drawTopYLabelEntryEnabled = true @@ -169,6 +172,8 @@ open class YAxis: AxisBase axisRange = abs(_axisMaximum - _axisMinimum) } + open var isDrawBottomYLabelEntryEnabled: Bool { return drawBottomYLabelEntryEnabled } + open var isDrawTopYLabelEntryEnabled: Bool { return drawTopYLabelEntryEnabled } } diff --git a/Source/Charts/Data/Implementations/ChartBaseDataSet.swift b/Source/Charts/Data/Implementations/ChartBaseDataSet.swift index e8d3def362..308b789559 100644 --- a/Source/Charts/Data/Implementations/ChartBaseDataSet.swift +++ b/Source/Charts/Data/Implementations/ChartBaseDataSet.swift @@ -126,12 +126,12 @@ open class ChartBaseDataSet: NSObject, IChartDataSet fatalError("addEntryOrdered is not implemented in ChartBaseDataSet") } - open func removeEntry(_ entry: ChartDataEntry) -> Bool + @discardableResult open func removeEntry(_ entry: ChartDataEntry) -> Bool { fatalError("removeEntry is not implemented in ChartBaseDataSet") } - open func removeEntry(index: Int) -> Bool + @discardableResult open func removeEntry(index: Int) -> Bool { if let entry = entryForIndex(index) { @@ -140,7 +140,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet return false } - open func removeEntry(x: Double) -> Bool + @discardableResult open func removeEntry(x: Double) -> Bool { if let entry = entryForXValue(x, closestToY: Double.nan) { @@ -149,7 +149,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet return false } - open func removeFirst() -> Bool + @discardableResult open func removeFirst() -> Bool { if entryCount > 0 { @@ -161,7 +161,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet return false } - open func removeLast() -> Bool + @discardableResult open func removeLast() -> Bool { if entryCount > 0 { @@ -352,7 +352,9 @@ open class ChartBaseDataSet: NSObject, IChartDataSet /// [1, 3, 4, 2] will paint [- ---- - ---- ] open var formLineDashLengths: [CGFloat]? = nil - /// Set this to true to draw y-values on the chart + /// Set this to true to draw y-values on the chart. + /// + /// - note: For bar and line charts: if `maxVisibleCount` is reached, no values will be drawn even if this is enabled. open var drawValuesEnabled = true /// - returns: `true` if y-value drawing is enabled, `false` ifnot @@ -360,6 +362,24 @@ open class ChartBaseDataSet: NSObject, IChartDataSet { return drawValuesEnabled } + + /// Set this to true to draw y-icons on the chart. + /// + /// - note: For bar and line charts: if `maxVisibleCount` is reached, no icons will be drawn even if this is enabled. + open var drawIconsEnabled = true + + /// Returns true if y-icon drawing is enabled, false if not + open var isDrawIconsEnabled: Bool + { + return drawIconsEnabled + } + + /// Offset of icons drawn on the chart. + /// + /// For all charts except Pie and Radar it will be ordinary (x offset, y offset). + /// + /// For Pie and Radar chart it will be (y offset, distance from center offset); so if you want icon to be rendered under value, you should increase X component of CGPoint, and if you want icon to be rendered closet to center, you should decrease height component of CGPoint. + open var iconsOffset = CGPoint(x: 0, y: 0) /// Set the visibility of this DataSet. If not visible, the DataSet will not be drawn to the chart upon refreshing it. open var visible = true diff --git a/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift index 7d39bc3c71..a4ab03d85d 100644 --- a/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift @@ -30,6 +30,30 @@ open class BarChartDataEntry: ChartDataEntry super.init() } + /// Constructor for normal bars (not stacked). + public override init(x: Double, y: Double) + { + super.init(x: x, y: y) + } + + /// Constructor for normal bars (not stacked). + public override init(x: Double, y: Double, data: AnyObject?) + { + super.init(x: x, y: y, data: data) + } + + /// Constructor for normal bars (not stacked). + public override init(x: Double, y: Double, icon: NSUIImage?) + { + super.init(x: x, y: y, icon: icon) + } + + /// Constructor for normal bars (not stacked). + public override init(x: Double, y: Double, icon: NSUIImage?, data: AnyObject?) + { + super.init(x: x, y: y, icon: icon, data: data) + } + /// Constructor for stacked bar entries. public init(x: Double, yValues: [Double]) { @@ -39,25 +63,41 @@ open class BarChartDataEntry: ChartDataEntry calcRanges() } - /// Constructor for normal bars (not stacked). - public override init(x: Double, y: Double) + /// This constructor is misleading, please use the `data` argument instead of `label`. + @available(*, deprecated: 1.0, message: "Use `data` argument instead of `label`.") + public init(x: Double, yValues: [Double], label: String) { - super.init(x: x, y: y) + super.init(x: x, y: BarChartDataEntry.calcSum(values: yValues), data: label as AnyObject?) + self._yVals = yValues + calcPosNegSum() + calcRanges() } - /// Constructor for stacked bar entries. - public init(x: Double, yValues: [Double], label: String) + /// Constructor for stacked bar entries. One data object for whole stack + public init(x: Double, yValues: [Double], data: AnyObject?) { - super.init(x: x, y: BarChartDataEntry.calcSum(values: yValues), data: label as AnyObject?) + super.init(x: x, y: BarChartDataEntry.calcSum(values: yValues), data: data) self._yVals = yValues calcPosNegSum() calcRanges() } - /// Constructor for normal bars (not stacked). - public override init(x: Double, y: Double, data: AnyObject?) + /// Constructor for stacked bar entries. One data object for whole stack + public init(x: Double, yValues: [Double], icon: NSUIImage?, data: AnyObject?) { - super.init(x: x, y: y, data: data) + super.init(x: x, y: BarChartDataEntry.calcSum(values: yValues), icon: icon, data: data) + self._yVals = yValues + calcPosNegSum() + calcRanges() + } + + /// Constructor for stacked bar entries. One data object for whole stack + public init(x: Double, yValues: [Double], icon: NSUIImage?) + { + super.init(x: x, y: BarChartDataEntry.calcSum(values: yValues), icon: icon) + self._yVals = yValues + calcPosNegSum() + calcRanges() } open func sumBelow(stackIndex :Int) -> Double diff --git a/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift index 37bdf08724..95941253ba 100644 --- a/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift @@ -39,7 +39,30 @@ open class BubbleChartDataEntry: ChartDataEntry public init(x: Double, y: Double, size: CGFloat, data: AnyObject?) { super.init(x: x, y: y, data: data) - + + self.size = size + } + + /// - parameter x: The index on the x-axis. + /// - parameter y: The value on the y-axis. + /// - parameter size: The size of the bubble. + /// - parameter icon: icon image + public init(x: Double, y: Double, size: CGFloat, icon: NSUIImage?) + { + super.init(x: x, y: y, icon: icon) + + self.size = size + } + + /// - parameter x: The index on the x-axis. + /// - parameter y: The value on the y-axis. + /// - parameter size: The size of the bubble. + /// - parameter icon: icon image + /// - parameter data: Spot for additional data this Entry represents. + public init(x: Double, y: Double, size: CGFloat, icon: NSUIImage?, data: AnyObject?) + { + super.init(x: x, y: y, icon: icon, data: data) + self.size = size } diff --git a/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift index 0b02ac184d..799f1b75a1 100644 --- a/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift @@ -50,6 +50,26 @@ open class CandleChartDataEntry: ChartDataEntry self.close = close } + public init(x: Double, shadowH: Double, shadowL: Double, open: Double, close: Double, icon: NSUIImage?) + { + super.init(x: x, y: (shadowH + shadowL) / 2.0, icon: icon) + + self.high = shadowH + self.low = shadowL + self.open = open + self.close = close + } + + public init(x: Double, shadowH: Double, shadowL: Double, open: Double, close: Double, icon: NSUIImage?, data: AnyObject?) + { + super.init(x: x, y: (shadowH + shadowL) / 2.0, icon: icon, data: data) + + self.high = shadowH + self.low = shadowL + self.open = open + self.close = close + } + /// - returns: The overall range (difference) between shadow-high and shadow-low. open var shadowRange: Double { @@ -81,9 +101,9 @@ open class CandleChartDataEntry: ChartDataEntry { let copy = super.copyWithZone(zone) as! CandleChartDataEntry copy.high = high - copy.high = low - copy.high = open - copy.high = close + copy.low = low + copy.open = open + copy.close = close return copy } } diff --git a/Source/Charts/Data/Implementations/Standard/ChartData.swift b/Source/Charts/Data/Implementations/Standard/ChartData.swift index 046c209d52..5d64efeb84 100644 --- a/Source/Charts/Data/Implementations/Standard/ChartData.swift +++ b/Source/Charts/Data/Implementations/Standard/ChartData.swift @@ -13,14 +13,14 @@ import Foundation open class ChartData: NSObject { - internal var _yMax: Double = -DBL_MAX - internal var _yMin: Double = DBL_MAX - internal var _xMax: Double = -DBL_MAX - internal var _xMin: Double = DBL_MAX - internal var _leftAxisMax: Double = -DBL_MAX - internal var _leftAxisMin: Double = DBL_MAX - internal var _rightAxisMax: Double = -DBL_MAX - internal var _rightAxisMin: Double = DBL_MAX + internal var _yMax: Double = -Double.greatestFiniteMagnitude + internal var _yMin: Double = Double.greatestFiniteMagnitude + internal var _xMax: Double = -Double.greatestFiniteMagnitude + internal var _xMin: Double = Double.greatestFiniteMagnitude + internal var _leftAxisMax: Double = -Double.greatestFiniteMagnitude + internal var _leftAxisMin: Double = Double.greatestFiniteMagnitude + internal var _rightAxisMax: Double = -Double.greatestFiniteMagnitude + internal var _rightAxisMin: Double = Double.greatestFiniteMagnitude internal var _dataSets = [IChartDataSet]() @@ -71,20 +71,20 @@ open class ChartData: NSObject /// calc minimum and maximum y value over all datasets open func calcMinMax() { - _yMax = -DBL_MAX - _yMin = DBL_MAX - _xMax = -DBL_MAX - _xMin = DBL_MAX + _yMax = -Double.greatestFiniteMagnitude + _yMin = Double.greatestFiniteMagnitude + _xMax = -Double.greatestFiniteMagnitude + _xMin = Double.greatestFiniteMagnitude for set in _dataSets { calcMinMax(dataSet: set) } - _leftAxisMax = -DBL_MAX - _leftAxisMin = DBL_MAX - _rightAxisMax = -DBL_MAX - _rightAxisMin = DBL_MAX + _leftAxisMax = -Double.greatestFiniteMagnitude + _leftAxisMin = Double.greatestFiniteMagnitude + _rightAxisMax = -Double.greatestFiniteMagnitude + _rightAxisMin = Double.greatestFiniteMagnitude // left axis let firstLeft = getFirstLeft(dataSets: dataSets) @@ -257,7 +257,7 @@ open class ChartData: NSObject { if axis == .left { - if _leftAxisMin == DBL_MAX + if _leftAxisMin == Double.greatestFiniteMagnitude { return _rightAxisMin } @@ -268,7 +268,7 @@ open class ChartData: NSObject } else { - if _rightAxisMin == DBL_MAX + if _rightAxisMin == Double.greatestFiniteMagnitude { return _leftAxisMin } @@ -295,7 +295,7 @@ open class ChartData: NSObject { if axis == .left { - if _leftAxisMax == -DBL_MAX + if _leftAxisMax == -Double.greatestFiniteMagnitude { return _rightAxisMax } @@ -306,7 +306,7 @@ open class ChartData: NSObject } else { - if _rightAxisMax == -DBL_MAX + if _rightAxisMax == -Double.greatestFiniteMagnitude { return _leftAxisMax } @@ -454,7 +454,7 @@ open class ChartData: NSObject /// Also recalculates all minimum and maximum values. /// /// - returns: `true` if a DataSet was removed, `false` ifno DataSet could be removed. - open func removeDataSet(_ dataSet: IChartDataSet!) -> Bool + @discardableResult open func removeDataSet(_ dataSet: IChartDataSet!) -> Bool { if dataSet === nil { @@ -476,7 +476,7 @@ open class ChartData: NSObject /// Also recalculates all minimum and maximum values. /// /// - returns: `true` if a DataSet was removed, `false` ifno DataSet could be removed. - open func removeDataSetByIndex(_ index: Int) -> Bool + @discardableResult open func removeDataSetByIndex(_ index: Int) -> Bool { if index >= _dataSets.count || index < 0 { @@ -508,7 +508,7 @@ open class ChartData: NSObject } /// Removes the given Entry object from the DataSet at the specified index. - open func removeEntry(_ entry: ChartDataEntry, dataSetIndex: Int) -> Bool + @discardableResult open func removeEntry(_ entry: ChartDataEntry, dataSetIndex: Int) -> Bool { // entry outofbounds if dataSetIndex >= _dataSets.count @@ -530,7 +530,7 @@ open class ChartData: NSObject /// Removes the Entry object closest to the given xIndex from the ChartDataSet at the /// specified index. /// - returns: `true` if an entry was removed, `false` ifno Entry was found that meets the specified requirements. - open func removeEntry(xValue: Double, dataSetIndex: Int) -> Bool + @discardableResult open func removeEntry(xValue: Double, dataSetIndex: Int) -> Bool { if dataSetIndex >= _dataSets.count { diff --git a/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift index e9eccd50aa..fe3d0aeccb 100644 --- a/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift @@ -35,16 +35,41 @@ open class ChartDataEntry: ChartDataEntryBase /// - parameter x: the x value /// - parameter y: the y value (the actual value of the entry) /// - parameter data: Space for additional data this Entry represents. - + public init(x: Double, y: Double, data: AnyObject?) { super.init(y: y) self.x = x - + self.data = data } + /// An Entry represents one single entry in the chart. + /// - parameter x: the x value + /// - parameter y: the y value (the actual value of the entry) + /// - parameter icon: icon image + + public init(x: Double, y: Double, icon: NSUIImage?) + { + super.init(y: y, icon: icon) + + self.x = x + } + + /// An Entry represents one single entry in the chart. + /// - parameter x: the x value + /// - parameter y: the y value (the actual value of the entry) + /// - parameter icon: icon image + /// - parameter data: Space for additional data this Entry represents. + + public init(x: Double, y: Double, icon: NSUIImage?, data: AnyObject?) + { + super.init(y: y, icon: icon, data: data) + + self.x = x + } + // MARK: NSObject open override func isEqual(_ object: Any?) -> Bool @@ -54,7 +79,7 @@ open class ChartDataEntry: ChartDataEntryBase return false } - if fabs((object! as AnyObject).x - x) > DBL_EPSILON + if fabs((object! as AnyObject).x - x) > Double.ulpOfOne { return false } @@ -100,12 +125,12 @@ public func ==(lhs: ChartDataEntry, rhs: ChartDataEntry) -> Bool return false } - if fabs(lhs.x - rhs.x) > DBL_EPSILON + if fabs(lhs.x - rhs.x) > Double.ulpOfOne { return false } - if fabs(lhs.y - rhs.y) > DBL_EPSILON + if fabs(lhs.y - rhs.y) > Double.ulpOfOne { return false } diff --git a/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift b/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift index bef571973a..36bb8e2725 100644 --- a/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift +++ b/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift @@ -19,6 +19,9 @@ open class ChartDataEntryBase: NSObject /// optional spot for additional data this Entry represents open var data: AnyObject? + /// optional icon image + open var icon: NSUIImage? + public override required init() { super.init() @@ -35,7 +38,7 @@ open class ChartDataEntryBase: NSObject /// - parameter y: the y value (the actual value of the entry) /// - parameter data: Space for additional data this Entry represents. - + public init(y: Double, data: AnyObject?) { super.init() @@ -44,6 +47,30 @@ open class ChartDataEntryBase: NSObject self.data = data } + /// - parameter y: the y value (the actual value of the entry) + /// - parameter icon: icon image + + public init(y: Double, icon: NSUIImage?) + { + super.init() + + self.y = y + self.icon = icon + } + + /// - parameter y: the y value (the actual value of the entry) + /// - parameter icon: icon image + /// - parameter data: Space for additional data this Entry represents. + + public init(y: Double, icon: NSUIImage?, data: AnyObject?) + { + super.init() + + self.y = y + self.icon = icon + self.data = data + } + // MARK: NSObject open override func isEqual(_ object: Any?) -> Bool @@ -63,7 +90,7 @@ open class ChartDataEntryBase: NSObject return false } - if fabs((object! as AnyObject).y - y) > DBL_EPSILON + if fabs((object! as AnyObject).y - y) > Double.ulpOfOne { return false } @@ -96,7 +123,7 @@ public func ==(lhs: ChartDataEntryBase, rhs: ChartDataEntryBase) -> Bool return false } - if fabs(lhs.y - rhs.y) > DBL_EPSILON + if fabs(lhs.y - rhs.y) > Double.ulpOfOne { return false } diff --git a/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift index 7b38303e8c..eabbf37e9f 100644 --- a/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift @@ -58,16 +58,16 @@ open class ChartDataSet: ChartBaseDataSet internal var _values: [ChartDataEntry]! /// maximum y-value in the value array - internal var _yMax: Double = -DBL_MAX + internal var _yMax: Double = -Double.greatestFiniteMagnitude /// minimum y-value in the value array - internal var _yMin: Double = DBL_MAX + internal var _yMin: Double = Double.greatestFiniteMagnitude /// maximum x-value in the value array - internal var _xMax: Double = -DBL_MAX + internal var _xMax: Double = -Double.greatestFiniteMagnitude /// minimum x-value in the value array - internal var _xMin: Double = DBL_MAX + internal var _xMin: Double = Double.greatestFiniteMagnitude /// * /// - note: Calls `notifyDataSetChanged()` after setting a new value. @@ -98,10 +98,10 @@ open class ChartDataSet: ChartBaseDataSet return } - _yMax = -DBL_MAX - _yMin = DBL_MAX - _xMax = -DBL_MAX - _xMin = DBL_MAX + _yMax = -Double.greatestFiniteMagnitude + _yMin = Double.greatestFiniteMagnitude + _xMax = -Double.greatestFiniteMagnitude + _xMin = Double.greatestFiniteMagnitude for e in _values { @@ -116,8 +116,8 @@ open class ChartDataSet: ChartBaseDataSet return } - _yMax = -DBL_MAX - _yMin = DBL_MAX + _yMax = -Double.greatestFiniteMagnitude + _yMin = Double.greatestFiniteMagnitude let indexFrom = entryIndex(x: fromX, closestToY: Double.nan, rounding: .down) let indexTo = entryIndex(x: toX, closestToY: Double.nan, rounding: .up) @@ -184,6 +184,9 @@ open class ChartDataSet: ChartBaseDataSet /// if `i` is out of bounds, it may throw an out-of-bounds exception open override func entryForIndex(_ i: Int) -> ChartDataEntry? { + guard i >= 0 && i < _values.count else { + return nil + } return _values[i] } diff --git a/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift b/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift index 4d6b9453c2..d356d32994 100644 --- a/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift +++ b/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift @@ -98,15 +98,15 @@ open class CombinedChartData: BarLineScatterCandleBubbleChartData { _dataSets.removeAll() - _yMax = -DBL_MAX - _yMin = DBL_MAX - _xMax = -DBL_MAX - _xMin = DBL_MAX + _yMax = -Double.greatestFiniteMagnitude + _yMin = Double.greatestFiniteMagnitude + _xMax = -Double.greatestFiniteMagnitude + _xMin = Double.greatestFiniteMagnitude - _leftAxisMax = -DBL_MAX - _leftAxisMin = DBL_MAX - _rightAxisMax = -DBL_MAX - _rightAxisMin = DBL_MAX + _leftAxisMax = -Double.greatestFiniteMagnitude + _leftAxisMin = Double.greatestFiniteMagnitude + _rightAxisMax = -Double.greatestFiniteMagnitude + _rightAxisMin = Double.greatestFiniteMagnitude let allData = self.allData diff --git a/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift index 753196f584..4fe67697e9 100644 --- a/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift @@ -43,7 +43,7 @@ open class LineRadarChartDataSet: LineScatterCandleRadarChartDataSet, ILineRadar fileprivate var _lineWidth = CGFloat(1.0) - /// line width of the chart (min = 0.2, max = 10) + /// line width of the chart (min = 0.0, max = 10) /// /// **default**: 1 open var lineWidth: CGFloat @@ -54,9 +54,9 @@ open class LineRadarChartDataSet: LineScatterCandleRadarChartDataSet, ILineRadar } set { - if newValue < 0.2 + if newValue < 0.0 { - _lineWidth = 0.2 + _lineWidth = 0.0 } else if newValue > 10.0 { diff --git a/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift index 449e61c391..9040fc9f46 100644 --- a/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift @@ -19,34 +19,66 @@ open class PieChartDataEntry: ChartDataEntry super.init() } - /// - parameter value: The value on the y-axis. + /// - parameter value: The value on the y-axis /// - parameter label: The label for the x-axis - /// - parameter data: Spot for additional data this Entry represents. - public init(value: Double, label: String?, data: AnyObject?) + public convenience init(value: Double, label: String?) + { + self.init(value: value, label: label, icon: nil, data: nil) + } + + /// - parameter value: The value on the y-axis + /// - parameter label: The label for the x-axis + /// - parameter data: Spot for additional data this Entry represents + public convenience init(value: Double, label: String?, data: AnyObject?) + { + self.init(value: value, label: label, icon: nil, data: data) + } + + /// - parameter value: The value on the y-axis + /// - parameter label: The label for the x-axis + /// - parameter icon: icon image + public convenience init(value: Double, label: String?, icon: NSUIImage?) + { + self.init(value: value, label: label, icon: icon, data: nil) + } + + /// - parameter value: The value on the y-axis + /// - parameter label: The label for the x-axis + /// - parameter icon: icon image + /// - parameter data: Spot for additional data this Entry represents + public init(value: Double, label: String?, icon: NSUIImage?, data: AnyObject?) { - super.init(x: 0.0, y: value, data: data) + super.init(x: 0.0, y: value, icon: icon, data: data) self.label = label } - /// - parameter value: The value on the y-axis. - /// - parameter label: The label for the x-axis - public convenience init(value: Double, label: String?) + /// - parameter value: The value on the y-axis + public convenience init(value: Double) { - self.init(value: value, label: label, data: nil) + self.init(value: value, label: nil, icon: nil, data: nil) } - /// - parameter value: The value on the y-axis. - /// - parameter data: Spot for additional data this Entry represents. + /// - parameter value: The value on the y-axis + /// - parameter data: Spot for additional data this Entry represents public convenience init(value: Double, data: AnyObject?) { - self.init(value: value, label: nil, data: data) + self.init(value: value, label: nil, icon: nil, data: data) } - /// - parameter value: The value on the y-axis. - public convenience init(value: Double) + /// - parameter value: The value on the y-axis + /// - parameter icon: icon image + public convenience init(value: Double, icon: NSUIImage?) + { + self.init(value: value, label: nil, icon: icon, data: nil) + } + + /// - parameter value: The value on the y-axis + /// - parameter icon: icon image + /// - parameter data: Spot for additional data this Entry represents + public convenience init(value: Double, icon: NSUIImage?, data: AnyObject?) { - self.init(value: value, label: nil, data: nil) + self.init(value: value, label: nil, icon: icon, data: data) } // MARK: Data property accessors diff --git a/Source/Charts/Data/Interfaces/IChartDataSet.swift b/Source/Charts/Data/Interfaces/IChartDataSet.swift index 8b45bda329..5cdb4bc9ed 100644 --- a/Source/Charts/Data/Interfaces/IChartDataSet.swift +++ b/Source/Charts/Data/Interfaces/IChartDataSet.swift @@ -229,12 +229,29 @@ public protocol IChartDataSet /// [1, 3, 4, 2] will paint [- ---- - ---- ] var formLineDashLengths: [CGFloat]? { get } - /// Set this to true to draw y-values on the chart + /// Set this to true to draw y-values on the chart. + /// + /// - note: For bar and line charts: if `maxVisibleCount` is reached, no values will be drawn even if this is enabled. var drawValuesEnabled: Bool { get set } /// - returns: `true` if y-value drawing is enabled, `false` ifnot var isDrawValuesEnabled: Bool { get } + /// Set this to true to draw y-icons on the chart + /// + /// - note: For bar and line charts: if `maxVisibleCount` is reached, no icons will be drawn even if this is enabled. + var drawIconsEnabled: Bool { get set } + + /// Returns true if y-icon drawing is enabled, false if not + var isDrawIconsEnabled: Bool { get } + + /// Offset of icons drawn on the chart. + /// + /// For all charts except Pie and Radar it will be ordinary (x offset, y offset). + /// + /// For Pie and Radar chart it will be (y offset, distance from center offset); so if you want icon to be rendered under value, you should increase X component of CGPoint, and if you want icon to be rendered closet to center, you should decrease height component of CGPoint. + var iconsOffset: CGPoint { get set } + /// Set the visibility of this DataSet. If not visible, the DataSet will not be drawn to the chart upon refreshing it. var visible: Bool { get set } diff --git a/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift b/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift index db75d82639..5d054948af 100644 --- a/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift +++ b/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift @@ -30,7 +30,7 @@ public protocol ILineRadarChartDataSet: ILineScatterCandleRadarChartDataSet /// **default**: 0.33 var fillAlpha: CGFloat { get set } - /// line width of the chart (min = 0.2, max = 10) + /// line width of the chart (min = 0.0, max = 10) /// /// **default**: 1 var lineWidth: CGFloat { get set } diff --git a/Source/Charts/Highlight/RadarHighlighter.swift b/Source/Charts/Highlight/RadarHighlighter.swift index 78a5fec64a..8df2d3195a 100644 --- a/Source/Charts/Highlight/RadarHighlighter.swift +++ b/Source/Charts/Highlight/RadarHighlighter.swift @@ -25,7 +25,7 @@ open class RadarHighlighter: PieRadarHighlighter let distanceToCenter = Double(chart.distanceToCenter(x: x, y: y) / chart.factor) var closest: Highlight? = nil - var distance = DBL_MAX + var distance = Double.greatestFiniteMagnitude for high in highlights { diff --git a/Source/Charts/Renderers/BarChartRenderer.swift b/Source/Charts/Renderers/BarChartRenderer.swift index b5a7c88a47..d79d1873cc 100644 --- a/Source/Charts/Renderers/BarChartRenderer.swift +++ b/Source/Charts/Renderers/BarChartRenderer.swift @@ -132,13 +132,18 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer var negY = -e.negativeSum var yStart = 0.0 - // fill the stack for k in 0 ..< vals!.count { let value = vals![k] - if value >= 0.0 + if value == 0.0 && (posY == 0.0 || negY == 0.0) + { + // Take care of the situation of a 0.0 value, which overlaps a non-zero bar + y = value + yStart = y + } + else if value >= 0.0 { y = posY yStart = posY + value @@ -416,6 +421,8 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer let trans = dataProvider.getTransformer(forAxis: dataSet.axisDependency) let phaseY = animator.phaseY + + let iconsOffset = dataSet.iconsOffset // if only single values are drawn (sum) if !dataSet.isStacked @@ -441,20 +448,41 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer let val = e.y - drawValue( - context: context, - value: formatter.stringForValue( - val, - entry: e, - dataSetIndex: dataSetIndex, - viewPortHandler: viewPortHandler), - xPos: x, - yPos: val >= 0.0 + if dataSet.isDrawValuesEnabled + { + drawValue( + context: context, + value: formatter.stringForValue( + val, + entry: e, + dataSetIndex: dataSetIndex, + viewPortHandler: viewPortHandler), + xPos: x, + yPos: val >= 0.0 + ? (rect.origin.y + posOffset) + : (rect.origin.y + rect.size.height + negOffset), + font: valueFont, + align: .center, + color: dataSet.valueTextColorAt(j)) + } + + if let icon = e.icon, dataSet.isDrawIconsEnabled + { + var px = x + var py = val >= 0.0 ? (rect.origin.y + posOffset) - : (rect.origin.y + rect.size.height + negOffset), - font: valueFont, - align: .center, - color: dataSet.valueTextColorAt(j)) + : (rect.origin.y + rect.size.height + negOffset) + + px += iconsOffset.x + py += iconsOffset.y + + ChartUtils.drawImage( + context: context, + image: icon, + x: px, + y: py, + size: icon.size) + } } } else @@ -487,19 +515,39 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer continue } - drawValue( - context: context, - value: formatter.stringForValue( - e.y, - entry: e, - dataSetIndex: dataSetIndex, - viewPortHandler: viewPortHandler), - xPos: x, - yPos: rect.origin.y + - (e.y >= 0 ? posOffset : negOffset), - font: valueFont, - align: .center, - color: dataSet.valueTextColorAt(index)) + if dataSet.isDrawValuesEnabled + { + drawValue( + context: context, + value: formatter.stringForValue( + e.y, + entry: e, + dataSetIndex: dataSetIndex, + viewPortHandler: viewPortHandler), + xPos: x, + yPos: rect.origin.y + + (e.y >= 0 ? posOffset : negOffset), + font: valueFont, + align: .center, + color: dataSet.valueTextColorAt(index)) + } + + if let icon = e.icon, dataSet.isDrawIconsEnabled + { + var px = x + var py = rect.origin.y + + (e.y >= 0 ? posOffset : negOffset) + + px += iconsOffset.x + py += iconsOffset.y + + ChartUtils.drawImage( + context: context, + image: icon, + x: px, + y: py, + size: icon.size) + } } else { @@ -516,7 +564,12 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer let value = vals[k] var y: Double - if value >= 0.0 + if value == 0.0 && (posY == 0.0 || negY == 0.0) + { + // Take care of the situation of a 0.0 value, which overlaps a non-zero bar + y = value + } + else if value >= 0.0 { posY += value y = posY @@ -534,7 +587,9 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer for k in 0 ..< transformed.count { - let y = transformed[k].y + (vals[k] >= 0 ? posOffset : negOffset) + let val = vals[k] + let drawBelow = (val == 0.0 && negY == 0.0 && posY > 0.0) || val < 0.0 + let y = transformed[k].y + (drawBelow ? negOffset : posOffset) if !viewPortHandler.isInBoundsRight(x) { @@ -546,18 +601,31 @@ open class BarChartRenderer: BarLineScatterCandleBubbleRenderer continue } - drawValue( - context: context, - value: formatter.stringForValue( - vals[k], - entry: e, - dataSetIndex: dataSetIndex, - viewPortHandler: viewPortHandler), - xPos: x, - yPos: y, - font: valueFont, - align: .center, - color: dataSet.valueTextColorAt(index)) + if dataSet.isDrawValuesEnabled + { + drawValue( + context: context, + value: formatter.stringForValue( + vals[k], + entry: e, + dataSetIndex: dataSetIndex, + viewPortHandler: viewPortHandler), + xPos: x, + yPos: y, + font: valueFont, + align: .center, + color: dataSet.valueTextColorAt(index)) + } + + if let icon = e.icon, dataSet.isDrawIconsEnabled + { + ChartUtils.drawImage( + context: context, + image: icon, + x: x + iconsOffset.x, + y: y + iconsOffset.y, + size: icon.size) + } } } diff --git a/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift b/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift index a3e8f8b54b..a70111771a 100644 --- a/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift +++ b/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift @@ -49,7 +49,7 @@ open class BarLineScatterCandleBubbleRenderer: DataRenderer /// - returns: `true` if the DataSet values should be drawn, `false` if not. internal func shouldDrawValues(forDataSet set: IChartDataSet) -> Bool { - return set.isVisible && set.isDrawValuesEnabled + return set.isVisible && (set.isDrawValuesEnabled || set.isDrawIconsEnabled) } /// Class representing the bounds of the current viewport in terms of indices in the values array of a DataSet. diff --git a/Source/Charts/Renderers/BubbleChartRenderer.swift b/Source/Charts/Renderers/BubbleChartRenderer.swift index 7bd2ead402..7950422a4f 100644 --- a/Source/Charts/Renderers/BubbleChartRenderer.swift +++ b/Source/Charts/Renderers/BubbleChartRenderer.swift @@ -172,6 +172,8 @@ open class BubbleChartRenderer: BarLineScatterCandleBubbleRenderer let trans = dataProvider.getTransformer(forAxis: dataSet.axisDependency) let valueToPixelMatrix = trans.valueToPixelMatrix + let iconsOffset = dataSet.iconsOffset + for j in stride(from: _xBounds.min, through: _xBounds.range + _xBounds.min, by: 1) { guard let e = dataSet.entryForIndex(j) as? BubbleChartDataEntry else { break } @@ -202,14 +204,27 @@ open class BubbleChartRenderer: BarLineScatterCandleBubbleRenderer let valueFont = dataSet.valueFont let lineHeight = valueFont.lineHeight - ChartUtils.drawText( - context: context, - text: text, - point: CGPoint( - x: pt.x, - y: pt.y - (0.5 * lineHeight)), - align: .center, - attributes: [NSFontAttributeName: valueFont, NSForegroundColorAttributeName: valueTextColor]) + if dataSet.isDrawValuesEnabled + { + ChartUtils.drawText( + context: context, + text: text, + point: CGPoint( + x: pt.x, + y: pt.y - (0.5 * lineHeight)), + align: .center, + attributes: [NSFontAttributeName: valueFont, NSForegroundColorAttributeName: valueTextColor]) + } + + if let icon = e.icon, dataSet.isDrawIconsEnabled + { + ChartUtils.drawImage(context: context, + image: icon, + x: pt.x + iconsOffset.x, + y: pt.y + iconsOffset.y, + size: icon.size) + } + } } } diff --git a/Source/Charts/Renderers/CandleStickChartRenderer.swift b/Source/Charts/Renderers/CandleStickChartRenderer.swift index 8dbaaecc24..3ec986cdf6 100644 --- a/Source/Charts/Renderers/CandleStickChartRenderer.swift +++ b/Source/Charts/Renderers/CandleStickChartRenderer.swift @@ -270,6 +270,8 @@ open class CandleStickChartRenderer: LineScatterCandleRadarRenderer let trans = dataProvider.getTransformer(forAxis: dataSet.axisDependency) let valueToPixelMatrix = trans.valueToPixelMatrix + let iconsOffset = dataSet.iconsOffset + _xBounds.set(chart: dataProvider, dataSet: dataSet, animator: animator) let lineHeight = valueFont.lineHeight @@ -293,18 +295,30 @@ open class CandleStickChartRenderer: LineScatterCandleRadarRenderer continue } - ChartUtils.drawText( - context: context, - text: formatter.stringForValue( - e.high, - entry: e, - dataSetIndex: i, - viewPortHandler: viewPortHandler), - point: CGPoint( - x: pt.x, - y: pt.y - yOffset), - align: .center, - attributes: [NSFontAttributeName: valueFont, NSForegroundColorAttributeName: dataSet.valueTextColorAt(j)]) + if dataSet.isDrawValuesEnabled + { + ChartUtils.drawText( + context: context, + text: formatter.stringForValue( + e.high, + entry: e, + dataSetIndex: i, + viewPortHandler: viewPortHandler), + point: CGPoint( + x: pt.x, + y: pt.y - yOffset), + align: .center, + attributes: [NSFontAttributeName: valueFont, NSForegroundColorAttributeName: dataSet.valueTextColorAt(j)]) + } + + if let icon = e.icon, dataSet.isDrawIconsEnabled + { + ChartUtils.drawImage(context: context, + image: icon, + x: pt.x + iconsOffset.x, + y: pt.y + iconsOffset.y, + size: icon.size) + } } } } diff --git a/Source/Charts/Renderers/HorizontalBarChartRenderer.swift b/Source/Charts/Renderers/HorizontalBarChartRenderer.swift index ee938bd3a1..7d2b03f14e 100644 --- a/Source/Charts/Renderers/HorizontalBarChartRenderer.swift +++ b/Source/Charts/Renderers/HorizontalBarChartRenderer.swift @@ -134,7 +134,13 @@ open class HorizontalBarChartRenderer: BarChartRenderer { let value = vals![k] - if value >= 0.0 + if value == 0.0 && (posY == 0.0 || negY == 0.0) + { + // Take care of the situation of a 0.0 value, which overlaps a non-zero bar + y = value + yStart = y + } + else if value >= 0.0 { y = posY yStart = posY + value @@ -321,7 +327,7 @@ open class HorizontalBarChartRenderer: BarChartRenderer { guard let dataSet = dataSets[dataSetIndex] as? IBarChartDataSet else { continue } - if !shouldDrawValues(forDataSet: dataSet) + if !shouldDrawValues(forDataSet: dataSet) || !(dataSet.isDrawIconsEnabled && dataSet.isVisible) { continue } @@ -337,6 +343,8 @@ open class HorizontalBarChartRenderer: BarChartRenderer let phaseY = animator.phaseY + let iconsOffset = dataSet.iconsOffset + let buffer = _buffers[dataSetIndex] // if only single values are drawn (sum) @@ -383,15 +391,35 @@ open class HorizontalBarChartRenderer: BarChartRenderer negOffset = -negOffset - valueTextWidth } - drawValue( - context: context, - value: valueText, - xPos: (rect.origin.x + rect.size.width) - + (val >= 0.0 ? posOffset : negOffset), - yPos: y + yOffset, - font: valueFont, - align: textAlign, - color: dataSet.valueTextColorAt(j)) + if dataSet.isDrawValuesEnabled + { + drawValue( + context: context, + value: valueText, + xPos: (rect.origin.x + rect.size.width) + + (val >= 0.0 ? posOffset : negOffset), + yPos: y + yOffset, + font: valueFont, + align: textAlign, + color: dataSet.valueTextColorAt(j)) + } + + if let icon = e.icon, dataSet.isDrawIconsEnabled + { + var px = (rect.origin.x + rect.size.width) + + (val >= 0.0 ? posOffset : negOffset) + var py = y + + px += iconsOffset.x + py += iconsOffset.y + + ChartUtils.drawImage( + context: context, + image: icon, + x: px, + y: py, + size: icon.size) + } } } else @@ -444,15 +472,35 @@ open class HorizontalBarChartRenderer: BarChartRenderer negOffset = -negOffset - valueTextWidth } - drawValue( - context: context, - value: valueText, - xPos: (rect.origin.x + rect.size.width) - + (val >= 0.0 ? posOffset : negOffset), - yPos: rect.origin.y + yOffset, - font: valueFont, - align: textAlign, - color: dataSet.valueTextColorAt(index)) + if dataSet.isDrawValuesEnabled + { + drawValue( + context: context, + value: valueText, + xPos: (rect.origin.x + rect.size.width) + + (val >= 0.0 ? posOffset : negOffset), + yPos: rect.origin.y + yOffset, + font: valueFont, + align: textAlign, + color: dataSet.valueTextColorAt(index)) + } + + if let icon = e.icon, dataSet.isDrawIconsEnabled + { + var px = (rect.origin.x + rect.size.width) + + (val >= 0.0 ? posOffset : negOffset) + var py = rect.origin.y + + px += iconsOffset.x + py += iconsOffset.y + + ChartUtils.drawImage( + context: context, + image: icon, + x: px, + y: py, + size: icon.size) + } } else { @@ -467,7 +515,12 @@ open class HorizontalBarChartRenderer: BarChartRenderer let value = vals[k] var y: Double - if value >= 0.0 + if value == 0.0 && (posY == 0.0 || negY == 0.0) + { + // Take care of the situation of a 0.0 value, which overlaps a non-zero bar + y = value + } + else if value >= 0.0 { posY += value y = posY @@ -503,7 +556,9 @@ open class HorizontalBarChartRenderer: BarChartRenderer negOffset = -negOffset - valueTextWidth } - let x = transformed[k].x + (val >= 0 ? posOffset : negOffset) + let drawBelow = (val == 0.0 && negY == 0.0 && posY > 0.0) || val < 0.0 + + let x = transformed[k].x + (drawBelow ? negOffset : posOffset) let y = rect.origin.y + rect.size.height / 2.0 if (!viewPortHandler.isInBoundsTop(y)) @@ -521,13 +576,26 @@ open class HorizontalBarChartRenderer: BarChartRenderer continue } - drawValue(context: context, - value: valueText, - xPos: x, - yPos: y + yOffset, - font: valueFont, - align: textAlign, - color: dataSet.valueTextColorAt(index)) + if dataSet.isDrawValuesEnabled + { + drawValue(context: context, + value: valueText, + xPos: x, + yPos: y + yOffset, + font: valueFont, + align: textAlign, + color: dataSet.valueTextColorAt(index)) + } + + if let icon = e.icon, dataSet.isDrawIconsEnabled + { + ChartUtils.drawImage( + context: context, + image: icon, + x: x + iconsOffset.x, + y: y + iconsOffset.y, + size: icon.size) + } } } diff --git a/Source/Charts/Renderers/LineChartRenderer.swift b/Source/Charts/Renderers/LineChartRenderer.swift index 124e09787d..85a6ac72d5 100644 --- a/Source/Charts/Renderers/LineChartRenderer.swift +++ b/Source/Charts/Renderers/LineChartRenderer.swift @@ -538,6 +538,8 @@ open class LineChartRenderer: LineRadarRenderer let trans = dataProvider.getTransformer(forAxis: dataSet.axisDependency) let valueToPixelMatrix = trans.valueToPixelMatrix + let iconsOffset = dataSet.iconsOffset + // make sure the values do not interfear with the circles var valOffset = Int(dataSet.circleRadius * 1.75) @@ -566,18 +568,29 @@ open class LineChartRenderer: LineRadarRenderer continue } - ChartUtils.drawText( - context: context, - text: formatter.stringForValue( - e.y, - entry: e, - dataSetIndex: i, - viewPortHandler: viewPortHandler), - point: CGPoint( - x: pt.x, - y: pt.y - CGFloat(valOffset) - valueFont.lineHeight), - align: .center, - attributes: [NSFontAttributeName: valueFont, NSForegroundColorAttributeName: dataSet.valueTextColorAt(j)]) + if dataSet.isDrawValuesEnabled { + ChartUtils.drawText( + context: context, + text: formatter.stringForValue( + e.y, + entry: e, + dataSetIndex: i, + viewPortHandler: viewPortHandler), + point: CGPoint( + x: pt.x, + y: pt.y - CGFloat(valOffset) - valueFont.lineHeight), + align: .center, + attributes: [NSFontAttributeName: valueFont, NSForegroundColorAttributeName: dataSet.valueTextColorAt(j)]) + } + + if let icon = e.icon, dataSet.isDrawIconsEnabled + { + ChartUtils.drawImage(context: context, + image: icon, + x: pt.x + iconsOffset.x, + y: pt.y + iconsOffset.y, + size: icon.size) + } } } } diff --git a/Source/Charts/Renderers/PieChartRenderer.swift b/Source/Charts/Renderers/PieChartRenderer.swift index 60810ef5c1..1127fe5357 100755 --- a/Source/Charts/Renderers/PieChartRenderer.swift +++ b/Source/Charts/Renderers/PieChartRenderer.swift @@ -130,7 +130,7 @@ open class PieChartRenderer: DataRenderer for j in 0 ..< entryCount { guard let e = dataSet.entryForIndex(j) else { continue } - if ((abs(e.y) > DBL_EPSILON)) + if ((abs(e.y) > Double.ulpOfOne)) { visibleAngleCount += 1 } @@ -148,7 +148,7 @@ open class PieChartRenderer: DataRenderer guard let e = dataSet.entryForIndex(j) else { continue } // draw only if the value is greater than zero - if (abs(e.y) > DBL_EPSILON) + if (abs(e.y) > Double.ulpOfOne) { if !chart.needsHighlight(index: j) { @@ -307,11 +307,13 @@ open class PieChartRenderer: DataRenderer let drawValues = dataSet.isDrawValuesEnabled - if !drawValues && !drawEntryLabels + if !drawValues && !drawEntryLabels && !dataSet.isDrawIconsEnabled { continue } + let iconsOffset = dataSet.iconsOffset + let xValuePosition = dataSet.xValuePosition let yValuePosition = dataSet.yValuePosition @@ -528,6 +530,21 @@ open class PieChartRenderer: DataRenderer } } + if let icon = e.icon, dataSet.isDrawIconsEnabled + { + // calculate the icon's position + + let x = (labelRadius + iconsOffset.y) * sliceXBase + center.x + var y = (labelRadius + iconsOffset.y) * sliceYBase + center.y + y += iconsOffset.x + + ChartUtils.drawImage(context: context, + image: icon, + x: x, + y: y, + size: icon.size) + } + xIndex += 1 } } @@ -691,7 +708,7 @@ open class PieChartRenderer: DataRenderer for j in 0 ..< entryCount { guard let e = set.entryForIndex(j) else { continue } - if ((abs(e.y) > DBL_EPSILON)) + if ((abs(e.y) > Double.ulpOfOne)) { visibleAngleCount += 1 } diff --git a/Source/Charts/Renderers/RadarChartRenderer.swift b/Source/Charts/Renderers/RadarChartRenderer.swift index 475e60e708..96dfb16412 100644 --- a/Source/Charts/Renderers/RadarChartRenderer.swift +++ b/Source/Charts/Renderers/RadarChartRenderer.swift @@ -168,6 +168,8 @@ open class RadarChartRenderer: LineRadarRenderer let entryCount = dataSet.entryCount + let iconsOffset = dataSet.iconsOffset + for j in 0 ..< entryCount { guard let e = dataSet.entryForIndex(j) else { continue } @@ -181,18 +183,36 @@ open class RadarChartRenderer: LineRadarRenderer guard let formatter = dataSet.valueFormatter else { continue } - ChartUtils.drawText( - context: context, - text: formatter.stringForValue( - e.y, - entry: e, - dataSetIndex: i, - viewPortHandler: viewPortHandler), - point: CGPoint(x: p.x, y: p.y - yoffset - valueFont.lineHeight), - align: .center, - attributes: [NSFontAttributeName: valueFont, - NSForegroundColorAttributeName: dataSet.valueTextColorAt(j)] - ) + if dataSet.isDrawValuesEnabled + { + ChartUtils.drawText( + context: context, + text: formatter.stringForValue( + e.y, + entry: e, + dataSetIndex: i, + viewPortHandler: viewPortHandler), + point: CGPoint(x: p.x, y: p.y - yoffset - valueFont.lineHeight), + align: .center, + attributes: [NSFontAttributeName: valueFont, + NSForegroundColorAttributeName: dataSet.valueTextColorAt(j)] + ) + } + + if let icon = e.icon, dataSet.isDrawIconsEnabled + { + var pIcon = ChartUtils.getPosition( + center: center, + dist: CGFloat(e.y) * factor * CGFloat(phaseY) + iconsOffset.y, + angle: sliceangle * CGFloat(j) * CGFloat(phaseX) + chart.rotationAngle) + pIcon.y += iconsOffset.x + + ChartUtils.drawImage(context: context, + image: icon, + x: pIcon.x, + y: pIcon.y, + size: icon.size) + } } } } diff --git a/Source/Charts/Renderers/ScatterChartRenderer.swift b/Source/Charts/Renderers/ScatterChartRenderer.swift index 8d0d57ab1b..4c6a0be213 100644 --- a/Source/Charts/Renderers/ScatterChartRenderer.swift +++ b/Source/Charts/Renderers/ScatterChartRenderer.swift @@ -136,6 +136,8 @@ open class ScatterChartRenderer: LineScatterCandleRadarRenderer let trans = dataProvider.getTransformer(forAxis: dataSet.axisDependency) let valueToPixelMatrix = trans.valueToPixelMatrix + let iconsOffset = dataSet.iconsOffset + let shapeSize = dataSet.scatterShapeSize let lineHeight = valueFont.lineHeight @@ -167,15 +169,27 @@ open class ScatterChartRenderer: LineScatterCandleRadarRenderer dataSetIndex: i, viewPortHandler: viewPortHandler) - ChartUtils.drawText( - context: context, - text: text, - point: CGPoint( - x: pt.x, - y: pt.y - shapeSize - lineHeight), - align: .center, - attributes: [NSFontAttributeName: valueFont, NSForegroundColorAttributeName: dataSet.valueTextColorAt(j)] - ) + if dataSet.isDrawValuesEnabled + { + ChartUtils.drawText( + context: context, + text: text, + point: CGPoint( + x: pt.x, + y: pt.y - shapeSize - lineHeight), + align: .center, + attributes: [NSFontAttributeName: valueFont, NSForegroundColorAttributeName: dataSet.valueTextColorAt(j)] + ) + } + + if let icon = e.icon, dataSet.isDrawIconsEnabled + { + ChartUtils.drawImage(context: context, + image: icon, + x: pt.x + iconsOffset.x, + y: pt.y + iconsOffset.y, + size: icon.size) + } } } } diff --git a/Source/Charts/Renderers/YAxisRenderer.swift b/Source/Charts/Renderers/YAxisRenderer.swift index 185b170049..fd9604e868 100644 --- a/Source/Charts/Renderers/YAxisRenderer.swift +++ b/Source/Charts/Renderers/YAxisRenderer.swift @@ -141,15 +141,13 @@ open class YAxisRenderer: AxisRendererBase let labelFont = yAxis.labelFont let labelTextColor = yAxis.labelTextColor - for i in 0 ..< yAxis.entryCount + let from = yAxis.isDrawBottomYLabelEntryEnabled ? 0 : 1 + let to = yAxis.isDrawTopYLabelEntryEnabled ? yAxis.entryCount : (yAxis.entryCount - 1) + + for i in stride(from: from, to: to, by: 1) { let text = yAxis.getFormattedLabel(i) - if !yAxis.isDrawTopYLabelEntryEnabled && i >= yAxis.entryCount - 1 - { - break - } - ChartUtils.drawText( context: context, text: text, diff --git a/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift b/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift index c17829882e..621d6dd6ed 100644 --- a/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift +++ b/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift @@ -165,15 +165,13 @@ open class YAxisRendererHorizontalBarChart: YAxisRenderer let labelFont = yAxis.labelFont let labelTextColor = yAxis.labelTextColor - for i in 0 ..< yAxis.entryCount + let from = yAxis.isDrawBottomYLabelEntryEnabled ? 0 : 1 + let to = yAxis.isDrawTopYLabelEntryEnabled ? yAxis.entryCount : (yAxis.entryCount - 1) + + for i in stride(from: from, to: to, by: 1) { let text = yAxis.getFormattedLabel(i) - if !yAxis.isDrawTopYLabelEntryEnabled && i >= yAxis.entryCount - 1 - { - return - } - ChartUtils.drawText( context: context, text: text, diff --git a/Source/Charts/Renderers/YAxisRendererRadarChart.swift b/Source/Charts/Renderers/YAxisRendererRadarChart.swift index 066f54f95b..bd04c08470 100644 --- a/Source/Charts/Renderers/YAxisRendererRadarChart.swift +++ b/Source/Charts/Renderers/YAxisRendererRadarChart.swift @@ -177,17 +177,13 @@ open class YAxisRendererRadarChart: YAxisRenderer let center = chart.centerOffsets let factor = chart.factor - let labelCount = yAxis.entryCount - let labelLineHeight = yAxis.labelFont.lineHeight - for j in 0 ..< labelCount + let from = yAxis.isDrawBottomYLabelEntryEnabled ? 0 : 1 + let to = yAxis.isDrawTopYLabelEntryEnabled ? yAxis.entryCount : (yAxis.entryCount - 1) + + for j in stride(from: from, to: to, by: 1) { - if j == labelCount - 1 && yAxis.isDrawTopYLabelEntryEnabled == false - { - break - } - let r = CGFloat(yAxis.entries[j] - yAxis._axisMinimum) * factor let p = ChartUtils.getPosition(center: center, dist: r, angle: chart.rotationAngle) diff --git a/Source/Charts/Utils/ChartUtils.swift b/Source/Charts/Utils/ChartUtils.swift index 17b85e167c..2228065f2c 100755 --- a/Source/Charts/Utils/ChartUtils.swift +++ b/Source/Charts/Utils/ChartUtils.swift @@ -22,10 +22,10 @@ open class ChartUtils internal struct Math { - internal static let FDEG2RAD = CGFloat(M_PI / 180.0) - internal static let FRAD2DEG = CGFloat(180.0 / M_PI) - internal static let DEG2RAD = M_PI / 180.0 - internal static let RAD2DEG = 180.0 / M_PI + internal static let FDEG2RAD = CGFloat(Double.pi / 180.0) + internal static let FRAD2DEG = CGFloat(180.0 / Double.pi) + internal static let DEG2RAD = Double.pi / 180.0 + internal static let RAD2DEG = 180.0 / Double.pi } internal class func roundToNextSignificant(number: Double) -> Double @@ -67,7 +67,7 @@ open class ChartUtils } else { - return number + DBL_EPSILON + return number + Double.ulpOfOne } } @@ -80,6 +80,49 @@ open class ChartUtils ) } + open class func drawImage( + context: CGContext, + image: NSUIImage, + x: CGFloat, + y: CGFloat, + size: CGSize) + { + var drawOffset = CGPoint() + drawOffset.x = x - (size.width / 2) + drawOffset.y = y - (size.height / 2) + + NSUIGraphicsPushContext(context) + + if image.size.width != size.width && image.size.height != size.height + { + let key = "resized_\(size.width)_\(size.height)" + + // Try to take scaled image from cache of this image + var scaledImage = objc_getAssociatedObject(image, key) as? NSUIImage + if scaledImage == nil + { + // Scale the image + NSUIGraphicsBeginImageContextWithOptions(size, false, 0.0) + + image.draw(in: CGRect(origin: CGPoint(x: 0, y: 0), size: size)) + + scaledImage = NSUIGraphicsGetImageFromCurrentImageContext() + NSUIGraphicsEndImageContext() + + // Put the scaled image in a cache owned by the original image + objc_setAssociatedObject(image, key, scaledImage, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + + scaledImage?.draw(in: CGRect(origin: drawOffset, size: size)) + } + else + { + image.draw(in: CGRect(origin: drawOffset, size: size)) + } + + NSUIGraphicsPopContext() + } + open class func drawText(context: CGContext, text: String, point: CGPoint, align: NSTextAlignment, attributes: [String : AnyObject]?) { var point = point diff --git a/Source/Charts/Utils/Platform.swift b/Source/Charts/Utils/Platform.swift index c85184cc77..76a82ef24a 100644 --- a/Source/Charts/Utils/Platform.swift +++ b/Source/Charts/Utils/Platform.swift @@ -445,7 +445,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple super.touchesCancelled(with: event!) } - var backgroundColor: NSUIColor? + open var backgroundColor: NSUIColor? { get { @@ -455,6 +455,7 @@ types are aliased to either their UI* implementation (on iOS) or their NS* imple } set { + self.wantsLayer = true self.layer?.backgroundColor = newValue == nil ? nil : newValue!.cgColor } } diff --git a/Source/Charts/Utils/ViewPortHandler.swift b/Source/Charts/Utils/ViewPortHandler.swift index 07cc346019..d57c98f00b 100755 --- a/Source/Charts/Utils/ViewPortHandler.swift +++ b/Source/Charts/Utils/ViewPortHandler.swift @@ -199,6 +199,12 @@ open class ViewPortHandler: NSObject return zoom(scaleX: 0.7, scaleY: 0.7, x: x, y: y) } + /// Zooms out to original size. + open func resetZoom() -> CGAffineTransform + { + return zoom(scaleX: 1.0, scaleY: 1.0, x: 0.0, y: 0.0) + } + /// Sets the scale factor to the specified values. open func setZoom(scaleX: CGFloat, scaleY: CGFloat) -> CGAffineTransform { diff --git a/Source/ChartsRealm/Data/RealmBarDataSet.swift b/Source/ChartsRealm/Data/RealmBarDataSet.swift deleted file mode 100644 index 9c2810170a..0000000000 --- a/Source/ChartsRealm/Data/RealmBarDataSet.swift +++ /dev/null @@ -1,236 +0,0 @@ -// -// RealmBarDataSet.swift -// Charts -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -import Foundation -import CoreGraphics -#if NEEDS_CHARTS -import Charts -#endif -import Realm -import Realm.Dynamic - -open class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDataSet -{ - open override func initialize() - { - self.highlightColor = NSUIColor.black - } - - public required init() - { - super.init() - } - - public override init(results: RLMResults?, xValueField: String?, yValueField: String, label: String?) - { - super.init(results: results, xValueField: xValueField, yValueField: yValueField, label: label) - } - - public init(results: RLMResults?, xValueField: String?, yValueField: String, stackValueField: String, label: String?) - { - _stackValueField = stackValueField - - super.init(results: results, xValueField: xValueField, yValueField: yValueField, label: label) - } - - public convenience init(results: RLMResults?, xValueField: String?, yValueField: String, stackValueField: String) - { - self.init(results: results, xValueField: xValueField, yValueField: yValueField, stackValueField: stackValueField, label: "DataSet") - } - - public convenience init(results: RLMResults?, yValueField: String, stackValueField: String, label: String) - { - self.init(results: results, xValueField: nil, yValueField: yValueField, stackValueField: stackValueField, label: label) - } - - public convenience init(results: RLMResults?, yValueField: String, stackValueField: String) - { - self.init(results: results, xValueField: nil, yValueField: yValueField, stackValueField: stackValueField) - } - - public override init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String?, yValueField: String, label: String?) - { - super.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: xValueField, yValueField: yValueField, label: label) - } - - public init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String?, yValueField: String, stackValueField: String, label: String?) - { - _stackValueField = stackValueField - - super.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: xValueField, yValueField: yValueField, label: label) - } - - public convenience init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String?, yValueField: String, stackValueField: String) - { - self.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: nil, yValueField: yValueField, stackValueField: stackValueField) - } - - public convenience init(realm: RLMRealm?, modelName: String, resultsWhere: String, yValueField: String, stackValueField: String, label: String?) - { - self.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: nil, yValueField: yValueField, stackValueField: stackValueField, label: label) - } - - public convenience init(realm: RLMRealm?, modelName: String, resultsWhere: String, yValueField: String, stackValueField: String) - { - self.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: nil, yValueField: yValueField, stackValueField: stackValueField, label: nil) - } - - open override func notifyDataSetChanged() - { - super.notifyDataSetChanged() - self.calcStackSize(entries: _cache as! [BarChartDataEntry]) - } - - // MARK: - Data functions and accessors - - internal var _stackValueField: String? - - /// the maximum number of bars that are stacked upon each other, this value - /// is calculated from the Entries that are added to the DataSet - fileprivate var _stackSize = 1 - - internal override func buildEntryFromResultObject(_ object: RLMObject, x: Double) -> ChartDataEntry - { - let value = object[_yValueField!] - let entry: BarChartDataEntry - - if value is RLMArray - { - var values = [Double]() - let iterator = NSFastEnumerationIterator(value as! RLMArray) - while let val = iterator.next() - { - values.append((val as! RLMObject)[_stackValueField!] as! Double) - } - entry = BarChartDataEntry(x: _xValueField == nil ? x : object[_xValueField!] as! Double, yValues: values) - } - else - { - entry = BarChartDataEntry(x: _xValueField == nil ? x : object[_xValueField!] as! Double, y: value as! Double) - } - - return entry - } - - /// calculates the maximum stacksize that occurs in the Entries array of this DataSet - fileprivate func calcStackSize(entries: [BarChartDataEntry]) - { - for i in 0 ..< entries.count - { - if let vals = entries[i].yValues - { - if vals.count > _stackSize - { - _stackSize = vals.count - } - } - } - } - - open override func calcMinMax() - { - if _cache.count == 0 - { - return - } - - _yMax = -DBL_MAX - _yMin = DBL_MAX - _xMax = -DBL_MAX - _xMin = DBL_MAX - - for e in _cache as! [BarChartDataEntry] - { - if !e.y.isNaN - { - if e.yValues == nil - { - if e.y < _yMin - { - _yMin = e.y - } - - if e.y > _yMax - { - _yMax = e.y - } - } - else - { - if -e.negativeSum < _yMin - { - _yMin = -e.negativeSum - } - - if e.positiveSum > _yMax - { - _yMax = e.positiveSum - } - } - - if e.x < _xMin - { - _xMin = e.x - } - if e.x > _xMax - { - _xMax = e.x - } - } - } - } - - /// - returns: The maximum number of bars that can be stacked upon another in this DataSet. - open var stackSize: Int - { - return _stackSize - } - - /// - returns: `true` if this DataSet is stacked (stacksize > 1) or not. - open var isStacked: Bool - { - return _stackSize > 1 ? true : false - } - - /// array of labels used to describe the different values of the stacked bars - open var stackLabels: [String] = ["Stack"] - - // MARK: - Styling functions and accessors - - /// the color used for drawing the bar-shadows. The bar shadows is a surface behind the bar that indicates the maximum value - open var barShadowColor = NSUIColor(red: 215.0/255.0, green: 215.0/255.0, blue: 215.0/255.0, alpha: 1.0) - - /// the width used for drawing borders around the bars. If borderWidth == 0, no border will be drawn. - open var barBorderWidth : CGFloat = 0.0 - - /// the color drawing borders around the bars. - open var barBorderColor = NSUIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0) - - #if !os(OSX) - /// the option rounding bar corners - open var barRoundingCorners: UIRectCorner = .allCorners - #endif - - /// the alpha value (transparency) that is used for drawing the highlight indicator bar. min = 0.0 (fully transparent), max = 1.0 (fully opaque) - open var highlightAlpha = CGFloat(120.0 / 255.0) - - // MARK: - NSCopying - - open override func copyWithZone(_ zone: NSZone?) -> AnyObject - { - let copy = super.copyWithZone(zone) as! RealmBarDataSet - copy._stackSize = _stackSize - copy.stackLabels = stackLabels - copy.barShadowColor = barShadowColor - copy.highlightAlpha = highlightAlpha - return copy - } -} diff --git a/Source/ChartsRealm/Data/RealmBarLineScatterCandleBubbleDataSet.swift b/Source/ChartsRealm/Data/RealmBarLineScatterCandleBubbleDataSet.swift deleted file mode 100644 index a8ddd01772..0000000000 --- a/Source/ChartsRealm/Data/RealmBarLineScatterCandleBubbleDataSet.swift +++ /dev/null @@ -1,41 +0,0 @@ -// -// RealmBarLineScatterCandleBubbleDataSet.swift -// Charts -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -import Foundation -#if NEEDS_CHARTS -import Charts -#endif -import Realm -import Realm.Dynamic - -open class RealmBarLineScatterCandleBubbleDataSet: RealmBaseDataSet, IBarLineScatterCandleBubbleChartDataSet -{ - // MARK: - Data functions and accessors - - // MARK: - Styling functions and accessors - - open var highlightColor = NSUIColor(red: 255.0/255.0, green: 187.0/255.0, blue: 115.0/255.0, alpha: 1.0) - open var highlightLineWidth = CGFloat(0.5) - open var highlightLineDashPhase = CGFloat(0.0) - open var highlightLineDashLengths: [CGFloat]? - - // MARK: - NSCopying - - open override func copyWithZone(_ zone: NSZone?) -> AnyObject - { - let copy = super.copyWithZone(zone) as! RealmBarLineScatterCandleBubbleDataSet - copy.highlightColor = highlightColor - copy.highlightLineWidth = highlightLineWidth - copy.highlightLineDashPhase = highlightLineDashPhase - copy.highlightLineDashLengths = highlightLineDashLengths - return copy - } -} diff --git a/Source/ChartsRealm/Data/RealmBaseDataSet.swift b/Source/ChartsRealm/Data/RealmBaseDataSet.swift deleted file mode 100644 index 3067647bf5..0000000000 --- a/Source/ChartsRealm/Data/RealmBaseDataSet.swift +++ /dev/null @@ -1,561 +0,0 @@ -// -// RealmBaseDataSet.swift -// Charts -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -import Foundation -#if NEEDS_CHARTS -import Charts -#endif -import Realm -import Realm.Dynamic - -open class RealmBaseDataSet: ChartBaseDataSet -{ - open func initialize() - { - fatalError("RealmBaseDataSet is an abstract class, you must inherit from it. Also please do not call super.initialize().") - } - - public required init() - { - super.init() - - // default color - colors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0)) - - initialize() - } - - public override init(label: String?) - { - super.init() - - // default color - colors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0)) - - self.label = label - - initialize() - } - - public init(results: RLMResults?, xValueField: String?, yValueField: String, label: String?) - { - super.init() - - // default color - colors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0)) - - self.label = label - - _results = results - _yValueField = yValueField - _xValueField = xValueField - - if _xValueField != nil - { - _results = _results?.sortedResults(usingProperty: _xValueField!, ascending: true) - } - - notifyDataSetChanged() - - initialize() - } - - public convenience init(results: RLMResults?, yValueField: String, label: String?) - { - self.init(results: results, xValueField: nil, yValueField: yValueField, label: label) - } - - public convenience init(results: RLMResults?, xValueField: String?, yValueField: String) - { - self.init(results: results, xValueField: xValueField, yValueField: yValueField, label: "DataSet") - } - - public convenience init(results: RLMResults?, yValueField: String) - { - self.init(results: results, yValueField: yValueField) - } - - public init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String?, yValueField: String, label: String?) - { - super.init() - - // default color - colors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0)) - - self.label = label - - _yValueField = yValueField - _xValueField = xValueField - - if realm != nil - { - loadResults(realm: realm!, modelName: modelName) - } - - initialize() - } - - public convenience init(realm: RLMRealm?, modelName: String, resultsWhere: String, yValueField: String, label: String?) - { - self.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: nil, yValueField: yValueField, label: label) - } - - open func loadResults(realm: RLMRealm, modelName: String) - { - loadResults(realm: realm, modelName: modelName, predicate: nil) - } - - open func loadResults(realm: RLMRealm, modelName: String, predicate: NSPredicate?) - { - if predicate == nil - { - _results = realm.allObjects(modelName) - } - else - { - _results = realm.objects(modelName, with: predicate!) - } - - if _xValueField != nil - { - _results = _results?.sortedResults(usingProperty: _xValueField!, ascending: true) - } - - notifyDataSetChanged() - } - - // MARK: - Data functions and accessors - - internal var _results: RLMResults? - internal var _yValueField: String? - internal var _xValueField: String? - internal var _cache = [ChartDataEntry]() - - internal var _yMax: Double = -DBL_MAX - internal var _yMin: Double = DBL_MAX - - internal var _xMax: Double = -DBL_MAX - internal var _xMin: Double = DBL_MAX - - /// Makes sure that the cache is populated for the specified range - internal func buildCache() - { - guard let results = _results else { return } - - _cache.removeAll() - _cache.reserveCapacity(Int(results.count)) - - var xValue: Double = 0.0 - - let iterator = NSFastEnumerationIterator(results) - while let e = iterator.next() - { - _cache.append(buildEntryFromResultObject(e as! RLMObject, x: xValue)) - xValue += 1.0 - } - } - - internal func buildEntryFromResultObject(_ object: RLMObject, x: Double) -> ChartDataEntry - { - let entry = ChartDataEntry(x: _xValueField == nil ? x : object[_xValueField!] as! Double, y: object[_yValueField!] as! Double) - - return entry - } - - /// Makes sure that the cache is populated for the specified range - internal func clearCache() - { - _cache.removeAll() - } - - /// Use this method to tell the data set that the underlying data has changed - open override func notifyDataSetChanged() - { - buildCache() - calcMinMax() - } - - open override func calcMinMax() - { - if _cache.count == 0 - { - return - } - - _yMax = -DBL_MAX - _yMin = DBL_MAX - _xMax = -DBL_MAX - _xMin = DBL_MAX - - for e in _cache - { - calcMinMax(entry: e) - } - } - - /// Updates the min and max x and y value of this DataSet based on the given Entry. - /// - /// - parameter e: - internal func calcMinMax(entry e: ChartDataEntry) - { - if e.y < _yMin - { - _yMin = e.y - } - if e.y > _yMax - { - _yMax = e.y - } - if e.x < _xMin - { - _xMin = e.x - } - if e.x > _xMax - { - _xMax = e.x - } - } - - /// - returns: The minimum y-value this DataSet holds - open override var yMin: Double { return _yMin } - - /// - returns: The maximum y-value this DataSet holds - open override var yMax: Double { return _yMax } - - /// - returns: The minimum x-value this DataSet holds - open override var xMin: Double { return _xMin } - - /// - returns: The maximum x-value this DataSet holds - open override var xMax: Double { return _xMax } - - /// - returns: The number of y-values this DataSet represents - open override var entryCount: Int { return Int(_results?.count ?? 0) } - - /// - returns: The entry object found at the given index (not x-value!) - /// - throws: out of bounds - /// if `i` is out of bounds, it may throw an out-of-bounds exception - open override func entryForIndex(_ i: Int) -> ChartDataEntry? - { - if _cache.count == 0 - { - buildCache() - } - return _cache[i] - } - - /// - returns: The first Entry object found at the given x-value with binary search. - /// If the no Entry at the specified x-value is found, this method returns the Entry at the closest x-value according to the rounding. - /// nil if no Entry object at that x-value. - /// - parameter xValue: the x-value - /// - parameter closestToY: If there are multiple y-values for the specified x-value, - /// - parameter rounding: determine whether to round up/down/closest if there is no Entry matching the provided x-value - open override func entryForXValue( - _ xValue: Double, - closestToY yValue: Double, - rounding: ChartDataSetRounding) -> ChartDataEntry? - { - let index = self.entryIndex(x: xValue, closestToY: yValue, rounding: rounding) - if index > -1 - { - return entryForIndex(index) - } - return nil - } - - /// - returns: The first Entry object found at the given x-value with binary search. - /// If the no Entry at the specified x-value is found, this method returns the Entry at the closest x-value. - /// nil if no Entry object at that x-value. - /// - parameter xValue: the x-value - /// - parameter closestToY: If there are multiple y-values for the specified x-value, - open override func entryForXValue( - _ xValue: Double, - closestToY y: Double) -> ChartDataEntry? - { - return entryForXValue(xValue, closestToY: y, rounding: .closest) - } - - /// - returns: All Entry objects found at the given x-value with binary search. - /// An empty array if no Entry object at that x-value. - open override func entriesForXValue(_ xValue: Double) -> [ChartDataEntry] - { - /*var entries = [ChartDataEntry]() - - guard let results = _results else { return entries } - - if _xValueField != nil - { - let foundObjects = results.objectsWithPredicate( - NSPredicate(format: "%K == %f", _xValueField!, x) - ) - - for e in foundObjects - { - entries.append(buildEntryFromResultObject(e as! RLMObject, x: x)) - } - } - - return entries*/ - - var entries = [ChartDataEntry]() - - var low = 0 - var high = _cache.count - 1 - - while low <= high - { - var m = (high + low) / 2 - var entry = _cache[m] - - if xValue == entry.x - { - while m > 0 && _cache[m - 1].x == xValue - { - m -= 1 - } - - high = _cache.count - while m < high - { - entry = _cache[m] - if entry.x == xValue - { - entries.append(entry) - } - else - { - break - } - - m += 1 - } - - break - } - else - { - if xValue > entry.x - { - low = m + 1 - } - else - { - high = m - 1 - } - } - } - - return entries - } - - /// - returns: The array-index of the specified entry. - /// If the no Entry at the specified x-value is found, this method returns the index of the Entry at the closest x-value according to the rounding. - /// - /// - parameter xValue: x-value of the entry to search for - /// - parameter closestToY: If there are multiple y-values for the specified x-value, - /// - parameter rounding: Rounding method if exact value was not found - open override func entryIndex( - x xValue: Double, - closestToY yValue: Double, - rounding: ChartDataSetRounding) -> Int - { - /*guard let results = _results else { return -1 } - - let foundIndex = results.indexOfObjectWithPredicate( - NSPredicate(format: "%K == %f", _xValueField!, x) - ) - - // TODO: Figure out a way to quickly find the closest index - - return Int(foundIndex)*/ - - var low = 0 - var high = _cache.count - 1 - var closest = high - - while low < high - { - let m = (low + high) / 2 - - let d1 = _cache[m].x - xValue - let d2 = _cache[m + 1].x - xValue - let ad1 = abs(d1), ad2 = abs(d2) - - if ad2 < ad1 - { - // [m + 1] is closer to xValue - // Search in an higher place - low = m + 1 - } - else if ad1 < ad2 - { - // [m] is closer to xValue - // Search in a lower place - high = m - } - else - { - // We have multiple sequential x-value with same distance - - if d1 >= 0.0 - { - // Search in a lower place - high = m - } - else if d1 < 0.0 - { - // Search in an higher place - low = m + 1 - } - } - - closest = high - } - - if closest != -1 - { - let closestXValue = _cache[closest].x - - if rounding == .up - { - // If rounding up, and found x-value is lower than specified x, and we can go upper... - if closestXValue < xValue && closest < _cache.count - 1 - { - closest += 1 - } - } - else if rounding == .down - { - // If rounding down, and found x-value is upper than specified x, and we can go lower... - if closestXValue > xValue && closest > 0 - { - closest -= 1 - } - } - - // Search by closest to y-value - if !yValue.isNaN - { - while closest > 0 && _cache[closest - 1].x == closestXValue - { - closest -= 1 - } - - var closestYValue = _cache[closest].y - var closestYIndex = closest - - while true - { - closest += 1 - if closest >= _cache.count { break } - - let value = _cache[closest] - - if value.x != closestXValue { break } - if abs(value.y - yValue) < abs(closestYValue - yValue) - { - closestYValue = yValue - closestYIndex = closest - } - } - - closest = closestYIndex - } - } - - return closest - } - - /// - returns: The array-index of the specified entry - /// - /// - parameter e: the entry to search for - open override func entryIndex(entry e: ChartDataEntry) -> Int - { - for i in 0 ..< _cache.count - { - if _cache[i] === e || _cache[i].isEqual(e) - { - return i - } - } - - return -1 - } - - /// Not supported on Realm datasets - open override func addEntry(_ e: ChartDataEntry) -> Bool - { - return false - } - - /// Not supported on Realm datasets - open override func addEntryOrdered(_ e: ChartDataEntry) -> Bool - { - return false - } - - /// Not supported on Realm datasets - open override func removeEntry(_ entry: ChartDataEntry) -> Bool - { - return false - } - - /// Checks if this DataSet contains the specified Entry. - /// - returns: `true` if contains the entry, `false` ifnot. - open override func contains(_ e: ChartDataEntry) -> Bool - { - for entry in _cache - { - if entry.isEqual(e) - { - return true - } - } - - return false - } - - /// - returns: The fieldname that represents the "y-values" in the realm-data. - open var yValueField: String? - { - get - { - return _yValueField - } - } - - /// - returns: The fieldname that represents the "x-values" in the realm-data. - open var xValueField: String? - { - get - { - return _xValueField - } - } - - // MARK: - NSCopying - - open override func copyWithZone(_ zone: NSZone?) -> AnyObject - { - let copy = super.copyWithZone(zone) as! RealmBaseDataSet - - copy._results = _results - copy._yValueField = _yValueField - copy._xValueField = _xValueField - copy._yMax = _yMax - copy._yMin = _yMin - copy._xMax = _xMax - copy._xMin = _xMin - - return copy - } -} - - diff --git a/Source/ChartsRealm/Data/RealmBubbleDataSet.swift b/Source/ChartsRealm/Data/RealmBubbleDataSet.swift deleted file mode 100644 index 3645eb10d0..0000000000 --- a/Source/ChartsRealm/Data/RealmBubbleDataSet.swift +++ /dev/null @@ -1,108 +0,0 @@ -// -// RealmBubbleDataSet.swift -// Charts -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -import Foundation -import CoreGraphics -#if NEEDS_CHARTS -import Charts -#endif -import Realm -import Realm.Dynamic - -open class RealmBubbleDataSet: RealmBarLineScatterCandleBubbleDataSet, IBubbleChartDataSet -{ - open override func initialize() - { - } - - public required init() - { - super.init() - } - - public init(results: RLMResults?, xValueField: String, yValueField: String, sizeField: String, label: String?) - { - _sizeField = sizeField - - super.init(results: results, xValueField: xValueField, yValueField: yValueField, label: label) - } - - public convenience init(results: RLMResults?, xValueField: String, yValueField: String, sizeField: String) - { - self.init(results: results, xValueField: xValueField, yValueField: yValueField, sizeField: sizeField, label: "DataSet") - } - - public init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String, yValueField: String, sizeField: String, label: String?) - { - _sizeField = sizeField - - super.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: xValueField, yValueField: yValueField, label: label) - } - - // MARK: - Data functions and accessors - - internal var _sizeField: String? - - internal var _maxSize = CGFloat(0.0) - - open var maxSize: CGFloat { return _maxSize } - open var normalizeSizeEnabled: Bool = true - open var isNormalizeSizeEnabled: Bool { return normalizeSizeEnabled } - - internal override func buildEntryFromResultObject(_ object: RLMObject, x: Double) -> ChartDataEntry - { - let entry = BubbleChartDataEntry(x: _xValueField == nil ? x : object[_xValueField!] as! Double, y: object[_yValueField!] as! Double, size: object[_sizeField!] as! CGFloat) - - return entry - } - - open override func calcMinMax() - { - if _cache.count == 0 - { - return - } - - _yMax = -DBL_MAX - _yMin = DBL_MAX - _xMax = -DBL_MAX - _xMin = DBL_MAX - - for e in _cache as! [BubbleChartDataEntry] - { - calcMinMax(entry: e) - - let size = e.size - - if size > _maxSize - { - _maxSize = size - } - } - } - - // MARK: - Styling functions and accessors - - /// Sets/gets the width of the circle that surrounds the bubble when highlighted - open var highlightCircleWidth: CGFloat = 2.5 - - // MARK: - NSCopying - - open override func copyWithZone(_ zone: NSZone?) -> AnyObject - { - let copy = super.copyWithZone(zone) as! RealmBubbleDataSet - copy._xMin = _xMin - copy._xMax = _xMax - copy._maxSize = _maxSize - copy.highlightCircleWidth = highlightCircleWidth - return copy - } -} diff --git a/Source/ChartsRealm/Data/RealmCandleDataSet.swift b/Source/ChartsRealm/Data/RealmCandleDataSet.swift deleted file mode 100644 index 1d6b5eef47..0000000000 --- a/Source/ChartsRealm/Data/RealmCandleDataSet.swift +++ /dev/null @@ -1,185 +0,0 @@ -// -// RealmCandleDataSet.swift -// Charts -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -import Foundation -import CoreGraphics -#if NEEDS_CHARTS -import Charts -#endif -import Realm -import Realm.Dynamic - -open class RealmCandleDataSet: RealmLineScatterCandleRadarDataSet, ICandleChartDataSet -{ - open override func initialize() - { - - } - - public required init() - { - super.init() - } - - public init(results: RLMResults?, xValueField: String, highField: String, lowField: String, openField: String, closeField: String, label: String?) - { - _highField = highField - _lowField = lowField - _openField = openField - _closeField = closeField - - super.init(results: results, xValueField: xValueField, yValueField: "", label: label) - } - - public convenience init(results: RLMResults?, xValueField: String, highField: String, lowField: String, openField: String, closeField: String) - { - self.init(results: results, xValueField: xValueField, highField: highField, lowField: lowField, openField: openField, closeField: closeField, label: "DataSet") - } - - public init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String, highField: String, lowField: String, openField: String, closeField: String, label: String?) - { - _highField = highField - _lowField = lowField - _openField = openField - _closeField = closeField - - super.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: xValueField, yValueField: "", label: label) - } - - // MARK: - Data functions and accessors - - internal var _highField: String? - internal var _lowField: String? - internal var _openField: String? - internal var _closeField: String? - - internal override func buildEntryFromResultObject(_ object: RLMObject, x: Double) -> ChartDataEntry - { - let entry = CandleChartDataEntry( - x: _xValueField == nil ? x : object[_xValueField!] as! Double, - shadowH: object[_highField!] as! Double, - shadowL: object[_lowField!] as! Double, - open: object[_openField!] as! Double, - close: object[_closeField!] as! Double) - - return entry - } - - open override func calcMinMax() - { - if _cache.count == 0 - { - return - } - - _yMax = -DBL_MAX - _yMin = DBL_MAX - _xMax = -DBL_MAX - _xMin = DBL_MAX - - for e in _cache as! [CandleChartDataEntry] - { - if e.low < _yMin - { - _yMin = e.low - } - - if e.high > _yMax - { - _yMax = e.high - } - - if e.x < _xMin - { - _xMin = e.x - } - if e.x > _xMax - { - _xMax = e.x - } - } - } - - // MARK: - Styling functions and accessors - - /// the space between the candle entries - /// - /// **default**: 0.1 (10%) - fileprivate var _barSpace = CGFloat(0.1) - - /// the space that is left out on the left and right side of each candle, - /// **default**: 0.1 (10%), max 0.45, min 0.0 - open var barSpace: CGFloat - { - set - { - if newValue < 0.0 - { - _barSpace = 0.0 - } - else if newValue > 0.45 - { - _barSpace = 0.45 - } - else - { - _barSpace = newValue - } - } - get - { - return _barSpace - } - } - - /// should the candle bars show? - /// when false, only "ticks" will show - /// - /// **default**: true - open var showCandleBar: Bool = true - - /// the width of the candle-shadow-line in pixels. - /// - /// **default**: 3.0 - open var shadowWidth = CGFloat(1.5) - - /// the color of the shadow line - open var shadowColor: NSUIColor? - - /// use candle color for the shadow - open var shadowColorSameAsCandle = false - - /// Is the shadow color same as the candle color? - open var isShadowColorSameAsCandle: Bool { return shadowColorSameAsCandle } - - /// color for open == close - open var neutralColor: NSUIColor? - - /// color for open > close - open var increasingColor: NSUIColor? - - /// color for open < close - open var decreasingColor: NSUIColor? - - /// Are increasing values drawn as filled? - /// increasing candlesticks are traditionally hollow - open var increasingFilled = false - - /// Are increasing values drawn as filled? - open var isIncreasingFilled: Bool { return increasingFilled } - - /// Are decreasing values drawn as filled? - /// descreasing candlesticks are traditionally filled - open var decreasingFilled = true - - /// Are decreasing values drawn as filled? - open var isDecreasingFilled: Bool { return decreasingFilled } -} diff --git a/Source/ChartsRealm/Data/RealmLineDataSet.swift b/Source/ChartsRealm/Data/RealmLineDataSet.swift deleted file mode 100644 index 9d8cebc8f3..0000000000 --- a/Source/ChartsRealm/Data/RealmLineDataSet.swift +++ /dev/null @@ -1,195 +0,0 @@ -// -// RealmLineDataSet.swift -// Charts -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -import Foundation -#if NEEDS_CHARTS -import Charts -#endif -import Realm -import Realm.Dynamic - -open class RealmLineDataSet: RealmLineRadarDataSet, ILineChartDataSet -{ - open override func initialize() - { - circleColors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0)) - } - - // MARK: - Data functions and accessors - - // MARK: - Styling functions and accessors - - /// The drawing mode for this line dataset - /// - /// **default**: Linear - open var mode: LineChartDataSet.Mode = LineChartDataSet.Mode.linear - - fileprivate var _cubicIntensity = CGFloat(0.2) - - /// Intensity for cubic lines (min = 0.05, max = 1) - /// - /// **default**: 0.2 - open var cubicIntensity: CGFloat - { - get - { - return _cubicIntensity - } - set - { - _cubicIntensity = newValue - if _cubicIntensity > 1.0 - { - _cubicIntensity = 1.0 - } - if _cubicIntensity < 0.05 - { - _cubicIntensity = 0.05 - } - } - } - - @available(*, deprecated: 1.0, message: "Use `mode` instead.") - open var drawCubicEnabled: Bool - { - get - { - return mode == .cubicBezier - } - set - { - mode = newValue ? LineChartDataSet.Mode.cubicBezier : LineChartDataSet.Mode.linear - } - } - - @available(*, deprecated: 1.0, message: "Use `mode` instead.") - open var isDrawCubicEnabled: Bool { return drawCubicEnabled } - - @available(*, deprecated: 1.0, message: "Use `mode` instead.") - open var drawSteppedEnabled: Bool - { - get - { - return mode == .stepped - } - set - { - mode = newValue ? LineChartDataSet.Mode.stepped : LineChartDataSet.Mode.linear - } - } - - @available(*, deprecated: 1.0, message: "Use `mode` instead.") - open var isDrawSteppedEnabled: Bool { return drawSteppedEnabled } - - /// The radius of the drawn circles. - open var circleRadius = CGFloat(8.0) - - /// The hole radius of the drawn circles - open var circleHoleRadius = CGFloat(4.0) - - open var circleColors = [NSUIColor]() - - /// - returns: The color at the given index of the DataSet's circle-color array. - /// Performs a IndexOutOfBounds check by modulus. - open func getCircleColor(atIndex index: Int) -> NSUIColor? - { - let size = circleColors.count - let index = index % size - if index >= size - { - return nil - } - return circleColors[index] - } - - /// Sets the one and ONLY color that should be used for this DataSet. - /// Internally, this recreates the colors array and adds the specified color. - open func setCircleColor(_ color: NSUIColor) - { - circleColors.removeAll(keepingCapacity: false) - circleColors.append(color) - } - - /// Resets the circle-colors array and creates a new one - open func resetCircleColors(_ index: Int) - { - circleColors.removeAll(keepingCapacity: false) - } - - /// If true, drawing circles is enabled - open var drawCirclesEnabled = true - - /// - returns: `true` if drawing circles for this DataSet is enabled, `false` ifnot - open var isDrawCirclesEnabled: Bool { return drawCirclesEnabled } - - /// The color of the inner circle (the circle-hole). - open var circleHoleColor: NSUIColor? = NSUIColor.white - - /// `true` if drawing circles for this DataSet is enabled, `false` ifnot - open var drawCircleHoleEnabled = true - - /// - returns: `true` if drawing the circle-holes is enabled, `false` ifnot. - open var isDrawCircleHoleEnabled: Bool { return drawCircleHoleEnabled } - - /// This is how much (in pixels) into the dash pattern are we starting from. - open var lineDashPhase = CGFloat(0.0) - - /// This is the actual dash pattern. - /// I.e. [2, 3] will paint [-- -- ] - /// [1, 3, 4, 2] will paint [- ---- - ---- ] - open var lineDashLengths: [CGFloat]? - - /// Line cap type, default is CGLineCap.Butt - open var lineCapType = CGLineCap.butt - - /// formatter for customizing the position of the fill-line - fileprivate var _fillFormatter: IFillFormatter = DefaultFillFormatter() - - /// Sets a custom IFillFormatter to the chart that handles the position of the filled-line for each DataSet. Set this to null to use the default logic. - open var fillFormatter: IFillFormatter? - { - get - { - return _fillFormatter - } - set - { - if newValue == nil - { - _fillFormatter = DefaultFillFormatter() - } - else - { - _fillFormatter = newValue! - } - } - } - - // MARK: NSCopying - - open override func copyWithZone(_ zone: NSZone?) -> AnyObject - { - let copy = super.copyWithZone(zone) as! RealmLineDataSet - copy.circleRadius = circleRadius - copy.circleHoleRadius = circleHoleRadius - copy.circleColors = circleColors - copy.circleRadius = circleRadius - copy.cubicIntensity = cubicIntensity - copy.lineDashPhase = lineDashPhase - copy.lineDashLengths = lineDashLengths - copy.lineCapType = lineCapType - copy.drawCirclesEnabled = drawCirclesEnabled - copy.drawCircleHoleEnabled = drawCircleHoleEnabled - copy.mode = mode - return copy - } - -} diff --git a/Source/ChartsRealm/Data/RealmLineRadarDataSet.swift b/Source/ChartsRealm/Data/RealmLineRadarDataSet.swift deleted file mode 100644 index 7c728d494e..0000000000 --- a/Source/ChartsRealm/Data/RealmLineRadarDataSet.swift +++ /dev/null @@ -1,94 +0,0 @@ -// -// RealmLineRadarDataSet.swift -// Charts -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -import Foundation -import CoreGraphics -#if NEEDS_CHARTS -import Charts -#endif -import Realm -import Realm.Dynamic - -open class RealmLineRadarDataSet: RealmLineScatterCandleRadarDataSet, ILineRadarChartDataSet -{ - // MARK: - Data functions and accessors - - // MARK: - Styling functions and accessors - - /// The color that is used for filling the line surface area. - fileprivate var _fillColor = NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0) - - /// The color that is used for filling the line surface area. - open var fillColor: NSUIColor - { - get { return _fillColor } - set - { - _fillColor = newValue - fill = nil - } - } - - /// The object that is used for filling the area below the line. - /// **default**: nil - open var fill: Fill? - - /// The alpha value that is used for filling the line surface, - /// **default**: 0.33 - open var fillAlpha = CGFloat(0.33) - - fileprivate var _lineWidth = CGFloat(1.0) - - /// line width of the chart (min = 0.2, max = 10) - /// - /// **default**: 1 - open var lineWidth: CGFloat - { - get - { - return _lineWidth - } - set - { - if newValue < 0.2 - { - _lineWidth = 0.2 - } - else if newValue > 10.0 - { - _lineWidth = 10.0 - } - else - { - _lineWidth = newValue - } - } - } - - open var drawFilledEnabled = false - - open var isDrawFilledEnabled: Bool - { - return drawFilledEnabled - } - - // MARK: NSCopying - - open override func copyWithZone(_ zone: NSZone?) -> AnyObject - { - let copy = super.copyWithZone(zone) as! RealmLineRadarDataSet - copy.fillColor = fillColor - copy._lineWidth = _lineWidth - copy.drawFilledEnabled = drawFilledEnabled - return copy - } - -} diff --git a/Source/ChartsRealm/Data/RealmLineScatterCandleRadarDataSet.swift b/Source/ChartsRealm/Data/RealmLineScatterCandleRadarDataSet.swift deleted file mode 100644 index df018d16f5..0000000000 --- a/Source/ChartsRealm/Data/RealmLineScatterCandleRadarDataSet.swift +++ /dev/null @@ -1,55 +0,0 @@ -// -// RealmLineScatterCandleRadarDataSet.swift -// Charts -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -import Foundation -#if NEEDS_CHARTS -import Charts -#endif -import Realm -import Realm.Dynamic - -open class RealmLineScatterCandleRadarDataSet: RealmBarLineScatterCandleBubbleDataSet, ILineScatterCandleRadarChartDataSet -{ - // MARK: - Data functions and accessors - - // MARK: - Styling functions and accessors - - /// Enables / disables the horizontal highlight-indicator. If disabled, the indicator is not drawn. - open var drawHorizontalHighlightIndicatorEnabled = true - - /// Enables / disables the vertical highlight-indicator. If disabled, the indicator is not drawn. - open var drawVerticalHighlightIndicatorEnabled = true - - /// - returns: `true` if horizontal highlight indicator lines are enabled (drawn) - open var isHorizontalHighlightIndicatorEnabled: Bool { return drawHorizontalHighlightIndicatorEnabled } - - /// - returns: `true` if vertical highlight indicator lines are enabled (drawn) - open var isVerticalHighlightIndicatorEnabled: Bool { return drawVerticalHighlightIndicatorEnabled } - - /// Enables / disables both vertical and horizontal highlight-indicators. - /// :param: enabled - open func setDrawHighlightIndicators(_ enabled: Bool) - { - drawHorizontalHighlightIndicatorEnabled = enabled - drawVerticalHighlightIndicatorEnabled = enabled - } - - // MARK: NSCopying - - open override func copyWithZone(_ zone: NSZone?) -> AnyObject - { - let copy = super.copyWithZone(zone) as! RealmLineScatterCandleRadarDataSet - copy.drawHorizontalHighlightIndicatorEnabled = drawHorizontalHighlightIndicatorEnabled - copy.drawVerticalHighlightIndicatorEnabled = drawVerticalHighlightIndicatorEnabled - return copy - } - -} diff --git a/Source/ChartsRealm/Data/RealmPieDataSet.swift b/Source/ChartsRealm/Data/RealmPieDataSet.swift deleted file mode 100644 index 1857da3027..0000000000 --- a/Source/ChartsRealm/Data/RealmPieDataSet.swift +++ /dev/null @@ -1,126 +0,0 @@ -// -// RealmPieDataSet.swift -// Charts -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -import Foundation -import CoreGraphics -#if NEEDS_CHARTS -import Charts -#endif -import Realm -import Realm.Dynamic - -open class RealmPieDataSet: RealmBaseDataSet, IPieChartDataSet -{ - open override func initialize() - { - self.valueTextColor = NSUIColor.white - self.valueFont = NSUIFont.systemFont(ofSize: 13.0) - } - - public required init() - { - super.init() - } - - public init(results: RLMResults?, yValueField: String, labelField: String?) - { - _labelField = labelField - - super.init(results: results, xValueField: nil, yValueField: yValueField, label: nil) - } - - // MARK: - Data functions and accessors - - internal var _labelField: String? - - internal override func buildEntryFromResultObject(_ object: RLMObject, x: Double) -> ChartDataEntry - { - if _labelField == nil - { - return PieChartDataEntry(value: object[_yValueField!] as! Double) - } - else - { - return PieChartDataEntry(value: object[_yValueField!] as! Double, label: object[_labelField!] as? String) - } - } - - // MARK: - Styling functions and accessors - - fileprivate var _sliceSpace = CGFloat(0.0) - - /// the space in pixels between the pie-slices - /// **default**: 0 - /// **maximum**: 20 - open var sliceSpace: CGFloat - { - get - { - return _sliceSpace - } - set - { - var space = newValue - if space > 20.0 - { - space = 20.0 - } - if space < 0.0 - { - space = 0.0 - } - _sliceSpace = space - } - } - - /// 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: PieChartDataSet.ValuePosition = .insideSlice - open var yValuePosition: PieChartDataSet.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 - - // MARK: - NSCopying - - open override func copyWithZone(_ zone: NSZone?) -> AnyObject - { - let copy = super.copyWithZone(zone) as! RealmPieDataSet - copy._sliceSpace = _sliceSpace - copy.selectionShift = selectionShift - return copy - } -} diff --git a/Source/ChartsRealm/Data/RealmRadarDataSet.swift b/Source/ChartsRealm/Data/RealmRadarDataSet.swift deleted file mode 100644 index f96d59707a..0000000000 --- a/Source/ChartsRealm/Data/RealmRadarDataSet.swift +++ /dev/null @@ -1,76 +0,0 @@ -// -// RealmRadarDataSet.swift -// Charts -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -import Foundation -import CoreGraphics -#if NEEDS_CHARTS -import Charts -#endif -import Realm -import Realm.Dynamic - -open class RealmRadarDataSet: RealmLineRadarDataSet, IRadarChartDataSet -{ - open override func initialize() - { - self.valueFont = NSUIFont.systemFont(ofSize: 13.0) - } - - public required init() - { - super.init() - } - - public init(results: RLMResults?, yValueField: String, label: String?) - { - super.init(results: results, xValueField: nil, yValueField: yValueField, label: label) - } - - public convenience init(results: RLMResults?, yValueField: String) - { - self.init(results: results, yValueField: yValueField, label: "DataSet") - } - - public init(realm: RLMRealm?, modelName: String, resultsWhere: String, yValueField: String, label: String?) - { - super.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: nil, yValueField: yValueField, label: label) - } - - // MARK: - Data functions and accessors - - internal override func buildEntryFromResultObject(_ object: RLMObject, x: Double) -> ChartDataEntry - { - return RadarChartDataEntry(value: object[_yValueField!] as! Double) - } - - // MARK: - Styling functions and accessors - - /// flag indicating whether highlight circle should be drawn or not - /// **default**: false - open var drawHighlightCircleEnabled: Bool = false - - /// - returns: `true` if highlight circle should be drawn, `false` ifnot - open var isDrawHighlightCircleEnabled: Bool { return drawHighlightCircleEnabled } - - open var highlightCircleFillColor: NSUIColor? = NSUIColor.white - - /// The stroke color for highlight circle. - /// If `nil`, the color of the dataset is taken. - open var highlightCircleStrokeColor: NSUIColor? - - open var highlightCircleStrokeAlpha: CGFloat = 0.3 - - open var highlightCircleInnerRadius: CGFloat = 3.0 - - open var highlightCircleOuterRadius: CGFloat = 4.0 - - open var highlightCircleStrokeWidth: CGFloat = 2.0 -} diff --git a/Source/ChartsRealm/Data/RealmScatterDataSet.swift b/Source/ChartsRealm/Data/RealmScatterDataSet.swift deleted file mode 100644 index ecf61b58f0..0000000000 --- a/Source/ChartsRealm/Data/RealmScatterDataSet.swift +++ /dev/null @@ -1,63 +0,0 @@ -// -// RealmScatterDataSet.swift -// Charts -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -import Foundation -import CoreGraphics -#if NEEDS_CHARTS -import Charts -#endif -import Realm -import Realm.Dynamic - -open class RealmScatterDataSet: RealmLineScatterCandleRadarDataSet, IScatterChartDataSet -{ - - /// The size the scatter shape will have - open var scatterShapeSize = CGFloat(10.0) - - /// The radius of the hole in the shape (applies to Square, Circle and Triangle) - /// **default**: 0.0 - open var scatterShapeHoleRadius: CGFloat = 0.0 - - /// Color for the hole in the shape. Setting to `nil` will behave as transparent. - /// **default**: nil - open var scatterShapeHoleColor: NSUIColor? = nil - - /// Sets the ScatterShape this DataSet should be drawn with. - /// This will search for an available IShapeRenderer and set this renderer for the DataSet - open func setScatterShape(_ shape: ScatterChartDataSet.Shape) - { - self.shapeRenderer = ScatterChartDataSet.renderer(forShape: shape) - } - - /// The IShapeRenderer responsible for rendering this DataSet. - /// This can also be used to set a custom IShapeRenderer aside from the default ones. - /// **default**: `SquareShapeRenderer` - open var shapeRenderer: IShapeRenderer? = SquareShapeRenderer() - - open override func initialize() - { - - } - - // MARK: NSCopying - - open override func copyWithZone(_ zone: NSZone?) -> AnyObject - { - let copy = super.copyWithZone(zone) as! RealmScatterDataSet - copy.scatterShapeSize = scatterShapeSize - copy.scatterShapeHoleRadius = scatterShapeHoleRadius - copy.scatterShapeHoleColor = scatterShapeHoleColor - copy.shapeRenderer = shapeRenderer - return copy - } - -} diff --git a/Source/Supporting Files/ChartsRealm.h b/Source/Supporting Files/ChartsRealm.h deleted file mode 100755 index c3281be726..0000000000 --- a/Source/Supporting Files/ChartsRealm.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// ChartsRealm.h -// Charts -// -// Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda -// A port of MPAndroidChart for iOS -// Licensed under Apache License 2.0 -// -// https://github.com/danielgindi/Charts -// - -#import - -//! Project version number for ChartsRealm. -FOUNDATION_EXPORT double ChartsRealmVersionNumber; - -//! Project version string for ChartsRealm. -FOUNDATION_EXPORT const unsigned char ChartsRealmVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import - - diff --git a/Source/Supporting Files/Info.plist b/Source/Supporting Files/Info.plist index 1b23976bd8..e7216db431 100644 --- a/Source/Supporting Files/Info.plist +++ b/Source/Supporting Files/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.0.1 + 3.0.2 CFBundleSignature ???? CFBundleVersion - 23 + 24 NSPrincipalClass diff --git a/Tests/Charts/BarChartTests.swift b/Tests/Charts/BarChartTests.swift index e16669da7d..60f6d8d512 100644 --- a/Tests/Charts/BarChartTests.swift +++ b/Tests/Charts/BarChartTests.swift @@ -24,11 +24,13 @@ class BarChartTests: FBSnapshotTestCase for (i, value) in values.enumerated() { - entries.append(BarChartDataEntry(x: Double(i), y: value)) + entries.append(BarChartDataEntry(x: Double(i), y: value, icon: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil))) } dataSet = BarChartDataSet(values: entries, label: "Bar chart unit test data") - + dataSet.drawIconsEnabled = false + dataSet.iconsOffset = CGPoint(x: 0, y: -10.0) + let data = BarChartData(dataSet: dataSet) data.barWidth = 0.85 @@ -80,4 +82,10 @@ class BarChartTests: FBSnapshotTestCase chart.xAxis.drawGridLinesEnabled = false FBSnapshotVerifyView(chart) } + + func testDrawIcons() + { + dataSet.drawIconsEnabled = true + FBSnapshotVerifyView(chart) + } } diff --git a/Tests/Charts/ChartUtilsTests.swift b/Tests/Charts/ChartUtilsTests.swift index a19b514d53..3887ac483e 100644 --- a/Tests/Charts/ChartUtilsTests.swift +++ b/Tests/Charts/ChartUtilsTests.swift @@ -53,7 +53,7 @@ class ChartUtilsTests: XCTestCase { func testDecimalWithMaxValue() { - let number = DBL_MAX + let number = Double.greatestFiniteMagnitude let actual = ChartUtils.decimals(number) let expected = 0 @@ -63,7 +63,7 @@ class ChartUtilsTests: XCTestCase { func testDecimalWithMinValue() { - let number = DBL_MIN + let number = Double.leastNormalMagnitude let actual = ChartUtils.decimals(number) let expected = 310 // Don't think this is supposed to be this value maybe 0? diff --git a/Tests/Charts/LineChartTests.swift b/Tests/Charts/LineChartTests.swift index 4ef5a9d65b..905a3922e1 100755 --- a/Tests/Charts/LineChartTests.swift +++ b/Tests/Charts/LineChartTests.swift @@ -24,11 +24,13 @@ class LineChartTests: FBSnapshotTestCase for (i, value) in values.enumerated() { - entries.append(ChartDataEntry(x: Double(i), y: value)) + entries.append(ChartDataEntry(x: Double(i), y: value, icon: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil))) } dataSet = LineChartDataSet(values: entries, label: "First unit test data") - + dataSet.drawIconsEnabled = false + dataSet.iconsOffset = CGPoint(x: 0, y: 20.0) + chart = LineChartView(frame: CGRect(x: 0, y: 0, width: 480, height: 350)) chart.backgroundColor = NSUIColor.clear chart.leftAxis.axisMinimum = 0.0 @@ -70,4 +72,10 @@ class LineChartTests: FBSnapshotTestCase dataSet.drawCircleHoleEnabled = false FBSnapshotVerifyView(chart) } + + func testDrawIcons() + { + dataSet.drawIconsEnabled = true + FBSnapshotVerifyView(chart) + } } diff --git a/Tests/ChartsRealm/ChartsRealmTest.swift b/Tests/ChartsRealm/ChartsRealmTest.swift deleted file mode 100644 index 8474e8c3d6..0000000000 --- a/Tests/ChartsRealm/ChartsRealmTest.swift +++ /dev/null @@ -1,21 +0,0 @@ -import XCTest -import FBSnapshotTestCase -import Charts -@testable import ChartsRealm - -class ChartsRealmTest: FBSnapshotTestCase -{ - override func setUp() - { - super.setUp() - - // Set to `true` to re-capture all snapshots - self.recordMode = false - } - - override func tearDown() - { - // Put teardown code here. This method is called after the invocation of each test method in the class. - super.tearDown() - } -} diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testDefaultValues.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testDefaultValues.png new file mode 100644 index 0000000000..4ac538c976 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testDefaultValues.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testDefaultValues@2x.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testDefaultValues@2x.png new file mode 100644 index 0000000000..71fd9e89e7 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testDefaultValues@2x.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testDrawIcons.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testDrawIcons.png new file mode 100644 index 0000000000..27871dd260 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testDrawIcons.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testDrawIcons@2x.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testDrawIcons@2x.png new file mode 100644 index 0000000000..060cd40d4a Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testDrawIcons@2x.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideHorizontalGridlines.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideHorizontalGridlines.png new file mode 100644 index 0000000000..e055c12127 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideHorizontalGridlines.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideHorizontalGridlines@2x.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideHorizontalGridlines@2x.png new file mode 100644 index 0000000000..b367140d6c Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideHorizontalGridlines@2x.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideLeftAxis.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideLeftAxis.png new file mode 100644 index 0000000000..327eb202a0 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideLeftAxis.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideLeftAxis@2x.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideLeftAxis@2x.png new file mode 100644 index 0000000000..ef6de921f2 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideLeftAxis@2x.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideRightAxis.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideRightAxis.png new file mode 100644 index 0000000000..5977848ba2 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideRightAxis.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideRightAxis@2x.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideRightAxis@2x.png new file mode 100644 index 0000000000..b7d538950b Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideRightAxis@2x.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideVerticalGridlines.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideVerticalGridlines.png new file mode 100644 index 0000000000..a35afaca41 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideVerticalGridlines.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideVerticalGridlines@2x.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideVerticalGridlines@2x.png new file mode 100644 index 0000000000..b15802f96a Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHideVerticalGridlines@2x.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHidesValues.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHidesValues.png new file mode 100644 index 0000000000..2e49b1bca6 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHidesValues.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHidesValues@2x.png b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHidesValues@2x.png new file mode 100644 index 0000000000..bcaaf874ee Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.BarChartTests/testHidesValues@2x.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDefaultValues.png b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDefaultValues.png new file mode 100644 index 0000000000..08d8d8fdac Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDefaultValues.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDefaultValues@2x.png b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDefaultValues@2x.png new file mode 100644 index 0000000000..cd87c21500 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDefaultValues@2x.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircleHole.png b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircleHole.png new file mode 100644 index 0000000000..8ce85acc8d Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircleHole.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircleHole@2x.png b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircleHole@2x.png new file mode 100644 index 0000000000..7bd64928f4 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircleHole@2x.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircles.png b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircles.png new file mode 100644 index 0000000000..470b8849ea Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircles.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircles@2x.png b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircles@2x.png new file mode 100644 index 0000000000..a5011d6508 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircles@2x.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDrawIcons.png b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDrawIcons.png new file mode 100644 index 0000000000..8bff3adcf0 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDrawIcons.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDrawIcons@2x.png b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDrawIcons@2x.png new file mode 100644 index 0000000000..e6f4633903 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testDrawIcons@2x.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testHidesValues.png b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testHidesValues.png new file mode 100644 index 0000000000..08d8d8fdac Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testHidesValues.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testHidesValues@2x.png b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testHidesValues@2x.png new file mode 100644 index 0000000000..cd87c21500 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testHidesValues@2x.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testIsCubic.png b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testIsCubic.png new file mode 100644 index 0000000000..94545fa334 Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testIsCubic.png differ diff --git a/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testIsCubic@2x.png b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testIsCubic@2x.png new file mode 100644 index 0000000000..efe77c1fec Binary files /dev/null and b/Tests/ReferenceImages_32/ChartsTests.LineChartTests/testIsCubic@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons.png new file mode 100644 index 0000000000..dfe9c79820 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons@2x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons@2x.png new file mode 100644 index 0000000000..1828600ac6 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons@3x.png b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons@3x.png new file mode 100644 index 0000000000..963ab90865 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.BarChartTests/testDrawIcons@3x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons.png new file mode 100644 index 0000000000..e1a622165a Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons@2x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons@2x.png new file mode 100644 index 0000000000..e48a938124 Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons@2x.png differ diff --git a/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons@3x.png b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons@3x.png new file mode 100644 index 0000000000..d5933cdd8c Binary files /dev/null and b/Tests/ReferenceImages_64/ChartsTests.LineChartTests/testDrawIcons@3x.png differ diff --git a/scripts/build-dependencies.sh b/scripts/build-dependencies.sh index f33a526549..8f0eca0b05 100755 --- a/scripts/build-dependencies.sh +++ b/scripts/build-dependencies.sh @@ -14,7 +14,7 @@ function build_dependencies { } function alert_to_install_carthage { - echo "error: Carthage was not found! In order to build Charts you need to use Carthage to build it's dependencies. Carthage can be downloaded from https://github.com/Carthage/Carthage." + echo "error: Carthage was not found! In order to build Charts you need to use Carthage to build its dependencies. Carthage can be downloaded from https://github.com/Carthage/Carthage." exit 1 } @@ -23,4 +23,4 @@ then build_dependencies else alert_to_install_carthage -fi \ No newline at end of file +fi