├── .gitignore ├── Assets ├── feature_graphic.png └── feature_graphic.psd ├── CONTRIBUTING.md ├── Charts.podspec ├── Charts ├── Cartfile.private ├── Cartfile.resolved ├── Carthage │ └── Checkouts │ │ └── ios-snapshot-test-case │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── CHANGELOG.md │ │ ├── Carthage │ │ └── Build │ │ ├── FBSnapshotTestCase.podspec │ │ ├── FBSnapshotTestCase.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── FBSnapshotTestCase.xcscheme │ │ ├── FBSnapshotTestCase │ │ ├── Categories │ │ │ ├── UIImage+Compare.h │ │ │ ├── UIImage+Compare.m │ │ │ ├── UIImage+Diff.h │ │ │ ├── UIImage+Diff.m │ │ │ ├── UIImage+Snapshot.h │ │ │ └── UIImage+Snapshot.m │ │ ├── FBSnapshotTestCase-Info.plist │ │ ├── FBSnapshotTestCase.h │ │ ├── FBSnapshotTestCase.m │ │ ├── FBSnapshotTestCasePlatform.h │ │ ├── FBSnapshotTestCasePlatform.m │ │ ├── FBSnapshotTestController.h │ │ ├── FBSnapshotTestController.m │ │ └── SwiftSupport.swift │ │ ├── FBSnapshotTestCaseDemo │ │ ├── FBSnapshotTestCaseDemo.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── FBSnapshotTestCaseDemo.xcscheme │ │ ├── FBSnapshotTestCaseDemo │ │ │ ├── FBAppDelegate.h │ │ │ ├── FBAppDelegate.m │ │ │ ├── FBSnapshotTestCaseDemo-Info.plist │ │ │ ├── FBSnapshotTestCaseDemo-Prefix.pch │ │ │ ├── Images.xcassets │ │ │ │ ├── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ │ └── LaunchImage.launchimage │ │ │ │ │ └── Contents.json │ │ │ ├── en.lproj │ │ │ │ └── InfoPlist.strings │ │ │ └── main.m │ │ ├── FBSnapshotTestCaseDemoTests │ │ │ ├── FBSnapshotTestCaseDemoTests-Info.plist │ │ │ ├── FBSnapshotTestCaseDemoTests.m │ │ │ ├── FBSnapshotTestCaseSwiftTests.swift │ │ │ ├── ReferenceImages_32 │ │ │ │ ├── FBSnapshotTestCaseDemoTests.FBSnapshotTestCaseSwiftTest │ │ │ │ │ └── testExample@2x.png │ │ │ │ └── FBSnapshotTestCaseDemoTests │ │ │ │ │ ├── testViewSnapshot@2x.png │ │ │ │ │ ├── testViewSnapshotWithDifferentBackgroundColorPerArchitecture@2x.png │ │ │ │ │ ├── testViewSnapshotWithUIAppearance@2x.png │ │ │ │ │ └── testViewSnapshotWithVisualEffects@2x.png │ │ │ ├── ReferenceImages_64 │ │ │ │ ├── FBSnapshotTestCaseDemoTests.FBSnapshotTestCaseSwiftTest │ │ │ │ │ └── testExample@2x.png │ │ │ │ └── FBSnapshotTestCaseDemoTests │ │ │ │ │ ├── testViewSnapshot@2x.png │ │ │ │ │ ├── testViewSnapshotRecordedOnlyFor64BitArchitecture@2x.png │ │ │ │ │ ├── testViewSnapshotWithDifferentBackgroundColorPerArchitecture@2x.png │ │ │ │ │ ├── testViewSnapshotWithUIAppearance@2x.png │ │ │ │ │ └── testViewSnapshotWithVisualEffects@2x.png │ │ │ └── en.lproj │ │ │ │ └── InfoPlist.strings │ │ ├── Podfile │ │ ├── Podfile.lock │ │ └── Scheme_FB_REFERENCE_IMAGE_DIR.png │ │ ├── FBSnapshotTestCaseTests │ │ ├── FBSnapshotControllerTests.m │ │ ├── FBSnapshotTestCaseTests-Info.plist │ │ ├── square-copy.png │ │ ├── square.png │ │ ├── square_with_pixel.png │ │ └── square_with_text.png │ │ ├── LICENSE │ │ ├── PATENTS │ │ ├── README.md │ │ ├── SnapshotTest.xctemplate │ │ ├── TemplateInfo.plist │ │ └── ___FILEBASENAME___.m │ │ └── build.sh ├── Charts.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── Charts-TV.xcscheme │ │ └── Charts-iOS.xcscheme ├── ChartsTests │ ├── Info.plist │ ├── LineChartTests.swift │ ├── ReferenceImages_32 │ │ └── ChartsTests.LineChartTests │ │ │ ├── testDefaultValues@2x.png │ │ │ ├── testDoesntDrawCircleHole@2x.png │ │ │ ├── testDoesntDrawCircles@2x.png │ │ │ ├── testHidesValues@2x.png │ │ │ └── testIsCubic@2x.png │ └── ReferenceImages_64 │ │ └── ChartsTests.LineChartTests │ │ ├── testDefaultValues@2x.png │ │ ├── testDefaultValues@3x.png │ │ ├── testDoesntDrawCircleHole@2x.png │ │ ├── testDoesntDrawCircleHole@3x.png │ │ ├── testDoesntDrawCircles@2x.png │ │ ├── testDoesntDrawCircles@3x.png │ │ ├── testHidesValues@2x.png │ │ ├── testHidesValues@3x.png │ │ ├── testIsCubic@2x.png │ │ └── testIsCubic@3x.png ├── Classes │ ├── Animation │ │ ├── ChartAnimationEasing.swift │ │ └── ChartAnimator.swift │ ├── Charts │ │ ├── BarChartView.swift │ │ ├── BarLineChartViewBase.swift │ │ ├── BubbleChartView.swift │ │ ├── CandleStickChartView.swift │ │ ├── ChartViewBase.swift │ │ ├── CombinedChartView.swift │ │ ├── HorizontalBarChartView.swift │ │ ├── LineChartView.swift │ │ ├── PieChartView.swift │ │ ├── PieRadarChartViewBase.swift │ │ ├── RadarChartView.swift │ │ └── ScatterChartView.swift │ ├── Components │ │ ├── ChartAxisBase.swift │ │ ├── ChartComponentBase.swift │ │ ├── ChartLegend.swift │ │ ├── ChartLimitLine.swift │ │ ├── ChartMarker.swift │ │ ├── ChartXAxis.swift │ │ └── ChartYAxis.swift │ ├── Data │ │ ├── BarChartData.swift │ │ ├── BarChartDataEntry.swift │ │ ├── BarChartDataSet.swift │ │ ├── BarLineScatterCandleBubbleChartData.swift │ │ ├── BarLineScatterCandleBubbleChartDataSet.swift │ │ ├── BubbleChartData.swift │ │ ├── BubbleChartDataEntry.swift │ │ ├── BubbleChartDataSet.swift │ │ ├── CandleChartData.swift │ │ ├── CandleChartDataEntry.swift │ │ ├── CandleChartDataSet.swift │ │ ├── ChartData.swift │ │ ├── ChartDataEntry.swift │ │ ├── ChartDataSet.swift │ │ ├── CombinedChartData.swift │ │ ├── LineChartData.swift │ │ ├── LineChartDataSet.swift │ │ ├── LineRadarChartDataSet.swift │ │ ├── LineScatterCandleChartDataSet.swift │ │ ├── PieChartData.swift │ │ ├── PieChartDataSet.swift │ │ ├── RadarChartData.swift │ │ ├── RadarChartDataSet.swift │ │ ├── ScatterChartData.swift │ │ └── ScatterChartDataSet.swift │ ├── Filters │ │ ├── ChartDataApproximatorFilter.swift │ │ └── ChartDataBaseFilter.swift │ ├── Formatters │ │ ├── ChartDefaultXAxisValueFormatter.swift │ │ ├── ChartFillFormatter.swift │ │ └── ChartXAxisValueFormatter.swift │ ├── Highlight │ │ ├── BarChartHighlighter.swift │ │ ├── ChartHighlight.swift │ │ ├── ChartHighlighter.swift │ │ ├── ChartRange.swift │ │ ├── CombinedHighlighter.swift │ │ └── HorizontalBarChartHighlighter.swift │ ├── Interfaces │ │ ├── BarChartDataProvider.swift │ │ ├── BarLineScatterCandleBubbleChartDataProvider.swift │ │ ├── BubbleChartDataProvider.swift │ │ ├── CandleChartDataProvider.swift │ │ ├── ChartDataProvider.swift │ │ ├── LineChartDataProvider.swift │ │ └── ScatterChartDataProvider.swift │ ├── Renderers │ │ ├── BarChartRenderer.swift │ │ ├── BubbleChartRenderer.swift │ │ ├── CandleStickChartRenderer.swift │ │ ├── ChartAxisRendererBase.swift │ │ ├── ChartDataRendererBase.swift │ │ ├── ChartLegendRenderer.swift │ │ ├── ChartRendererBase.swift │ │ ├── ChartXAxisRenderer.swift │ │ ├── ChartXAxisRendererBarChart.swift │ │ ├── ChartXAxisRendererHorizontalBarChart.swift │ │ ├── ChartXAxisRendererRadarChart.swift │ │ ├── ChartYAxisRenderer.swift │ │ ├── ChartYAxisRendererHorizontalBarChart.swift │ │ ├── ChartYAxisRendererRadarChart.swift │ │ ├── CombinedChartRenderer.swift │ │ ├── HorizontalBarChartRenderer.swift │ │ ├── LineChartRenderer.swift │ │ ├── LineScatterCandleRadarChartRenderer.swift │ │ ├── PieChartRenderer.swift │ │ ├── RadarChartRenderer.swift │ │ └── ScatterChartRenderer.swift │ └── Utils │ │ ├── ChartColorTemplates.swift │ │ ├── ChartSelectionDetail.swift │ │ ├── ChartTransformer.swift │ │ ├── ChartTransformerHorizontalBarChart.swift │ │ ├── ChartUtils.swift │ │ └── ChartViewPortHandler.swift └── Supporting Files │ ├── Charts.h │ └── Info.plist ├── ChartsDemo ├── ChartsDemo.xcodeproj │ └── project.pbxproj ├── Classes │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Components │ │ ├── BalloonMarker.swift │ │ ├── MyCustomXValueFormatter.h │ │ └── MyCustomXValueFormatter.m │ ├── DemoBaseViewController.h │ ├── DemoBaseViewController.m │ ├── DemoListViewController.h │ ├── DemoListViewController.m │ ├── DemoListViewController.xib │ └── Demos │ │ ├── AnotherBarChartViewController.h │ │ ├── AnotherBarChartViewController.m │ │ ├── AnotherBarChartViewController.xib │ │ ├── BarChartViewController.h │ │ ├── BarChartViewController.m │ │ ├── BarChartViewController.xib │ │ ├── BubbleChartViewController.h │ │ ├── BubbleChartViewController.m │ │ ├── BubbleChartViewController.xib │ │ ├── CandleStickChartViewController.h │ │ ├── CandleStickChartViewController.m │ │ ├── CandleStickChartViewController.xib │ │ ├── ColoredLineChartViewController.h │ │ ├── ColoredLineChartViewController.m │ │ ├── ColoredLineChartViewController.xib │ │ ├── CombinedChartViewController.h │ │ ├── CombinedChartViewController.m │ │ ├── CombinedChartViewController.xib │ │ ├── CubicLineChartViewController.h │ │ ├── CubicLineChartViewController.m │ │ ├── CubicLineChartViewController.xib │ │ ├── HorizontalBarChartViewController.h │ │ ├── HorizontalBarChartViewController.m │ │ ├── HorizontalBarChartViewController.xib │ │ ├── LineChart1ViewController.h │ │ ├── LineChart1ViewController.m │ │ ├── LineChart1ViewController.xib │ │ ├── LineChart2ViewController.h │ │ ├── LineChart2ViewController.m │ │ ├── LineChart2ViewController.xib │ │ ├── MultipleBarChartViewController.h │ │ ├── MultipleBarChartViewController.m │ │ ├── MultipleBarChartViewController.xib │ │ ├── MultipleLinesChartViewController.h │ │ ├── MultipleLinesChartViewController.m │ │ ├── MultipleLinesChartViewController.xib │ │ ├── NegativeStackedBarChartViewController.h │ │ ├── NegativeStackedBarChartViewController.m │ │ ├── NegativeStackedBarChartViewController.xib │ │ ├── PieChartViewController.h │ │ ├── PieChartViewController.m │ │ ├── PieChartViewController.xib │ │ ├── RadarChartViewController.h │ │ ├── RadarChartViewController.m │ │ ├── RadarChartViewController.xib │ │ ├── ScatterChartViewController.h │ │ ├── ScatterChartViewController.m │ │ ├── ScatterChartViewController.xib │ │ ├── SinusBarChartViewController.h │ │ ├── SinusBarChartViewController.m │ │ ├── SinusBarChartViewController.xib │ │ ├── StackedBarChartViewController.h │ │ ├── StackedBarChartViewController.m │ │ └── StackedBarChartViewController.xib ├── Resources │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-29@2x.png │ │ │ ├── Icon-29@3x.png │ │ │ ├── Icon-40@2x.png │ │ │ ├── Icon-40@3x.png │ │ │ ├── Icon-60@2x.png │ │ │ └── Icon-60@3x.png │ │ └── LaunchImage.launchimage │ │ │ ├── Contents.json │ │ │ ├── Default-568h@2x.png │ │ │ ├── Default-667h@2x.png │ │ │ ├── Default-736h@3x.png │ │ │ └── Default@2x.png │ ├── app-icon │ │ ├── Icon-29@2x.png │ │ ├── Icon-29@3x.png │ │ ├── Icon-40@2x.png │ │ ├── Icon-40@3x.png │ │ ├── Icon-60@2x.png │ │ ├── Icon-60@3x.png │ │ ├── iTunesArtwork │ │ └── iTunesArtwork@2x │ └── launch-image │ │ ├── Default-568h@2x.png │ │ ├── Default-667h@2x.png │ │ ├── Default-736h@3x.png │ │ └── Default@2x.png └── Supporting Files │ ├── ChartsDemo-Bridging-Header.h │ ├── Info.plist │ └── main.m ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | *.xcworkspace 20 | 21 | # CocoaPods 22 | # 23 | # We recommend against adding the Pods directory to your .gitignore. However 24 | # you should judge for yourself, the pros and cons are mentioned at: 25 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 26 | # 27 | # Pods/ 28 | 29 | Carthage 30 | Charts.framework.zip 31 | -------------------------------------------------------------------------------- /Assets/feature_graphic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Assets/feature_graphic.png -------------------------------------------------------------------------------- /Assets/feature_graphic.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Assets/feature_graphic.psd -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | Bug-fixes and features often come from users of the Charts framework, and improving it greatly. We want to keep it as easy as possible to contribute changes that improve the experience for users all around the world. There are a few guidelines that we 4 | need contributors to follow so that we can have a chance of keeping on 5 | top of things. 6 | 7 | ## Simple issues and bug reports 8 | 9 | If you are reporting a bug which can be observed visually, please add to your issue either: 10 | 11 | * Screenshots, if the bug is easily explainable 12 | * A working sample project that we can compile, run, and immediately observe the issue 13 | 14 | ## Getting Started with Contributions 15 | 16 | * Make sure you have a [GitHub account](https://github.com/signup/free) 17 | * Submit a ticket for your issue, assuming one does not already exist. 18 | * Clearly describe the issue including steps to reproduce when it is a bug. 19 | * Make sure you fill in the earliest version (or commit number) that you know has the issue. 20 | * Fork the repository on GitHub 21 | 22 | ## Making Changes 23 | 24 | * Create a topic branch from where you want to base your work. This is usually the master branch. 25 | * Make commits of logical units. 26 | * Make sure your code conforms to the code style around it. It's easy, just look around! 27 | * If you have made changes back and forth, or have made merges, your commit history might look messy and hard to understand. A single issue or change should still be in one commit. So please squash those commits together and rebase them however you need to - to make our lives easier when reading it later. 28 | * Check for unnecessary whitespace with `git diff --check` before committing. 29 | * Make sure your commit messages are in the proper format. 30 | 31 | ```` 32 | First line must be up to 50 chars (Fixes #1234) 33 | 34 | The first line should be a short statement as to what have changed, and should also include an issue number, prefixed with a dash. 35 | The body of the message comes after an empty new line, and describes the changes 36 | more thoroughly, especially if there was a special case handled there, 37 | or maybe some trickery that only code wizards can understand. 38 | ```` 39 | 40 | * Make sure you have tested your changes well. 41 | * If your changes could theoretically affect some other component or case, which you do not necessarily use, you still have to test it. 42 | * Create a Pull Request from your topic branch to the relevant branch in the main repo. If you go to the main repo of the framework, you'll see a big green button which pretty much prepares the PR for you. You just have to hit it. 43 | 44 | ## Making Trivial Changes 45 | 46 | For changes of a trivial nature to comments and documentation, it is not 47 | always necessary to create a new ticket. In this case, it is 48 | appropriate to start the first line of a commit with '(doc)' instead of 49 | a ticket number. Even the default commit message the GitHub generates is fine with us. 50 | -------------------------------------------------------------------------------- /Charts.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "Charts" 3 | s.version = "2.1.6" 4 | s.summary = "ios-charts is a powerful & easy to use chart library for iOS" 5 | s.homepage = "https://github.com/danielgindi/ios-charts" 6 | s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" } 7 | s.authors = "Daniel Cohen Gindi", "Philipp Jahoda" 8 | s.ios.deployment_target = "8.0" 9 | s.tvos.deployment_target = "9.0" 10 | s.source = { :git => "https://github.com/danielgindi/ios-charts.git", :tag => "v#{s.version}" } 11 | s.source_files = "Classes", "Charts/Classes/**/*.swift" 12 | end 13 | -------------------------------------------------------------------------------- /Charts/Cartfile.private: -------------------------------------------------------------------------------- 1 | github "facebook/ios-snapshot-test-case" ~> 2.0 2 | -------------------------------------------------------------------------------- /Charts/Cartfile.resolved: -------------------------------------------------------------------------------- 1 | github "facebook/ios-snapshot-test-case" "2.0.5" 2 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | */build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | xcuserdata 12 | profile 13 | *.moved-aside 14 | DerivedData 15 | .idea/ 16 | *.hmap 17 | *.xccheckout 18 | Pods -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode7 3 | before_script: 4 | - gem install cocoapods -v 0.37.2 --no-ri --no-rdoc 5 | script: 6 | ./build.sh 7 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | ## 2.0.5 6 | 7 | - Swift 2.0 (#111, #120) (Thanks to @pietbrauer and @grantjk) 8 | - Fix pod spec by disabling bitcode (#115) (Thanks to @soleares) 9 | - Fix for incorrect errors with multiple suffixes (#119) (Thanks to @Grubas7) 10 | - Support for Model and OS in image names (#121 thanks to @esttorhe) 11 | 12 | ## 2.0.4 13 | 14 | - Support loading reference images from the test bundle (#104) (Thanks to @yiding) 15 | - Fix for retina tolerance comparisons (#107) 16 | 17 | ## 2.0.3 18 | 19 | - New property added `usesDrawViewHierarchyInRect` to handle cases like `UIVisualEffect` (#70), `UIAppearance` (#91) and Size Classes (#92) (#100) 20 | 21 | ## 2.0.2 22 | 23 | - Fix for retina comparisons (#96) 24 | 25 | ## 2.0.1 26 | 27 | - Allow usage of Objective-C subspec only, for projects supporting iOS 7 (#93) (Thanks to @x2on) 28 | 29 | ## 2.0.0 30 | 31 | - Approximate comparison (#88) (Thanks to @nap-sam-dean) 32 | - Swift support (#87) (Thanks to @pietbrauer) 33 | 34 | ## 1.8.1 35 | 36 | ### Fixed 37 | 38 | - Prevent mangling of C function names when compiled with a C++ compiler. (#79) 39 | 40 | ## 1.8.0 41 | 42 | ### Changed 43 | 44 | - The default directories for snapshots images are now **ReferenceImages_32** (32bit) and **ReferenceImages_64** (64bit) and the suffix depends on the architecture when the test is running. (#77) 45 | - If a test fails for a given suffix, it will try to load and compare all other suffixes before failing. 46 | - Added assertion on setRecordMode. (#76) 47 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/Carthage/Build: -------------------------------------------------------------------------------- 1 | ../../../../Carthage/Build -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCase.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "FBSnapshotTestCase" 3 | s.version = "2.0.5" 4 | s.summary = "Snapshot view unit tests for iOS" 5 | s.description = <<-DESC 6 | A "snapshot test case" takes a configured UIView or CALayer 7 | and uses the renderInContext: method to get an image snapshot 8 | of its contents. It compares this snapshot to a "reference image" 9 | stored in your source code repository and fails the test if the 10 | two images don't match. 11 | DESC 12 | s.homepage = "https://github.com/facebook/ios-snapshot-test-case" 13 | s.license = 'BSD' 14 | s.author = 'Facebook' 15 | s.source = { :git => "https://github.com/facebook/ios-snapshot-test-case.git", 16 | :tag => s.version.to_s } 17 | s.platform = :ios, '7.0' 18 | s.requires_arc = true 19 | s.framework = 'XCTest' 20 | s.pod_target_xcconfig = { 'ENABLE_BITCODE' => 'NO' } 21 | s.public_header_files = ['FBSnapshotTestCase/FBSnapshotTestCase.h', 'FBSnapshotTestCase/FBSnapshotTestCasePlatform.h'] 22 | s.private_header_files = ['FBSnapshotTestCase/FBSnapshotTestController.h', 'FBSnapshotTestCase/UIImage+Compare.h', 'FBSnapshotTestCase/UIImage+Diff.h'] 23 | s.default_subspecs = 'SwiftSupport' 24 | s.subspec 'Core' do |cs| 25 | cs.source_files = 'FBSnapshotTestCase/**/*.{h,m}' 26 | end 27 | s.subspec 'SwiftSupport' do |cs| 28 | cs.dependency 'FBSnapshotTestCase/Core' 29 | cs.source_files = 'FBSnapshotTestCase/**/*.swift' 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCase/Categories/UIImage+Compare.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Gabriel Handford on 3/1/09. 3 | // Copyright 2009-2013. All rights reserved. 4 | // Created by John Boiles on 10/20/11. 5 | // Copyright (c) 2011. All rights reserved 6 | // Modified by Felix Schulze on 2/11/13. 7 | // Copyright 2013. All rights reserved. 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | @interface UIImage (Compare) 34 | 35 | - (BOOL)fb_compareWithImage:(UIImage *)image tolerance:(CGFloat)tolerance; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCase/Categories/UIImage+Diff.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Gabriel Handford on 3/1/09. 3 | // Copyright 2009-2013. All rights reserved. 4 | // Created by John Boiles on 10/20/11. 5 | // Copyright (c) 2011. All rights reserved 6 | // Modified by Felix Schulze on 2/11/13. 7 | // Copyright 2013. All rights reserved. 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | @interface UIImage (Diff) 34 | 35 | - (UIImage *)fb_diffWithImage:(UIImage *)image; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCase/Categories/UIImage+Diff.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Gabriel Handford on 3/1/09. 3 | // Copyright 2009-2013. All rights reserved. 4 | // Created by John Boiles on 10/20/11. 5 | // Copyright (c) 2011. All rights reserved 6 | // Modified by Felix Schulze on 2/11/13. 7 | // Copyright 2013. All rights reserved. 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | 31 | #import 32 | 33 | @implementation UIImage (Diff) 34 | 35 | - (UIImage *)fb_diffWithImage:(UIImage *)image 36 | { 37 | if (!image) { 38 | return nil; 39 | } 40 | CGSize imageSize = CGSizeMake(MAX(self.size.width, image.size.width), MAX(self.size.height, image.size.height)); 41 | UIGraphicsBeginImageContextWithOptions(imageSize, YES, 0); 42 | CGContextRef context = UIGraphicsGetCurrentContext(); 43 | [self drawInRect:CGRectMake(0, 0, self.size.width, self.size.height)]; 44 | CGContextSetAlpha(context, 0.5); 45 | CGContextBeginTransparencyLayer(context, NULL); 46 | [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)]; 47 | CGContextSetBlendMode(context, kCGBlendModeDifference); 48 | CGContextSetFillColorWithColor(context,[UIColor whiteColor].CGColor); 49 | CGContextFillRect(context, CGRectMake(0, 0, self.size.width, self.size.height)); 50 | CGContextEndTransparencyLayer(context); 51 | UIImage *returnImage = UIGraphicsGetImageFromCurrentImageContext(); 52 | UIGraphicsEndImageContext(); 53 | return returnImage; 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCase/Categories/UIImage+Snapshot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | @interface UIImage (Snapshot) 14 | 15 | /// Uses renderInContext: to get a snapshot of the layer. 16 | + (UIImage *)fb_imageForLayer:(CALayer *)layer; 17 | 18 | /// Uses renderInContext: to get a snapshot of the view layer. 19 | + (UIImage *)fb_imageForViewLayer:(UIView *)view; 20 | 21 | /// Uses drawViewHierarchyInRect: to get a snapshot of the view and adds the view into a window if needed. 22 | + (UIImage *)fb_imageForView:(UIView *)view; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCase/Categories/UIImage+Snapshot.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | @implementation UIImage (Snapshot) 14 | 15 | + (UIImage *)fb_imageForLayer:(CALayer *)layer 16 | { 17 | CGRect bounds = layer.bounds; 18 | NSAssert1(CGRectGetWidth(bounds), @"Zero width for layer %@", layer); 19 | NSAssert1(CGRectGetHeight(bounds), @"Zero height for layer %@", layer); 20 | 21 | UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0); 22 | CGContextRef context = UIGraphicsGetCurrentContext(); 23 | NSAssert1(context, @"Could not generate context for layer %@", layer); 24 | CGContextSaveGState(context); 25 | [layer layoutIfNeeded]; 26 | [layer renderInContext:context]; 27 | CGContextRestoreGState(context); 28 | 29 | UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext(); 30 | UIGraphicsEndImageContext(); 31 | return snapshot; 32 | } 33 | 34 | + (UIImage *)fb_imageForViewLayer:(UIView *)view 35 | { 36 | [view layoutIfNeeded]; 37 | return [self fb_imageForLayer:view.layer]; 38 | } 39 | 40 | + (UIImage *)fb_imageForView:(UIView *)view 41 | { 42 | CGRect bounds = view.bounds; 43 | NSAssert1(CGRectGetWidth(bounds), @"Zero width for view %@", view); 44 | NSAssert1(CGRectGetHeight(bounds), @"Zero height for view %@", view); 45 | 46 | UIWindow *window = view.window; 47 | if (window == nil) { 48 | window = [[UIWindow alloc] initWithFrame:bounds]; 49 | [window addSubview:view]; 50 | [window makeKeyAndVisible]; 51 | } 52 | 53 | UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0); 54 | [view layoutIfNeeded]; 55 | [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES]; 56 | 57 | UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext(); 58 | UIGraphicsEndImageContext(); 59 | return snapshot; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCase/FBSnapshotTestCase-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCase/FBSnapshotTestCasePlatform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** 18 | Returns a Boolean value that indicates whether the snapshot test is running in 64Bit. 19 | This method is a convenience for creating the suffixes set based on the architecture 20 | that the test is running. 21 | 22 | @returns @c YES if the test is running in 64bit, otherwise @c NO. 23 | */ 24 | BOOL FBSnapshotTestCaseIs64Bit(void); 25 | 26 | /** 27 | Returns a default set of strings that is used to append a suffix based on the architectures. 28 | @warning Do not modify this function, you can create your own and use it with @c FBSnapshotVerifyViewWithOptions() 29 | 30 | @returns An @c NSOrderedSet object containing strings that are appended to the reference images directory. 31 | */ 32 | NSOrderedSet *FBSnapshotTestCaseDefaultSuffixes(void); 33 | 34 | /** 35 | Returns a fully «normalized» file name. 36 | Strips punctuation and spaces and replaces them with @c _. Also appends the device model, running OS and screen size to the file name. 37 | 38 | @returns An @c NSString object containing the passed @c fileName with the device model, OS and screen size appended at the end. 39 | */ 40 | NSString *FBDeviceAgnosticNormalizedFileName(NSString *fileName); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCase/FBSnapshotTestCasePlatform.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | #import 13 | 14 | BOOL FBSnapshotTestCaseIs64Bit(void) 15 | { 16 | #if __LP64__ 17 | return YES; 18 | #else 19 | return NO; 20 | #endif 21 | } 22 | 23 | NSOrderedSet *FBSnapshotTestCaseDefaultSuffixes(void) 24 | { 25 | NSMutableOrderedSet *suffixesSet = [[NSMutableOrderedSet alloc] init]; 26 | [suffixesSet addObject:@"_32"]; 27 | [suffixesSet addObject:@"_64"]; 28 | if (FBSnapshotTestCaseIs64Bit()) { 29 | return [suffixesSet reversedOrderedSet]; 30 | } 31 | return [suffixesSet copy]; 32 | } 33 | 34 | NSString *FBDeviceAgnosticNormalizedFileName(NSString *fileName) 35 | { 36 | UIDevice *device = [UIDevice currentDevice]; 37 | CGSize screenSize = [[UIApplication sharedApplication] keyWindow].bounds.size; 38 | NSString *os = device.systemVersion; 39 | 40 | fileName = [NSString stringWithFormat:@"%@_%@%@_%.0fx%.0f", fileName, device.model, os, screenSize.width, screenSize.height]; 41 | 42 | NSMutableCharacterSet *invalidCharacters = [NSMutableCharacterSet new]; 43 | [invalidCharacters formUnionWithCharacterSet:[NSCharacterSet whitespaceCharacterSet]]; 44 | [invalidCharacters formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]]; 45 | NSArray *validComponents = [fileName componentsSeparatedByCharactersInSet:invalidCharacters]; 46 | fileName = [validComponents componentsJoinedByString:@"_"]; 47 | 48 | return fileName; 49 | } -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCase/SwiftSupport.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | public extension FBSnapshotTestCase { 12 | public func FBSnapshotVerifyView(view: UIView, identifier: String = "", suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), file: String = __FILE__, line: UInt = __LINE__) { 13 | FBSnapshotVerifyViewOrLayer(view, identifier: identifier, suffixes: suffixes) 14 | } 15 | 16 | public func FBSnapshotVerifyLayer(layer: CALayer, identifier: String = "", suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), file: String = __FILE__, line: UInt = __LINE__) { 17 | FBSnapshotVerifyViewOrLayer(layer, identifier: identifier, suffixes: suffixes) 18 | } 19 | 20 | private func FBSnapshotVerifyViewOrLayer(viewOrLayer: AnyObject, identifier: String = "", suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), file: String = __FILE__, line: UInt = __LINE__) { 21 | let envReferenceImageDirectory = self.getReferenceImageDirectoryWithDefault(FB_REFERENCE_IMAGE_DIR) 22 | var error: NSError? 23 | var comparisonSuccess = false 24 | 25 | if let envReferenceImageDirectory = envReferenceImageDirectory { 26 | for suffix in suffixes { 27 | let referenceImagesDirectory = "\(envReferenceImageDirectory)\(suffix)" 28 | if viewOrLayer.isKindOfClass(UIView) { 29 | do { 30 | try compareSnapshotOfView(viewOrLayer as! UIView, referenceImagesDirectory: referenceImagesDirectory, identifier: identifier, tolerance: 0) 31 | comparisonSuccess = true 32 | } catch let error1 as NSError { 33 | error = error1 34 | comparisonSuccess = false 35 | } 36 | } else if viewOrLayer.isKindOfClass(CALayer) { 37 | do { 38 | try compareSnapshotOfLayer(viewOrLayer as! CALayer, referenceImagesDirectory: referenceImagesDirectory, identifier: identifier, tolerance: 0) 39 | comparisonSuccess = true 40 | } catch let error1 as NSError { 41 | error = error1 42 | comparisonSuccess = false 43 | } 44 | } else { 45 | assertionFailure("Only UIView and CALayer classes can be snapshotted") 46 | } 47 | 48 | assert(recordMode == false, message: "Test ran in record mode. Reference image is now saved. Disable record mode to perform an actual snapshot comparison!", file: file, line: line) 49 | 50 | if comparisonSuccess || recordMode { 51 | break 52 | } 53 | 54 | assert(comparisonSuccess, message: "Snapshot comparison failed: \(error)", file: file, line: line) 55 | } 56 | } else { 57 | XCTFail("Missing value for referenceImagesDirectory - Set FB_REFERENCE_IMAGE_DIR as Environment variable in your scheme.") 58 | } 59 | } 60 | 61 | func assert(assertion: Bool, message: String, file: String, line: UInt) { 62 | if !assertion { 63 | XCTFail(message, file: file, line: line) 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/FBAppDelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | @interface FBAppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/FBAppDelegate.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import "FBAppDelegate.h" 12 | 13 | @implementation FBAppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 18 | // Override point for customization after application launch. 19 | UIViewController *viewController = [[UIViewController alloc] init]; 20 | self.window.rootViewController = viewController; 21 | self.window.backgroundColor = [UIColor whiteColor]; 22 | [self.window makeKeyAndVisible]; 23 | return YES; 24 | } 25 | 26 | - (void)applicationWillResignActive:(UIApplication *)application 27 | { 28 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 29 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 30 | } 31 | 32 | - (void)applicationDidEnterBackground:(UIApplication *)application 33 | { 34 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 35 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 36 | } 37 | 38 | - (void)applicationWillEnterForeground:(UIApplication *)application 39 | { 40 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 41 | } 42 | 43 | - (void)applicationDidBecomeActive:(UIApplication *)application 44 | { 45 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 46 | } 47 | 48 | - (void)applicationWillTerminate:(UIApplication *)application 49 | { 50 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.facebook.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "60x60", 21 | "scale" : "3x" 22 | } 23 | ], 24 | "info" : { 25 | "version" : 1, 26 | "author" : "xcode" 27 | } 28 | } -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemo/main.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | #import "FBAppDelegate.h" 14 | 15 | int main(int argc, char * argv[]) 16 | { 17 | @autoreleasepool { 18 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([FBAppDelegate class])); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseDemoTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.facebook.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseDemoTests.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | 13 | @interface FBSnapshotTestCaseDemoTests : FBSnapshotTestCase 14 | 15 | @end 16 | 17 | @implementation FBSnapshotTestCaseDemoTests 18 | 19 | - (void)setUp 20 | { 21 | [super setUp]; 22 | // Flip this to YES to record images in the reference image directory. 23 | // You need to do this the first time you create a test and whenever you change the snapshotted views. 24 | // Tests running in record mode will allways fail so that you know that you have to do something here before you commit. 25 | self.recordMode = NO; 26 | } 27 | 28 | - (void)testViewSnapshot 29 | { 30 | UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; 31 | redView.backgroundColor = [UIColor redColor]; 32 | FBSnapshotVerifyView(redView, nil); 33 | FBSnapshotVerifyLayer(redView.layer, nil); 34 | } 35 | 36 | - (void)testViewSnapshotWithVisualEffects 37 | { 38 | if ([UIVisualEffect class]) { 39 | UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; 40 | UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; 41 | UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 40)]; 42 | redView.backgroundColor = [UIColor redColor]; 43 | visualEffectView.frame = CGRectMake(0, 0, 40, 40); 44 | 45 | UIView *parentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; 46 | parentView.backgroundColor = [UIColor whiteColor]; 47 | [parentView addSubview:redView]; 48 | [parentView addSubview:visualEffectView]; 49 | 50 | self.usesDrawViewHierarchyInRect = YES; 51 | FBSnapshotVerifyView(parentView, nil); 52 | } 53 | } 54 | 55 | - (void)testViewSnapshotWithUIAppearance 56 | { 57 | [[UISwitch appearance] setOnTintColor:[UIColor blueColor]]; 58 | [[UISwitch appearance] setThumbTintColor:[UIColor lightGrayColor]]; 59 | UISwitch *control = [[UISwitch alloc] init]; 60 | control.on = YES; 61 | 62 | self.usesDrawViewHierarchyInRect = YES; 63 | FBSnapshotVerifyView(control, nil); 64 | } 65 | 66 | - (void)testViewSnapshotWithDifferentBackgroundColorPerArchitecture 67 | { 68 | UIColor *color = FBSnapshotTestCaseIs64Bit() ? [UIColor magentaColor] : [UIColor cyanColor]; 69 | 70 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; 71 | view.backgroundColor = color; 72 | FBSnapshotVerifyView(view, nil); 73 | } 74 | 75 | - (void)testViewSnapshotRecordedOnlyFor64BitArchitecture 76 | { 77 | UIView *greenView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; 78 | greenView.backgroundColor = [UIColor greenColor]; 79 | FBSnapshotVerifyView(greenView, nil); 80 | } 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/FBSnapshotTestCaseSwiftTests.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | import FBSnapshotTestCase 12 | 13 | class FBSnapshotTestCaseSwiftTest: FBSnapshotTestCase { 14 | override func setUp() { 15 | super.setUp() 16 | recordMode = false 17 | } 18 | 19 | func testExample() { 20 | let view = UIView(frame: CGRect(x: 0, y: 0, width: 64, height: 64)) 21 | view.backgroundColor = UIColor.blueColor() 22 | FBSnapshotVerifyView(view) 23 | FBSnapshotVerifyLayer(view.layer) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDemoTests.FBSnapshotTestCaseSwiftTest/testExample@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDemoTests.FBSnapshotTestCaseSwiftTest/testExample@2x.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDemoTests/testViewSnapshot@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDemoTests/testViewSnapshot@2x.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDemoTests/testViewSnapshotWithDifferentBackgroundColorPerArchitecture@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDemoTests/testViewSnapshotWithDifferentBackgroundColorPerArchitecture@2x.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDemoTests/testViewSnapshotWithUIAppearance@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDemoTests/testViewSnapshotWithUIAppearance@2x.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDemoTests/testViewSnapshotWithVisualEffects@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_32/FBSnapshotTestCaseDemoTests/testViewSnapshotWithVisualEffects@2x.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests.FBSnapshotTestCaseSwiftTest/testExample@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests.FBSnapshotTestCaseSwiftTest/testExample@2x.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshot@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshot@2x.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshotRecordedOnlyFor64BitArchitecture@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshotRecordedOnlyFor64BitArchitecture@2x.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshotWithDifferentBackgroundColorPerArchitecture@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshotWithDifferentBackgroundColorPerArchitecture@2x.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshotWithUIAppearance@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshotWithUIAppearance@2x.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshotWithVisualEffects@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/ReferenceImages_64/FBSnapshotTestCaseDemoTests/testViewSnapshotWithVisualEffects@2x.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/FBSnapshotTestCaseDemoTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | platform :ios, '8.0' 3 | 4 | use_frameworks! 5 | 6 | target :'FBSnapshotTestCaseDemoTests' do 7 | pod 'FBSnapshotTestCase', :path => '..' 8 | end 9 | 10 | 11 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FBSnapshotTestCase (2.0.5): 3 | - FBSnapshotTestCase/SwiftSupport (= 2.0.5) 4 | - FBSnapshotTestCase/Core (2.0.5) 5 | - FBSnapshotTestCase/SwiftSupport (2.0.5): 6 | - FBSnapshotTestCase/Core 7 | 8 | DEPENDENCIES: 9 | - FBSnapshotTestCase (from `..`) 10 | 11 | EXTERNAL SOURCES: 12 | FBSnapshotTestCase: 13 | :path: ".." 14 | 15 | SPEC CHECKSUMS: 16 | FBSnapshotTestCase: 6917deb01d0556dd544536f9eb34e0cf26f904d5 17 | 18 | COCOAPODS: 0.39.0 19 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/Scheme_FB_REFERENCE_IMAGE_DIR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseDemo/Scheme_FB_REFERENCE_IMAGE_DIR.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseTests/FBSnapshotControllerTests.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | */ 10 | 11 | #import 12 | #import "FBSnapshotTestController.h" 13 | #import "FBSnapshotTestCasePlatform.h" 14 | 15 | @interface FBSnapshotControllerTests : XCTestCase 16 | 17 | @end 18 | 19 | @implementation FBSnapshotControllerTests 20 | 21 | #pragma mark - Tests 22 | 23 | - (void)testCompareReferenceImageToImageShouldBeEqual 24 | { 25 | UIImage *referenceImage = [self _bundledImageNamed:@"square" type:@"png"]; 26 | XCTAssertNotNil(referenceImage); 27 | UIImage *testImage = [self _bundledImageNamed:@"square-copy" type:@"png"]; 28 | XCTAssertNotNil(testImage); 29 | 30 | FBSnapshotTestController *controller = [[FBSnapshotTestController alloc] initWithTestClass:nil]; 31 | XCTAssertTrue([controller compareReferenceImage:referenceImage toImage:testImage tolerance:0 error:nil]); 32 | } 33 | 34 | - (void)testCompareReferenceImageToImageShouldNotBeEqual 35 | { 36 | UIImage *referenceImage = [self _bundledImageNamed:@"square" type:@"png"]; 37 | XCTAssertNotNil(referenceImage); 38 | UIImage *testImage = [self _bundledImageNamed:@"square_with_text" type:@"png"]; 39 | XCTAssertNotNil(testImage); 40 | 41 | FBSnapshotTestController *controller = [[FBSnapshotTestController alloc] initWithTestClass:nil]; 42 | XCTAssertFalse([controller compareReferenceImage:referenceImage toImage:testImage tolerance:0 error:nil]); 43 | } 44 | 45 | - (void)testCompareReferenceImageWithVeryLowToleranceShouldNotMatch 46 | { 47 | UIImage *referenceImage = [self _bundledImageNamed:@"square" type:@"png"]; 48 | XCTAssertNotNil(referenceImage); 49 | UIImage *testImage = [self _bundledImageNamed:@"square_with_pixel" type:@"png"]; 50 | XCTAssertNotNil(testImage); 51 | 52 | FBSnapshotTestController *controller = [[FBSnapshotTestController alloc] initWithTestClass:nil]; 53 | // With virtually no margin for error, this should fail to be equal 54 | XCTAssertFalse([controller compareReferenceImage:referenceImage toImage:testImage tolerance:0.0001 error:nil]); 55 | } 56 | 57 | - (void)testCompareReferenceImageWithVeryLowToleranceShouldMatch 58 | { 59 | UIImage *referenceImage = [self _bundledImageNamed:@"square" type:@"png"]; 60 | XCTAssertNotNil(referenceImage); 61 | UIImage *testImage = [self _bundledImageNamed:@"square_with_pixel" type:@"png"]; 62 | XCTAssertNotNil(testImage); 63 | 64 | FBSnapshotTestController *controller = [[FBSnapshotTestController alloc] initWithTestClass:nil]; 65 | // With some tolerance these should be considered the same 66 | XCTAssertTrue([controller compareReferenceImage:referenceImage toImage:testImage tolerance:.001 error:nil]); 67 | } 68 | 69 | - (void)testFailedImageWithDeviceAgnosticShouldHaveModelOnName 70 | { 71 | UIImage *referenceImage = [self _bundledImageNamed:@"square" type:@"png"]; 72 | XCTAssertNotNil(referenceImage); 73 | UIImage *testImage = [self _bundledImageNamed:@"square_with_pixel" type:@"png"]; 74 | XCTAssertNotNil(testImage); 75 | 76 | FBSnapshotTestController *controller = [[FBSnapshotTestController alloc] initWithTestClass:nil]; 77 | [controller setDeviceAgnostic:YES]; 78 | [controller setReferenceImagesDirectory:@"/dev/null/"]; 79 | NSError *error = nil; 80 | SEL selector = @selector(isDeviceAgnostic); 81 | [controller referenceImageForSelector:selector identifier:@"" error:&error]; 82 | XCTAssertNotNil(error); 83 | NSString *deviceAgnosticReferencePath = FBDeviceAgnosticNormalizedFileName(NSStringFromSelector(selector)); 84 | XCTAssertTrue([(NSString *)[error.userInfo objectForKey:FBReferenceImageFilePathKey] containsString:deviceAgnosticReferencePath]); 85 | } 86 | 87 | #pragma mark - Private helper methods 88 | 89 | - (UIImage *)_bundledImageNamed:(NSString *)name type:(NSString *)type 90 | { 91 | NSBundle *bundle = [NSBundle bundleForClass:[self class]]; 92 | NSString *path = [bundle pathForResource:name ofType:type]; 93 | NSData *data = [[NSData alloc] initWithContentsOfFile:path]; 94 | return [[UIImage alloc] initWithData:data]; 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseTests/FBSnapshotTestCaseTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseTests/square-copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseTests/square-copy.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseTests/square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseTests/square.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseTests/square_with_pixel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseTests/square_with_pixel.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseTests/square_with_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/Carthage/Checkouts/ios-snapshot-test-case/FBSnapshotTestCaseTests/square_with_text.png -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/LICENSE: -------------------------------------------------------------------------------- 1 | BSD License 2 | 3 | For the FBSnapshotTestCase software 4 | 5 | Copyright (c) 2013, Facebook, Inc. 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | * Neither the name Facebook nor the names of its contributors may be used to 17 | endorse or promote products derived from this software without specific 18 | prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/PATENTS: -------------------------------------------------------------------------------- 1 | Additional Grant of Patent Rights Version 2 2 | 3 | "Software" means the FBSnapshotTestCase software distributed by Facebook, Inc. 4 | 5 | Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software 6 | ("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable 7 | (subject to the termination provision below) license under any Necessary 8 | Claims, to make, have made, use, sell, offer to sell, import, and otherwise 9 | transfer the Software. For avoidance of doubt, no license is granted under 10 | Facebook' rights in any patent claims that are infringed by (i) modifications 11 | to the Software made by you or any third party or (ii) the Software in 12 | combination with any software or other technology. 13 | 14 | The license granted hereunder will terminate, automatically and without notice, 15 | if you (or any of your subsidiaries, corporate affiliates or agents) initiate 16 | directly or indirectly, or take a direct financial interest in, any Patent 17 | Assertion: (i) against Facebook or any of its subsidiaries or corporate 18 | affiliates, (ii) against any party if such Patent Assertion arises in whole or 19 | in part from any software, technology, product or service of Facebook or any of 20 | its subsidiaries or corporate affiliates, or (iii) against any party relating 21 | to the Software. Notwithstanding the foregoing, if Facebook or any of its 22 | subsidiaries or corporate affiliates files a lawsuit alleging patent 23 | infringement against you in the first instance, and you respond by filing a 24 | patent infringement counterclaim in that lawsuit against that party that is 25 | unrelated to the Software, the license granted hereunder will not terminate 26 | under section (i) of this paragraph due to such counterclaim. 27 | 28 | A "Necessary Claim" is a claim of a patent owned by Facebook that is 29 | necessarily infringed by the Software standing alone. 30 | 31 | A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, 32 | or contributory infringement or inducement to infringe any patent, including a 33 | cross-claim or counterclaim. -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/README.md: -------------------------------------------------------------------------------- 1 | FBSnapshotTestCase 2 | ====================== 3 | 4 | [![Build Status](https://travis-ci.org/facebook/ios-snapshot-test-case.svg)](https://travis-ci.org/facebook/ios-snapshot-test-case) [![Cocoa Pod Version](https://cocoapod-badges.herokuapp.com/v/FBSnapshotTestCase/badge.svg)](http://cocoadocs.org/docsets/FBSnapshotTestCase/) 5 | 6 | What it does 7 | ------------ 8 | 9 | A "snapshot test case" takes a configured `UIView` or `CALayer` and uses the 10 | `renderInContext:` method to get an image snapshot of its contents. It 11 | compares this snapshot to a "reference image" stored in your source code 12 | repository and fails the test if the two images don't match. 13 | 14 | Why? 15 | ---- 16 | 17 | At Facebook we write a lot of UI code. As you might imagine, each type of 18 | feed story is rendered using a subclass of `UIView`. There are a lot of edge 19 | cases that we want to handle correctly: 20 | 21 | - What if there is more text than can fit in the space available? 22 | - What if an image doesn't match the size of an image view? 23 | - What should the highlighted state look like? 24 | 25 | It's straightforward to test logic code, but less obvious how you should test 26 | views. You can do a lot of rectangle asserts, but these are hard to understand 27 | or visualize. Looking at an image diff shows you exactly what changed and how 28 | it will look to users. 29 | 30 | We developed `FBSnapshotTestCase` to make snapshot tests easy. 31 | 32 | Installation with CocoaPods 33 | --------------------------- 34 | 35 | 1. Add the following lines to your Podfile: 36 | 37 | ``` 38 | target "Tests" do 39 | pod 'FBSnapshotTestCase' 40 | end 41 | ``` 42 | 43 | If you support iOS 7 use `FBSnapshotTestCase/Core` instead, which doesn't contain Swift support. 44 | 45 | Replace "Tests" with the name of your test project. 46 | 47 | 2. There are [three ways](https://github.com/facebook/ios-snapshot-test-case/blob/master/FBSnapshotTestCase/FBSnapshotTestCase.h#L19-L29) of setting reference image directories, the recommended one is to define `FB_REFERENCE_IMAGE_DIR` in your scheme. This should point to the directory where you want reference images to be stored. At Facebook, we normally use this: 48 | 49 | |Name|Value| 50 | |:---|:----| 51 | |`FB_REFERENCE_IMAGE_DIR`|`$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages`| 52 | 53 | 54 | ![](FBSnapshotTestCaseDemo/Scheme_FB_REFERENCE_IMAGE_DIR.png) 55 | 56 | Creating a snapshot test 57 | ------------------------ 58 | 59 | 1. Subclass `FBSnapshotTestCase` instead of `XCTestCase`. 60 | 2. From within your test, use `FBSnapshotVerifyView`. 61 | 3. Run the test once with `self.recordMode = YES;` in the test's `-setUp` 62 | method. (This creates the reference images on disk.) 63 | 4. Remove the line enabling record mode and run the test. 64 | 65 | Features 66 | -------- 67 | 68 | - Automatically names reference images on disk according to test class and 69 | selector. 70 | - Prints a descriptive error message to the console on failure. (Bonus: 71 | failure message includes a one-line command to see an image diff if 72 | you have [Kaleidoscope](http://www.kaleidoscopeapp.com) installed.) 73 | - Supply an optional "identifier" if you want to perform multiple snapshots 74 | in a single test method. 75 | - Support for `CALayer` via `FBSnapshotVerifyLayer`. 76 | - `usesDrawViewHierarchyInRect` to handle cases like `UIVisualEffect`, `UIAppearance` and Size Classes. 77 | - `isDeviceAgnostic` to allow appending the device model (`iPhone`, `iPad`, `iPod Touch`, etc), OS version and screen size to the images (allowing to have multiple tests for the same «snapshot» for different `OS`s and devices). 78 | 79 | Notes 80 | ----- 81 | 82 | Your unit test must be an "application test", not a "logic test." (That is, it 83 | must be run within the Simulator so that it has access to UIKit.) In Xcode 5 84 | and later new projects only offer application tests, but older projects will 85 | have separate targets for the two types. 86 | 87 | Authors 88 | ------- 89 | 90 | `FBSnapshotTestCase` was written at Facebook by 91 | [Jonathan Dann](https://facebook.com/j.p.dann) with significant contributions by 92 | [Todd Krabach](https://facebook.com/toddkrabach). 93 | 94 | License 95 | ------- 96 | 97 | `FBSnapshotTestCase` is BSD-licensed. See `LICENSE`. 98 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/SnapshotTest.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AllowedTypes 6 | 7 | public.objective-c-source 8 | 9 | Platforms 10 | 11 | com.apple.platform.iphoneos 12 | 13 | DefaultCompletionName 14 | SnapshotTest 15 | Description 16 | Test case using FBSnapshotTests 17 | Kind 18 | Xcode.IDEKit.TextSubstitutionFileTemplateKind 19 | MainTemplateFile 20 | ___FILEBASENAME___.m 21 | SortOrder 22 | 1 23 | Summary 24 | FBSnapshotTests 25 | Options 26 | 27 | 28 | Default 29 | 30 | Description 31 | Class Under Test 32 | Identifier 33 | cutClass 34 | Name 35 | Test case for class name 36 | Required 37 | 38 | NotPersisted 39 | 40 | Type 41 | text 42 | 43 | 44 | Default 45 | 46 | Description 47 | Property Name 48 | Identifier 49 | propName 50 | Name 51 | Property Name 52 | Required 53 | 54 | NotPersisted 55 | 56 | Type 57 | text 58 | 59 | 60 | Default 61 | ___VARIABLE_cutClass:identifier___SnapshotTests 62 | Identifier 63 | productName 64 | Type 65 | static 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/SnapshotTest.xctemplate/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILENAME___ 3 | // ___PROJECTNAME___ 4 | // 5 | // Created by ___FULLUSERNAME___ on ___DATE___. 6 | // Copyright ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved. 7 | // 8 | 9 | #import "___VARIABLE_cutClass:identifier___.h" 10 | #import "FBSnapshotTestCase.h" 11 | 12 | @interface ___VARIABLE_cutClass:identifier___SnapshotTests : FBSnapshotTestCase 13 | @property (nonatomic, strong) ___VARIABLE_cutClass:identifier___ *___VARIABLE_propName:identifier___; 14 | @end 15 | 16 | @implementation ___VARIABLE_cutClass:identifier___SnapshotTests 17 | 18 | - (void)setUp 19 | { 20 | [super setUp]; 21 | 22 | self.recordMode = YES; 23 | 24 | self.___VARIABLE_propName:identifier___ = [[___VARIABLE_cutClass:identifier___ alloc] init]; 25 | } 26 | 27 | - (void)tearDown 28 | { 29 | self.___VARIABLE_propName:identifier___ = nil; 30 | [super tearDown]; 31 | } 32 | 33 | - (void)test<#testnamehere#> 34 | { 35 | <# set up your view and add the data #> 36 | 37 | FBSnapshotVerifyView(self.___VARIABLE_propName:identifier___, nil); 38 | } 39 | 40 | @end -------------------------------------------------------------------------------- /Charts/Carthage/Checkouts/ios-snapshot-test-case/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | function ci_lib() { 6 | NAME=$1 7 | xcodebuild -project FBSnapshotTestCase.xcodeproj \ 8 | -scheme FBSnapshotTestCase \ 9 | -destination "platform=iOS Simulator,name=${NAME}" \ 10 | -sdk iphonesimulator \ 11 | build test 12 | } 13 | 14 | function ci_demo() { 15 | NAME=$1 16 | pushd FBSnapshotTestCaseDemo 17 | pod install 18 | xcodebuild -workspace FBSnapshotTestCaseDemo.xcworkspace \ 19 | -scheme FBSnapshotTestCaseDemo \ 20 | -destination "platform=iOS Simulator,name=${NAME}" \ 21 | build test 22 | popd 23 | } 24 | 25 | ci_lib "iPhone 5" && ci_demo "iPhone 5" 26 | ci_lib "iPhone 6" && ci_demo "iPhone 6" 27 | -------------------------------------------------------------------------------- /Charts/ChartsTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Charts/ChartsTests/LineChartTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import FBSnapshotTestCase 3 | @testable import Charts 4 | 5 | class LineChartTests: FBSnapshotTestCase 6 | { 7 | 8 | var chart: LineChartView! 9 | var dataSet: LineChartDataSet! 10 | 11 | override func setUp() 12 | { 13 | super.setUp() 14 | 15 | // Set to `true` to re-capture all snapshots 16 | self.recordMode = false 17 | 18 | // Sample data 19 | let values: [Double] = [8, 104, 81, 93, 52, 44, 97, 101, 75, 28, 20 | 76, 25, 20, 13, 52, 44, 57, 23, 45, 91, 21 | 99, 14, 84, 48, 40, 71, 106, 41, 45, 61] 22 | 23 | var entries: [ChartDataEntry] = Array() 24 | var xValues: [String] = Array() 25 | 26 | for (i, value) in values.enumerate() 27 | { 28 | entries.append(ChartDataEntry.init(value: value, xIndex: i)) 29 | xValues.append("\(i)") 30 | } 31 | 32 | dataSet = LineChartDataSet(yVals: entries, label: "First unit test data") 33 | 34 | chart = LineChartView(frame: CGRectMake(0, 0, 480, 350)) 35 | chart.data = LineChartData(xVals: xValues, dataSet: dataSet) 36 | } 37 | 38 | override func tearDown() 39 | { 40 | // Put teardown code here. This method is called after the invocation of each test method in the class. 41 | super.tearDown() 42 | } 43 | 44 | func testDefaultValues() 45 | { 46 | FBSnapshotVerifyView(chart) 47 | } 48 | 49 | func testHidesValues() 50 | { 51 | dataSet.drawValuesEnabled = false 52 | FBSnapshotVerifyView(chart) 53 | } 54 | 55 | func testDoesntDrawCircles() 56 | { 57 | dataSet.drawCirclesEnabled = false 58 | FBSnapshotVerifyView(chart) 59 | } 60 | 61 | func testIsCubic() 62 | { 63 | dataSet.drawCubicEnabled = true 64 | FBSnapshotVerifyView(chart) 65 | } 66 | 67 | func testDoesntDrawCircleHole() 68 | { 69 | dataSet.drawCircleHoleEnabled = false 70 | FBSnapshotVerifyView(chart) 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_32/ChartsTests.LineChartTests/testDefaultValues@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_32/ChartsTests.LineChartTests/testDefaultValues@2x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircleHole@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircleHole@2x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircles@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_32/ChartsTests.LineChartTests/testDoesntDrawCircles@2x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_32/ChartsTests.LineChartTests/testHidesValues@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_32/ChartsTests.LineChartTests/testHidesValues@2x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_32/ChartsTests.LineChartTests/testIsCubic@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_32/ChartsTests.LineChartTests/testIsCubic@2x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues@2x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testDefaultValues@3x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole@2x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircleHole@3x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles@2x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testDoesntDrawCircles@3x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues@2x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testHidesValues@3x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic@2x.png -------------------------------------------------------------------------------- /Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/Charts/ChartsTests/ReferenceImages_64/ChartsTests.LineChartTests/testIsCubic@3x.png -------------------------------------------------------------------------------- /Charts/Classes/Charts/BubbleChartView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BubbleChartView.swift 3 | // Charts 4 | // 5 | // Bubble chart implementation: 6 | // Copyright 2015 Pierre-Marc Airoldi 7 | // Licensed under Apache License 2.0 8 | // 9 | // https://github.com/danielgindi/ios-charts 10 | // 11 | 12 | import Foundation 13 | import CoreGraphics 14 | 15 | public class BubbleChartView: BarLineChartViewBase, BubbleChartDataProvider 16 | { 17 | public override func initialize() 18 | { 19 | super.initialize() 20 | 21 | renderer = BubbleChartRenderer(dataProvider: self, animator: _animator, viewPortHandler: _viewPortHandler) 22 | } 23 | 24 | public override func calcMinMax() 25 | { 26 | super.calcMinMax() 27 | 28 | if (_deltaX == 0.0 && _data.yValCount > 0) 29 | { 30 | _deltaX = 1.0 31 | } 32 | 33 | _chartXMin = -0.5 34 | _chartXMax = Double(_data.xVals.count) - 0.5 35 | 36 | if renderer as? BubbleChartRenderer !== nil, 37 | let sets = _data.dataSets as? [BubbleChartDataSet] 38 | { 39 | for set in sets { 40 | 41 | let xmin = set.xMin 42 | let xmax = set.xMax 43 | 44 | if (xmin < _chartXMin) 45 | { 46 | _chartXMin = xmin 47 | } 48 | 49 | if (xmax > _chartXMax) 50 | { 51 | _chartXMax = xmax 52 | } 53 | } 54 | } 55 | 56 | _deltaX = CGFloat(abs(_chartXMax - _chartXMin)) 57 | } 58 | 59 | // MARK: - BubbleChartDataProbider 60 | 61 | public var bubbleData: BubbleChartData? { return _data as? BubbleChartData } 62 | } -------------------------------------------------------------------------------- /Charts/Classes/Charts/CandleStickChartView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CandleStickChartView.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 4/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | /// Financial chart type that draws candle-sticks. 18 | public class CandleStickChartView: BarLineChartViewBase, CandleChartDataProvider 19 | { 20 | internal override func initialize() 21 | { 22 | super.initialize() 23 | 24 | renderer = CandleStickChartRenderer(dataProvider: self, animator: _animator, viewPortHandler: _viewPortHandler) 25 | _chartXMin = -0.5 26 | } 27 | 28 | internal override func calcMinMax() 29 | { 30 | super.calcMinMax() 31 | 32 | _chartXMax += 0.5 33 | _deltaX = CGFloat(abs(_chartXMax - _chartXMin)) 34 | } 35 | 36 | // MARK: - CandleChartDataProvider 37 | 38 | public var candleData: CandleChartData? 39 | { 40 | return _data as? CandleChartData 41 | } 42 | } -------------------------------------------------------------------------------- /Charts/Classes/Charts/LineChartView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LineChartView.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 4/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | /// Chart that draws lines, surfaces, circles, ... 18 | public class LineChartView: BarLineChartViewBase, LineChartDataProvider 19 | { 20 | internal override func initialize() 21 | { 22 | super.initialize() 23 | 24 | renderer = LineChartRenderer(dataProvider: self, animator: _animator, viewPortHandler: _viewPortHandler) 25 | } 26 | 27 | internal override func calcMinMax() 28 | { 29 | super.calcMinMax() 30 | 31 | if (_deltaX == 0.0 && _data.yValCount > 0) 32 | { 33 | _deltaX = 1.0 34 | } 35 | } 36 | 37 | // MARK: - LineChartDataProvider 38 | 39 | public var lineData: LineChartData? { return _data as? LineChartData } 40 | } -------------------------------------------------------------------------------- /Charts/Classes/Charts/ScatterChartView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScatterChartView.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 4/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | /// The ScatterChart. Draws dots, triangles, squares and custom shapes into the chartview. 18 | public class ScatterChartView: BarLineChartViewBase, ScatterChartDataProvider 19 | { 20 | public override func initialize() 21 | { 22 | super.initialize() 23 | 24 | renderer = ScatterChartRenderer(dataProvider: self, animator: _animator, viewPortHandler: _viewPortHandler) 25 | _chartXMin = -0.5 26 | } 27 | 28 | public override func calcMinMax() 29 | { 30 | super.calcMinMax() 31 | 32 | if (_deltaX == 0.0 && _data.yValCount > 0) 33 | { 34 | _deltaX = 1.0 35 | } 36 | 37 | _chartXMax += 0.5 38 | _deltaX = CGFloat(abs(_chartXMax - _chartXMin)) 39 | } 40 | 41 | // MARK: - ScatterChartDataProbider 42 | 43 | public var scatterData: ScatterChartData? { return _data as? ScatterChartData } 44 | } -------------------------------------------------------------------------------- /Charts/Classes/Components/ChartAxisBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartAxisBase.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 23/2/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | import UIKit 17 | 18 | public class ChartAxisBase: ChartComponentBase 19 | { 20 | public var labelFont = UIFont.systemFontOfSize(10.0) 21 | public var labelTextColor = UIColor.blackColor() 22 | 23 | public var subtitleFont = UIFont.systemFontOfSize(10.0) 24 | public var subtitleTextColor = UIColor.blackColor() 25 | 26 | public var selectedLabelFont = UIFont.systemFontOfSize(10.0) 27 | public var selectedLabelTextColor = UIColor.blackColor() 28 | 29 | public var selectedSubtitleFont = UIFont.systemFontOfSize(10.0) 30 | public var selectedSubtitleTextColor = UIColor.blackColor() 31 | 32 | public var axisLineColor = UIColor.grayColor() 33 | public var axisLineWidth = CGFloat(0.5) 34 | public var axisLineDashPhase = CGFloat(0.0) 35 | public var axisLineDashLengths: [CGFloat]! 36 | 37 | public var gridColor = UIColor.grayColor().colorWithAlphaComponent(0.9) 38 | public var gridLineWidth = CGFloat(0.5) 39 | public var gridLineDashPhase = CGFloat(0.0) 40 | public var gridLineDashLengths: [CGFloat]! 41 | 42 | public var drawGridLinesEnabled = true 43 | public var drawAxisLineEnabled = true 44 | 45 | /// flag that indicates of the labels of this axis should be drawn or not 46 | public var drawLabelsEnabled = true 47 | 48 | /// array of limitlines that can be set for the axis 49 | private var _limitLines = [ChartLimitLine]() 50 | 51 | /// Are the LimitLines drawn behind the data or in front of the data? 52 | /// 53 | /// **default**: false 54 | public var drawLimitLinesBehindDataEnabled = false 55 | 56 | /// the flag can be used to turn off the antialias for grid lines 57 | public var gridAntialiasEnabled = true 58 | 59 | public override init() 60 | { 61 | super.init() 62 | } 63 | 64 | public func getLongestLabel() -> String 65 | { 66 | fatalError("getLongestLabel() cannot be called on ChartAxisBase") 67 | } 68 | 69 | public var isDrawGridLinesEnabled: Bool { return drawGridLinesEnabled; } 70 | 71 | public var isDrawAxisLineEnabled: Bool { return drawAxisLineEnabled; } 72 | 73 | public var isDrawLabelsEnabled: Bool { return drawLabelsEnabled; } 74 | 75 | /// Are the LimitLines drawn behind the data or in front of the data? 76 | /// 77 | /// **default**: false 78 | public var isDrawLimitLinesBehindDataEnabled: Bool { return drawLimitLinesBehindDataEnabled; } 79 | 80 | /// Adds a new ChartLimitLine to this axis. 81 | public func addLimitLine(line: ChartLimitLine) 82 | { 83 | _limitLines.append(line) 84 | } 85 | 86 | /// Removes the specified ChartLimitLine from the axis. 87 | public func removeLimitLine(line: ChartLimitLine) 88 | { 89 | for (var i = 0; i < _limitLines.count; i++) 90 | { 91 | if (_limitLines[i] === line) 92 | { 93 | _limitLines.removeAtIndex(i) 94 | return 95 | } 96 | } 97 | } 98 | 99 | /// Removes all LimitLines from the axis. 100 | public func removeAllLimitLines() 101 | { 102 | _limitLines.removeAll(keepCapacity: false) 103 | } 104 | 105 | /// - returns: the LimitLines of this axis. 106 | public var limitLines : [ChartLimitLine] 107 | { 108 | return _limitLines 109 | } 110 | } -------------------------------------------------------------------------------- /Charts/Classes/Components/ChartComponentBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartComponentBase.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 16/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import UIKit 16 | 17 | /// This class encapsulates everything both Axis, Legend and LimitLines have in common 18 | public class ChartComponentBase: NSObject 19 | { 20 | /// flag that indicates if this component is enabled or not 21 | public var enabled = true 22 | 23 | /// Sets the used x-axis offset for the labels on this axis. 24 | /// **default**: 5.0 25 | public var xOffset = CGFloat(5.0) 26 | 27 | /// Sets the used y-axis offset for the labels on this axis. 28 | /// **default**: 5.0 (or 0.0 on ChartYAxis) 29 | public var yOffset = CGFloat(5.0) 30 | 31 | public override init() 32 | { 33 | super.init() 34 | } 35 | 36 | public var isEnabled: Bool { return enabled; } 37 | } 38 | -------------------------------------------------------------------------------- /Charts/Classes/Components/ChartLimitLine.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartLimitLine.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 23/2/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | import UIKit 17 | 18 | /// The limit line is an additional feature for all Line, Bar and ScatterCharts. 19 | /// It allows the displaying of an additional line in the chart that marks a certain maximum / limit on the specified axis (x- or y-axis). 20 | public class ChartLimitLine: ChartComponentBase 21 | { 22 | @objc 23 | public enum ChartLimitLabelPosition: Int 24 | { 25 | case LeftTop 26 | case LeftBottom 27 | case RightTop 28 | case RightBottom 29 | } 30 | 31 | /// limit / maximum (the y-value or xIndex) 32 | public var limit = Double(0.0) 33 | 34 | private var _lineWidth = CGFloat(2.0) 35 | public var lineColor = UIColor(red: 237.0/255.0, green: 91.0/255.0, blue: 91.0/255.0, alpha: 1.0) 36 | public var lineDashPhase = CGFloat(0.0) 37 | public var lineDashLengths: [CGFloat]? 38 | public var valueTextColor = UIColor.blackColor() 39 | public var valueFont = UIFont.systemFontOfSize(13.0) 40 | public var label = "" 41 | public var labelPosition = ChartLimitLabelPosition.RightTop 42 | 43 | public override init() 44 | { 45 | super.init() 46 | } 47 | 48 | public init(limit: Double) 49 | { 50 | super.init() 51 | self.limit = limit 52 | } 53 | 54 | public init(limit: Double, label: String) 55 | { 56 | super.init() 57 | self.limit = limit 58 | self.label = label 59 | } 60 | 61 | /// set the line width of the chart (min = 0.2, max = 12); default 2 62 | public var lineWidth: CGFloat 63 | { 64 | get 65 | { 66 | return _lineWidth 67 | } 68 | set 69 | { 70 | if (newValue < 0.2) 71 | { 72 | _lineWidth = 0.2 73 | } 74 | else if (newValue > 12.0) 75 | { 76 | _lineWidth = 12.0 77 | } 78 | else 79 | { 80 | _lineWidth = newValue 81 | } 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /Charts/Classes/Components/ChartMarker.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartMarker.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 3/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import UIKit 16 | 17 | public class ChartMarker: ChartComponentBase 18 | { 19 | /// The marker image to render 20 | public var image: UIImage? 21 | 22 | /// Use this to return the desired offset you wish the MarkerView to have on the x-axis. 23 | public var offset: CGPoint = CGPoint() 24 | 25 | /// The marker's size 26 | public var size: CGSize 27 | { 28 | get 29 | { 30 | return image!.size 31 | } 32 | } 33 | 34 | public override init() 35 | { 36 | super.init() 37 | } 38 | 39 | /// Returns the offset for drawing at the specific `point` 40 | /// 41 | /// - parameter point: This is the point at which the marker wants to be drawn. You can adjust the offset conditionally based on this argument. 42 | /// - By default returns the self.offset property. You can return any other value to override that. 43 | public func offsetForDrawingAtPos(point: CGPoint) -> CGPoint 44 | { 45 | return offset; 46 | } 47 | 48 | /// Draws the ChartMarker on the given position on the given context 49 | public func draw(context context: CGContext, point: CGPoint) 50 | { 51 | let offset = self.offsetForDrawingAtPos(point) 52 | let size = self.size 53 | 54 | let rect = CGRect(x: point.x + offset.x, y: point.y + offset.y, width: size.width, height: size.height) 55 | 56 | UIGraphicsPushContext(context) 57 | image!.drawInRect(rect) 58 | UIGraphicsPopContext() 59 | } 60 | 61 | /// This method enables a custom ChartMarker to update it's content everytime the MarkerView is redrawn according to the data entry it points to. 62 | /// 63 | /// - parameter highlight: the highlight object contains information about the highlighted value such as it's dataset-index, the selected range or stack-index (only stacked bar entries). 64 | public func refreshContent(entry entry: ChartDataEntry, highlight: ChartHighlight) 65 | { 66 | // Do nothing here... 67 | } 68 | } -------------------------------------------------------------------------------- /Charts/Classes/Data/BarChartData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BarChartData.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | public class BarChartData: BarLineScatterCandleBubbleChartData 18 | { 19 | public override init() 20 | { 21 | super.init() 22 | } 23 | 24 | public override init(xVals: [String?]?, dataSets: [ChartDataSet]?) 25 | { 26 | super.init(xVals: xVals, dataSets: dataSets) 27 | } 28 | 29 | public override init(xVals: [NSObject]?, dataSets: [ChartDataSet]?) 30 | { 31 | super.init(xVals: xVals, dataSets: dataSets) 32 | } 33 | 34 | private var _groupSpace = CGFloat(0.8) 35 | 36 | /// The spacing is relative to a full bar width 37 | public var groupSpace: CGFloat 38 | { 39 | get 40 | { 41 | if (_dataSets.count <= 1) 42 | { 43 | return 0.0 44 | } 45 | return _groupSpace 46 | } 47 | set 48 | { 49 | _groupSpace = newValue 50 | } 51 | } 52 | 53 | /// - returns: true if this BarData object contains grouped DataSets (more than 1 DataSet). 54 | public var isGrouped: Bool 55 | { 56 | return _dataSets.count > 1 ? true : false 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Charts/Classes/Data/BarLineScatterCandleBubbleChartData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BarLineScatterCandleBubbleChartData.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | 16 | public class BarLineScatterCandleBubbleChartData: ChartData 17 | { 18 | public override init() 19 | { 20 | super.init() 21 | } 22 | 23 | public override init(xVals: [String?]?, dataSets: [ChartDataSet]?) 24 | { 25 | super.init(xVals: xVals, dataSets: dataSets) 26 | } 27 | 28 | public override init(xVals: [NSObject]?, dataSets: [ChartDataSet]?) 29 | { 30 | super.init(xVals: xVals, dataSets: dataSets) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Charts/Classes/Data/BarLineScatterCandleBubbleChartDataSet.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BarLineScatterCandleBubbleChartDataSet.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import UIKit 16 | 17 | public class BarLineScatterCandleBubbleChartDataSet: ChartDataSet 18 | { 19 | public var highlightColor = UIColor(red: 255.0/255.0, green: 187.0/255.0, blue: 115.0/255.0, alpha: 1.0) 20 | public var highlightLineWidth = CGFloat(0.5) 21 | public var highlightLineDashPhase = CGFloat(0.0) 22 | public var highlightLineDashLengths: [CGFloat]? 23 | 24 | // MARK: NSCopying 25 | 26 | public override func copyWithZone(zone: NSZone) -> AnyObject 27 | { 28 | let copy = super.copyWithZone(zone) as! BarLineScatterCandleBubbleChartDataSet 29 | copy.highlightColor = highlightColor 30 | copy.highlightLineWidth = highlightLineWidth 31 | copy.highlightLineDashPhase = highlightLineDashPhase 32 | copy.highlightLineDashLengths = highlightLineDashLengths 33 | return copy 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Charts/Classes/Data/BubbleChartData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BubbleChartData.swift 3 | // Charts 4 | // 5 | // Bubble chart implementation: 6 | // Copyright 2015 Pierre-Marc Airoldi 7 | // Licensed under Apache License 2.0 8 | // 9 | // https://github.com/danielgindi/ios-charts 10 | // 11 | 12 | import Foundation 13 | import CoreGraphics 14 | 15 | public class BubbleChartData: BarLineScatterCandleBubbleChartData 16 | { 17 | public override init() 18 | { 19 | super.init() 20 | } 21 | 22 | public override init(xVals: [String?]?, dataSets: [ChartDataSet]?) 23 | { 24 | super.init(xVals: xVals, dataSets: dataSets) 25 | } 26 | 27 | public override init(xVals: [NSObject]?, dataSets: [ChartDataSet]?) 28 | { 29 | super.init(xVals: xVals, dataSets: dataSets) 30 | } 31 | 32 | /// Sets the width of the circle that surrounds the bubble when highlighted for all DataSet objects this data object contains 33 | public func setHighlightCircleWidth(width: CGFloat) 34 | { 35 | for set in _dataSets as! [BubbleChartDataSet]! 36 | { 37 | set.highlightCircleWidth = width 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Charts/Classes/Data/BubbleChartDataEntry.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BubbleDataEntry.swift 3 | // Charts 4 | // 5 | // Bubble chart implementation: 6 | // Copyright 2015 Pierre-Marc Airoldi 7 | // Licensed under Apache License 2.0 8 | // 9 | // https://github.com/danielgindi/ios-charts 10 | // 11 | 12 | import Foundation 13 | import CoreGraphics 14 | 15 | public class BubbleChartDataEntry: ChartDataEntry 16 | { 17 | /// The size of the bubble. 18 | public var size = CGFloat(0.0) 19 | 20 | public required init() 21 | { 22 | super.init() 23 | } 24 | 25 | /// - parameter xIndex: The index on the x-axis. 26 | /// - parameter val: The value on the y-axis. 27 | /// - parameter size: The size of the bubble. 28 | public init(xIndex: Int, value: Double, size: CGFloat) 29 | { 30 | super.init(value: value, xIndex: xIndex) 31 | 32 | self.size = size 33 | } 34 | 35 | /// - parameter xIndex: The index on the x-axis. 36 | /// - parameter val: The value on the y-axis. 37 | /// - parameter size: The size of the bubble. 38 | /// - parameter data: Spot for additional data this Entry represents. 39 | public init(xIndex: Int, value: Double, size: CGFloat, data: AnyObject?) 40 | { 41 | super.init(value: value, xIndex: xIndex, data: data) 42 | 43 | self.size = size 44 | } 45 | 46 | // MARK: NSCopying 47 | 48 | public override func copyWithZone(zone: NSZone) -> AnyObject 49 | { 50 | let copy = super.copyWithZone(zone) as! BubbleChartDataEntry 51 | copy.size = size 52 | return copy 53 | } 54 | } -------------------------------------------------------------------------------- /Charts/Classes/Data/BubbleChartDataSet.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BubbleChartDataSet.swift 3 | // Charts 4 | // 5 | // Bubble chart implementation: 6 | // Copyright 2015 Pierre-Marc Airoldi 7 | // Licensed under Apache License 2.0 8 | // 9 | // https://github.com/danielgindi/ios-charts 10 | // 11 | 12 | import Foundation 13 | import CoreGraphics 14 | import UIKit 15 | 16 | public class BubbleChartDataSet: BarLineScatterCandleBubbleChartDataSet 17 | { 18 | internal var _xMax = Double(0.0) 19 | internal var _xMin = Double(0.0) 20 | internal var _maxSize = CGFloat(0.0) 21 | 22 | public var xMin: Double { return _xMin } 23 | public var xMax: Double { return _xMax } 24 | public var maxSize: CGFloat { return _maxSize } 25 | 26 | public func setColor(color: UIColor, alpha: CGFloat) 27 | { 28 | super.setColor(color.colorWithAlphaComponent(alpha)) 29 | } 30 | 31 | internal override func calcMinMax(start start: Int, end: Int) 32 | { 33 | if (yVals.count == 0) 34 | { 35 | return 36 | } 37 | 38 | let entries = yVals as! [BubbleChartDataEntry] 39 | 40 | // need chart width to guess this properly 41 | 42 | var endValue : Int 43 | 44 | if end == 0 45 | { 46 | endValue = entries.count - 1 47 | } 48 | else 49 | { 50 | endValue = end 51 | } 52 | 53 | _lastStart = start 54 | _lastEnd = end 55 | 56 | _yMin = yMin(entries[start]) 57 | _yMax = yMax(entries[start]) 58 | 59 | for (var i = start; i <= endValue; i++) 60 | { 61 | let entry = entries[i] 62 | 63 | let ymin = yMin(entry) 64 | let ymax = yMax(entry) 65 | 66 | if (ymin < _yMin) 67 | { 68 | _yMin = ymin 69 | } 70 | 71 | if (ymax > _yMax) 72 | { 73 | _yMax = ymax 74 | } 75 | 76 | let xmin = xMin(entry) 77 | let xmax = xMax(entry) 78 | 79 | if (xmin < _xMin) 80 | { 81 | _xMin = xmin 82 | } 83 | 84 | if (xmax > _xMax) 85 | { 86 | _xMax = xmax 87 | } 88 | 89 | let size = largestSize(entry) 90 | 91 | if (size > _maxSize) 92 | { 93 | _maxSize = size 94 | } 95 | } 96 | } 97 | 98 | /// Sets/gets the width of the circle that surrounds the bubble when highlighted 99 | public var highlightCircleWidth: CGFloat = 2.5 100 | 101 | private func yMin(entry: BubbleChartDataEntry) -> Double 102 | { 103 | return entry.value 104 | } 105 | 106 | private func yMax(entry: BubbleChartDataEntry) -> Double 107 | { 108 | return entry.value 109 | } 110 | 111 | private func xMin(entry: BubbleChartDataEntry) -> Double 112 | { 113 | return Double(entry.xIndex) 114 | } 115 | 116 | private func xMax(entry: BubbleChartDataEntry) -> Double 117 | { 118 | return Double(entry.xIndex) 119 | } 120 | 121 | private func largestSize(entry: BubbleChartDataEntry) -> CGFloat 122 | { 123 | return entry.size 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /Charts/Classes/Data/CandleChartData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CandleChartData.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | 16 | public class CandleChartData: BarLineScatterCandleBubbleChartData 17 | { 18 | public override init() 19 | { 20 | super.init() 21 | } 22 | 23 | public override init(xVals: [String?]?, dataSets: [ChartDataSet]?) 24 | { 25 | super.init(xVals: xVals, dataSets: dataSets) 26 | } 27 | 28 | public override init(xVals: [NSObject]?, dataSets: [ChartDataSet]?) 29 | { 30 | super.init(xVals: xVals, dataSets: dataSets) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Charts/Classes/Data/CandleChartDataEntry.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CandleChartDataEntry.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 4/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | 16 | public class CandleChartDataEntry: ChartDataEntry 17 | { 18 | /// shadow-high value 19 | public var high = Double(0.0) 20 | 21 | /// shadow-low value 22 | public var low = Double(0.0) 23 | 24 | /// close value 25 | public var close = Double(0.0) 26 | 27 | /// open value 28 | public var open = Double(0.0) 29 | 30 | public required init() 31 | { 32 | super.init() 33 | } 34 | 35 | public init(xIndex: Int, shadowH: Double, shadowL: Double, open: Double, close: Double) 36 | { 37 | super.init(value: (shadowH + shadowL) / 2.0, xIndex: xIndex) 38 | 39 | self.high = shadowH 40 | self.low = shadowL 41 | self.open = open 42 | self.close = close 43 | } 44 | 45 | public init(xIndex: Int, shadowH: Double, shadowL: Double, open: Double, close: Double, data: AnyObject?) 46 | { 47 | super.init(value: (shadowH + shadowL) / 2.0, xIndex: xIndex, data: data) 48 | 49 | self.high = shadowH 50 | self.low = shadowL 51 | self.open = open 52 | self.close = close 53 | } 54 | 55 | /// - returns: the overall range (difference) between shadow-high and shadow-low. 56 | public var shadowRange: Double 57 | { 58 | return abs(high - low) 59 | } 60 | 61 | /// - returns: the body size (difference between open and close). 62 | public var bodyRange: Double 63 | { 64 | return abs(open - close) 65 | } 66 | 67 | /// the center value of the candle. (Middle value between high and low) 68 | public override var value: Double 69 | { 70 | get 71 | { 72 | return super.value 73 | } 74 | set 75 | { 76 | super.value = (high + low) / 2.0 77 | } 78 | } 79 | 80 | // MARK: NSCopying 81 | 82 | public override func copyWithZone(zone: NSZone) -> AnyObject 83 | { 84 | let copy = super.copyWithZone(zone) as! CandleChartDataEntry 85 | copy.high = high 86 | copy.high = low 87 | copy.high = open 88 | copy.high = close 89 | return copy 90 | } 91 | } -------------------------------------------------------------------------------- /Charts/Classes/Data/CandleChartDataSet.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CandleChartDataSet.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 4/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | import UIKit 17 | 18 | public class CandleChartDataSet: LineScatterCandleChartDataSet 19 | { 20 | /// the width of the candle-shadow-line in pixels. 21 | /// 22 | /// **default**: 3.0 23 | public var shadowWidth = CGFloat(1.5) 24 | 25 | /// the space between the candle entries 26 | /// 27 | /// **default**: 0.1 (10%) 28 | private var _bodySpace = CGFloat(0.1) 29 | 30 | /// the color of the shadow line 31 | public var shadowColor: UIColor? 32 | 33 | /// use candle color for the shadow 34 | public var shadowColorSameAsCandle = false 35 | 36 | /// color for open <= close 37 | public var decreasingColor: UIColor? 38 | 39 | /// color for open > close 40 | public var increasingColor: UIColor? 41 | 42 | /// Are decreasing values drawn as filled? 43 | public var decreasingFilled = false 44 | 45 | /// Are increasing values drawn as filled? 46 | public var increasingFilled = true 47 | 48 | public required init() 49 | { 50 | super.init() 51 | } 52 | 53 | public override init(yVals: [ChartDataEntry]?, label: String?) 54 | { 55 | super.init(yVals: yVals, label: label) 56 | } 57 | 58 | internal override func calcMinMax(start start: Int, end: Int) 59 | { 60 | if (yVals.count == 0) 61 | { 62 | return 63 | } 64 | 65 | var entries = yVals as! [CandleChartDataEntry] 66 | 67 | var endValue : Int 68 | 69 | if end == 0 || end >= entries.count 70 | { 71 | endValue = entries.count - 1 72 | } 73 | else 74 | { 75 | endValue = end 76 | } 77 | 78 | _lastStart = start 79 | _lastEnd = end 80 | 81 | _yMin = DBL_MAX 82 | _yMax = -DBL_MAX 83 | 84 | for (var i = start; i <= endValue; i++) 85 | { 86 | let e = entries[i] 87 | 88 | if (e.low < _yMin) 89 | { 90 | _yMin = e.low 91 | } 92 | 93 | if (e.high > _yMax) 94 | { 95 | _yMax = e.high 96 | } 97 | } 98 | } 99 | 100 | /// the space that is left out on the left and right side of each candle, 101 | /// **default**: 0.1 (10%), max 0.45, min 0.0 102 | public var bodySpace: CGFloat 103 | { 104 | set 105 | { 106 | if (newValue < 0.0) 107 | { 108 | _bodySpace = 0.0 109 | } 110 | else if (newValue > 0.45) 111 | { 112 | _bodySpace = 0.45 113 | } 114 | else 115 | { 116 | _bodySpace = newValue 117 | } 118 | } 119 | get 120 | { 121 | return _bodySpace 122 | } 123 | } 124 | 125 | /// Is the shadow color same as the candle color? 126 | public var isShadowColorSameAsCandle: Bool { return shadowColorSameAsCandle } 127 | 128 | /// Are increasing values drawn as filled? 129 | public var isIncreasingFilled: Bool { return increasingFilled; } 130 | 131 | /// Are decreasing values drawn as filled? 132 | public var isDecreasingFilled: Bool { return decreasingFilled; } 133 | } -------------------------------------------------------------------------------- /Charts/Classes/Data/ChartDataEntry.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartDataEntry.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 23/2/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | 17 | public class ChartDataEntry: NSObject 18 | { 19 | /// the actual value (y axis) 20 | public var value = Double(0.0) 21 | 22 | /// the index on the x-axis 23 | public var xIndex = Int(0) 24 | 25 | /// optional spot for additional data this Entry represents 26 | public var data: AnyObject? 27 | 28 | public override required init() 29 | { 30 | super.init() 31 | } 32 | 33 | public init(value: Double, xIndex: Int) 34 | { 35 | super.init() 36 | 37 | self.value = value 38 | self.xIndex = xIndex 39 | } 40 | 41 | public init(value: Double, xIndex: Int, data: AnyObject?) 42 | { 43 | super.init() 44 | 45 | self.value = value 46 | self.xIndex = xIndex 47 | self.data = data 48 | } 49 | 50 | // MARK: NSObject 51 | 52 | public override func isEqual(object: AnyObject?) -> Bool 53 | { 54 | if (object === nil) 55 | { 56 | return false 57 | } 58 | 59 | if (!object!.isKindOfClass(self.dynamicType)) 60 | { 61 | return false 62 | } 63 | 64 | if (object!.data !== data && !object!.data.isEqual(self.data)) 65 | { 66 | return false 67 | } 68 | 69 | if (object!.xIndex != xIndex) 70 | { 71 | return false 72 | } 73 | 74 | if (fabs(object!.value - value) > 0.00001) 75 | { 76 | return false 77 | } 78 | 79 | return true 80 | } 81 | 82 | // MARK: NSObject 83 | 84 | public override var description: String 85 | { 86 | return "ChartDataEntry, xIndex: \(xIndex), value \(value)" 87 | } 88 | 89 | // MARK: NSCopying 90 | 91 | public func copyWithZone(zone: NSZone) -> AnyObject 92 | { 93 | let copy = self.dynamicType.init() 94 | 95 | copy.value = value 96 | copy.xIndex = xIndex 97 | copy.data = data 98 | 99 | return copy 100 | } 101 | } 102 | 103 | public func ==(lhs: ChartDataEntry, rhs: ChartDataEntry) -> Bool 104 | { 105 | if (lhs === rhs) 106 | { 107 | return true 108 | } 109 | 110 | if (!lhs.isKindOfClass(rhs.dynamicType)) 111 | { 112 | return false 113 | } 114 | 115 | if (lhs.data !== rhs.data && !lhs.data!.isEqual(rhs.data)) 116 | { 117 | return false 118 | } 119 | 120 | if (lhs.xIndex != rhs.xIndex) 121 | { 122 | return false 123 | } 124 | 125 | if (fabs(lhs.value - rhs.value) > 0.00001) 126 | { 127 | return false 128 | } 129 | 130 | return true 131 | } -------------------------------------------------------------------------------- /Charts/Classes/Data/LineChartData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LineChartData.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | 16 | /// Data object that encapsulates all data associated with a LineChart. 17 | public class LineChartData: ChartData 18 | { 19 | public override init() 20 | { 21 | super.init() 22 | } 23 | 24 | public override init(xVals: [String?]?, dataSets: [ChartDataSet]?) 25 | { 26 | super.init(xVals: xVals, dataSets: dataSets) 27 | } 28 | 29 | public override init(xVals: [NSObject]?, dataSets: [ChartDataSet]?) 30 | { 31 | super.init(xVals: xVals, dataSets: dataSets) 32 | } 33 | 34 | public convenience init(xVals: [NSObject]?, dataSets: [ChartDataSet]?, subtitles: [String?]) { 35 | self.init(xVals: xVals, dataSets: dataSets) 36 | _xSubtitles = subtitles 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Charts/Classes/Data/LineRadarChartDataSet.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LineRadarChartDataSet.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | import UIKit 17 | 18 | public class LineRadarChartDataSet: LineScatterCandleChartDataSet 19 | { 20 | public var fillColor = UIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0) 21 | public var fillAlpha = CGFloat(0.33) 22 | private var _lineWidth = CGFloat(1.0) 23 | public var drawFilledEnabled = false 24 | 25 | /// line width of the chart (min = 0.2, max = 10) 26 | /// 27 | /// **default**: 1 28 | public var lineWidth: CGFloat 29 | { 30 | get 31 | { 32 | return _lineWidth 33 | } 34 | set 35 | { 36 | if (newValue < 0.2) 37 | { 38 | _lineWidth = 0.2 39 | } 40 | else if (newValue > 10.0) 41 | { 42 | _lineWidth = 10.0 43 | } 44 | else 45 | { 46 | _lineWidth = newValue 47 | } 48 | } 49 | } 50 | 51 | public var isDrawFilledEnabled: Bool 52 | { 53 | return drawFilledEnabled 54 | } 55 | 56 | // MARK: NSCopying 57 | 58 | public override func copyWithZone(zone: NSZone) -> AnyObject 59 | { 60 | let copy = super.copyWithZone(zone) as! LineRadarChartDataSet 61 | copy.fillColor = fillColor 62 | copy._lineWidth = _lineWidth 63 | copy.drawFilledEnabled = drawFilledEnabled 64 | return copy 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Charts/Classes/Data/LineScatterCandleChartDataSet.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LineScatterCandleChartDataSet.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 29/7/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import UIKit 16 | 17 | public class LineScatterCandleChartDataSet: BarLineScatterCandleBubbleChartDataSet 18 | { 19 | /// Enables / disables the horizontal highlight-indicator. If disabled, the indicator is not drawn. 20 | public var drawHorizontalHighlightIndicatorEnabled = true 21 | 22 | /// Enables / disables the vertical highlight-indicator. If disabled, the indicator is not drawn. 23 | public var drawVerticalHighlightIndicatorEnabled = true 24 | 25 | public var isHorizontalHighlightIndicatorEnabled: Bool { return drawHorizontalHighlightIndicatorEnabled } 26 | public var isVerticalHighlightIndicatorEnabled: Bool { return drawVerticalHighlightIndicatorEnabled } 27 | 28 | /// Enables / disables both vertical and horizontal highlight-indicators. 29 | /// :param: enabled 30 | public func setDrawHighlightIndicators(enabled: Bool) 31 | { 32 | drawHorizontalHighlightIndicatorEnabled = enabled 33 | drawVerticalHighlightIndicatorEnabled = enabled 34 | } 35 | 36 | // MARK: NSCopying 37 | 38 | public override func copyWithZone(zone: NSZone) -> AnyObject 39 | { 40 | let copy = super.copyWithZone(zone) as! LineScatterCandleChartDataSet 41 | copy.drawHorizontalHighlightIndicatorEnabled = drawHorizontalHighlightIndicatorEnabled 42 | copy.drawVerticalHighlightIndicatorEnabled = drawVerticalHighlightIndicatorEnabled 43 | return copy 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Charts/Classes/Data/PieChartData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PieData.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 24/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | 16 | public class PieChartData: ChartData 17 | { 18 | public override init() 19 | { 20 | super.init() 21 | } 22 | 23 | public override init(xVals: [String?]?, dataSets: [ChartDataSet]?) 24 | { 25 | super.init(xVals: xVals, dataSets: dataSets) 26 | } 27 | 28 | public override init(xVals: [NSObject]?, dataSets: [ChartDataSet]?) 29 | { 30 | super.init(xVals: xVals, dataSets: dataSets) 31 | } 32 | 33 | var dataSet: PieChartDataSet? 34 | { 35 | get 36 | { 37 | return dataSets.count > 0 ? dataSets[0] as? PieChartDataSet : nil 38 | } 39 | set 40 | { 41 | if (newValue != nil) 42 | { 43 | dataSets = [newValue!] 44 | } 45 | else 46 | { 47 | dataSets = [] 48 | } 49 | } 50 | } 51 | 52 | public override func getDataSetByIndex(index: Int) -> ChartDataSet? 53 | { 54 | if (index != 0) 55 | { 56 | return nil 57 | } 58 | return super.getDataSetByIndex(index) 59 | } 60 | 61 | public override func getDataSetByLabel(label: String, ignorecase: Bool) -> ChartDataSet? 62 | { 63 | if (dataSets.count == 0 || dataSets[0].label == nil) 64 | { 65 | return nil 66 | } 67 | 68 | if (ignorecase) 69 | { 70 | if (label.caseInsensitiveCompare(dataSets[0].label!) == NSComparisonResult.OrderedSame) 71 | { 72 | return dataSets[0] 73 | } 74 | } 75 | else 76 | { 77 | if (label == dataSets[0].label) 78 | { 79 | return dataSets[0] 80 | } 81 | } 82 | return nil 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Charts/Classes/Data/PieChartDataSet.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PieChartDataSet.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 24/2/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | import CoreGraphics 17 | import UIKit 18 | 19 | public class PieChartDataSet: ChartDataSet 20 | { 21 | private var _sliceSpace = CGFloat(0.0) 22 | 23 | /// indicates the selection distance of a pie slice 24 | public var selectionShift = CGFloat(18.0) 25 | 26 | public required init() 27 | { 28 | super.init() 29 | 30 | self.valueTextColor = UIColor.whiteColor() 31 | self.valueFont = UIFont.systemFontOfSize(13.0) 32 | } 33 | 34 | public override init(yVals: [ChartDataEntry]?, label: String?) 35 | { 36 | super.init(yVals: yVals, label: label) 37 | 38 | self.valueTextColor = UIColor.whiteColor() 39 | self.valueFont = UIFont.systemFontOfSize(13.0) 40 | } 41 | 42 | /// the space that is left out between the piechart-slices, default: 0° 43 | /// --> no space, maximum 45, minimum 0 (no space) 44 | public var sliceSpace: CGFloat 45 | { 46 | get 47 | { 48 | return _sliceSpace 49 | } 50 | set 51 | { 52 | _sliceSpace = newValue 53 | if (_sliceSpace > 45.0) 54 | { 55 | _sliceSpace = 45.0 56 | } 57 | if (_sliceSpace < 0.0) 58 | { 59 | _sliceSpace = 0.0 60 | } 61 | } 62 | } 63 | 64 | // MARK: NSCopying 65 | 66 | public override func copyWithZone(zone: NSZone) -> AnyObject 67 | { 68 | let copy = super.copyWithZone(zone) as! PieChartDataSet 69 | copy._sliceSpace = _sliceSpace 70 | copy.selectionShift = selectionShift 71 | return copy 72 | } 73 | } -------------------------------------------------------------------------------- /Charts/Classes/Data/RadarChartData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RadarChartData.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | import UIKit 17 | 18 | public class RadarChartData: ChartData 19 | { 20 | public var highlightColor = UIColor(red: 255.0/255.0, green: 187.0/255.0, blue: 115.0/255.0, alpha: 1.0) 21 | public var highlightLineWidth = CGFloat(1.0) 22 | public var highlightLineDashPhase = CGFloat(0.0) 23 | public var highlightLineDashLengths: [CGFloat]? 24 | 25 | public override init() 26 | { 27 | super.init() 28 | } 29 | 30 | public override init(xVals: [String?]?, dataSets: [ChartDataSet]?) 31 | { 32 | super.init(xVals: xVals, dataSets: dataSets) 33 | } 34 | 35 | public override init(xVals: [NSObject]?, dataSets: [ChartDataSet]?) 36 | { 37 | super.init(xVals: xVals, dataSets: dataSets) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Charts/Classes/Data/RadarChartDataSet.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RadarChartDataSet.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 24/2/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | import UIKit 17 | 18 | public class RadarChartDataSet: LineRadarChartDataSet 19 | { 20 | public required init() 21 | { 22 | super.init() 23 | 24 | self.valueFont = UIFont.systemFontOfSize(13.0) 25 | } 26 | 27 | public override init(yVals: [ChartDataEntry]?, label: String?) 28 | { 29 | super.init(yVals: yVals, label: label) 30 | 31 | self.valueFont = UIFont.systemFontOfSize(13.0) 32 | } 33 | } -------------------------------------------------------------------------------- /Charts/Classes/Data/ScatterChartData.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScatterChartData.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import UIKit 15 | 16 | public class ScatterChartData: BarLineScatterCandleBubbleChartData 17 | { 18 | public override init() 19 | { 20 | super.init() 21 | } 22 | 23 | public override init(xVals: [String?]?, dataSets: [ChartDataSet]?) 24 | { 25 | super.init(xVals: xVals, dataSets: dataSets) 26 | } 27 | 28 | public override init(xVals: [NSObject]?, dataSets: [ChartDataSet]?) 29 | { 30 | super.init(xVals: xVals, dataSets: dataSets) 31 | } 32 | 33 | /// - returns: the maximum shape-size across all DataSets. 34 | public func getGreatestShapeSize() -> CGFloat 35 | { 36 | var max = CGFloat(0.0) 37 | 38 | for set in _dataSets 39 | { 40 | let scatterDataSet = set as? ScatterChartDataSet 41 | 42 | if (scatterDataSet == nil) 43 | { 44 | print("ScatterChartData: Found a DataSet which is not a ScatterChartDataSet", terminator: "\n") 45 | } 46 | else 47 | { 48 | let size = scatterDataSet!.scatterShapeSize 49 | 50 | if (size > max) 51 | { 52 | max = size 53 | } 54 | } 55 | } 56 | 57 | return max 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Charts/Classes/Data/ScatterChartDataSet.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScatterChartDataSet.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | public class ScatterChartDataSet: LineScatterCandleChartDataSet 18 | { 19 | @objc 20 | public enum ScatterShape: Int 21 | { 22 | case Cross 23 | case Triangle 24 | case Circle 25 | case Square 26 | case Custom 27 | } 28 | 29 | public var scatterShapeSize = CGFloat(15.0) 30 | public var scatterShape = ScatterShape.Square 31 | public var customScatterShape: CGPath? 32 | 33 | // MARK: NSCopying 34 | 35 | public override func copyWithZone(zone: NSZone) -> AnyObject 36 | { 37 | let copy = super.copyWithZone(zone) as! ScatterChartDataSet 38 | copy.scatterShapeSize = scatterShapeSize 39 | copy.scatterShape = scatterShape 40 | copy.customScatterShape = customScatterShape 41 | return copy 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Charts/Classes/Filters/ChartDataBaseFilter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartDataFilter.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 23/2/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | 17 | public class ChartDataBaseFilter: NSObject 18 | { 19 | public override init() 20 | { 21 | super.init() 22 | } 23 | 24 | public func filter(points: [ChartDataEntry]) -> [ChartDataEntry] 25 | { 26 | fatalError("filter() cannot be called on ChartDataBaseFilter") 27 | } 28 | } -------------------------------------------------------------------------------- /Charts/Classes/Formatters/ChartDefaultXAxisValueFormatter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartDefaultXAxisValueFormatter.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 27/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | 16 | /// An interface for providing custom x-axis Strings. 17 | public class ChartDefaultXAxisValueFormatter: NSObject, ChartXAxisValueFormatter 18 | { 19 | 20 | public func stringForXValue(index: Int, original: String, viewPortHandler: ChartViewPortHandler) -> String 21 | { 22 | return original // just return original, no adjustments 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /Charts/Classes/Formatters/ChartFillFormatter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartFillFormatter.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 6/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | /// Protocol for providing a custom logic to where the filling line of a LineDataSet should end. This of course only works if setFillEnabled(...) is set to true. 18 | @objc 19 | public protocol ChartFillFormatter 20 | { 21 | /// - returns: the vertical (y-axis) position where the filled-line of the LineDataSet should end. 22 | func getFillLinePosition(dataSet dataSet: LineChartDataSet, dataProvider: LineChartDataProvider) -> CGFloat 23 | } 24 | -------------------------------------------------------------------------------- /Charts/Classes/Formatters/ChartXAxisValueFormatter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartXAxisValueFormatter.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 27/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | 16 | /// An interface for providing custom x-axis Strings. 17 | @objc 18 | public protocol ChartXAxisValueFormatter 19 | { 20 | 21 | /// For performance reasons, avoid excessive calculations and memory allocations inside this method. 22 | /// 23 | /// - returns: the customized label that is drawn on the x-axis. 24 | /// - parameter index: the x-index that is currently being drawn 25 | /// - parameter original: the original x-axis label to be drawn 26 | /// - parameter viewPortHandler: provides information about the current chart state (scale, translation, ...) 27 | /// 28 | func stringForXValue(index: Int, original: String, viewPortHandler: ChartViewPortHandler) -> String 29 | 30 | } -------------------------------------------------------------------------------- /Charts/Classes/Highlight/ChartHighlight.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartHighlight.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 23/2/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | 17 | public class ChartHighlight: NSObject 18 | { 19 | /// the x-index of the highlighted value 20 | private var _xIndex = Int(0) 21 | 22 | /// the index of the dataset the highlighted value is in 23 | private var _dataSetIndex = Int(0) 24 | 25 | /// index which value of a stacked bar entry is highlighted 26 | /// 27 | /// **default**: -1 28 | private var _stackIndex = Int(-1) 29 | 30 | /// the range of the bar that is selected (only for stacked-barchart) 31 | private var _range: ChartRange? 32 | 33 | public override init() 34 | { 35 | super.init() 36 | } 37 | 38 | public init(xIndex x: Int, dataSetIndex: Int) 39 | { 40 | super.init() 41 | 42 | _xIndex = x 43 | _dataSetIndex = dataSetIndex 44 | } 45 | 46 | public init(xIndex x: Int, dataSetIndex: Int, stackIndex: Int) 47 | { 48 | super.init() 49 | 50 | _xIndex = x 51 | _dataSetIndex = dataSetIndex 52 | _stackIndex = stackIndex 53 | } 54 | 55 | /// Constructor, only used for stacked-barchart. 56 | /// 57 | /// - parameter x: the index of the highlighted value on the x-axis 58 | /// - parameter dataSet: the index of the DataSet the highlighted value belongs to 59 | /// - parameter stackIndex: references which value of a stacked-bar entry has been selected 60 | /// - parameter range: the range the selected stack-value is in 61 | public convenience init(xIndex x: Int, dataSetIndex: Int, stackIndex: Int, range: ChartRange) 62 | { 63 | self.init(xIndex: x, dataSetIndex: dataSetIndex, stackIndex: stackIndex) 64 | 65 | _range = range 66 | } 67 | 68 | public var dataSetIndex: Int { return _dataSetIndex; } 69 | public var xIndex: Int { return _xIndex; } 70 | public var stackIndex: Int { return _stackIndex; } 71 | 72 | /// - returns: the range of values the selected value of a stacked bar is in. (this is only relevant for stacked-barchart) 73 | public var range: ChartRange? { return _range } 74 | 75 | // MARK: NSObject 76 | 77 | public override var description: String 78 | { 79 | return "Highlight, xIndex: \(_xIndex), dataSetIndex: \(_dataSetIndex), stackIndex (only stacked barentry): \(_stackIndex)" 80 | } 81 | 82 | public override func isEqual(object: AnyObject?) -> Bool 83 | { 84 | if (object === nil) 85 | { 86 | return false 87 | } 88 | 89 | if (!object!.isKindOfClass(self.dynamicType)) 90 | { 91 | return false 92 | } 93 | 94 | if (object!.xIndex != _xIndex) 95 | { 96 | return false 97 | } 98 | 99 | if (object!.dataSetIndex != _dataSetIndex) 100 | { 101 | return false 102 | } 103 | 104 | if (object!.stackIndex != _stackIndex) 105 | { 106 | return false 107 | } 108 | 109 | return true 110 | } 111 | } 112 | 113 | func ==(lhs: ChartHighlight, rhs: ChartHighlight) -> Bool 114 | { 115 | if (lhs === rhs) 116 | { 117 | return true 118 | } 119 | 120 | if (!lhs.isKindOfClass(rhs.dynamicType)) 121 | { 122 | return false 123 | } 124 | 125 | if (lhs._xIndex != rhs._xIndex) 126 | { 127 | return false 128 | } 129 | 130 | if (lhs._dataSetIndex != rhs._dataSetIndex) 131 | { 132 | return false 133 | } 134 | 135 | if (lhs._stackIndex != rhs._stackIndex) 136 | { 137 | return false 138 | } 139 | 140 | return true 141 | } -------------------------------------------------------------------------------- /Charts/Classes/Highlight/ChartHighlighter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartHighlighter.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/7/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | import CoreGraphics 17 | 18 | internal class ChartHighlighter 19 | { 20 | /// instance of the data-provider 21 | internal weak var _chart: BarLineChartViewBase?; 22 | 23 | internal init(chart: BarLineChartViewBase) 24 | { 25 | _chart = chart; 26 | } 27 | 28 | /// Returns a Highlight object corresponding to the given x- and y- touch positions in pixels. 29 | /// - parameter x: 30 | /// - parameter y: 31 | /// - returns: 32 | internal func getHighlight(x x: Double, y: Double) -> ChartHighlight? 33 | { 34 | let xIndex = getXIndex(x) 35 | if (xIndex == -Int.max) 36 | { 37 | return nil 38 | } 39 | 40 | let dataSetIndex = getDataSetIndex(xIndex: xIndex, x: x, y: y) 41 | if (dataSetIndex == -Int.max) 42 | { 43 | return nil 44 | } 45 | 46 | return ChartHighlight(xIndex: xIndex, dataSetIndex: dataSetIndex) 47 | } 48 | 49 | /// Returns the corresponding x-index for a given touch-position in pixels. 50 | /// - parameter x: 51 | /// - returns: 52 | internal func getXIndex(x: Double) -> Int 53 | { 54 | // create an array of the touch-point 55 | var pt = CGPoint(x: x, y: 0.0) 56 | 57 | // take any transformer to determine the x-axis value 58 | _chart?.getTransformer(ChartYAxis.AxisDependency.Left).pixelToValue(&pt) 59 | 60 | return Int(round(pt.x)) 61 | } 62 | 63 | /// Returns the corresponding dataset-index for a given xIndex and xy-touch position in pixels. 64 | /// - parameter xIndex: 65 | /// - parameter x: 66 | /// - parameter y: 67 | /// - returns: 68 | internal func getDataSetIndex(xIndex xIndex: Int, x: Double, y: Double) -> Int 69 | { 70 | let valsAtIndex = getSelectionDetailsAtIndex(xIndex) 71 | 72 | let leftdist = ChartUtils.getMinimumDistance(valsAtIndex, val: y, axis: ChartYAxis.AxisDependency.Left) 73 | let rightdist = ChartUtils.getMinimumDistance(valsAtIndex, val: y, axis: ChartYAxis.AxisDependency.Right) 74 | 75 | let axis = leftdist < rightdist ? ChartYAxis.AxisDependency.Left : ChartYAxis.AxisDependency.Right 76 | 77 | let dataSetIndex = ChartUtils.closestDataSetIndex(valsAtIndex, value: y, axis: axis) 78 | 79 | return dataSetIndex 80 | } 81 | 82 | /// Returns a list of SelectionDetail object corresponding to the given xIndex. 83 | /// - parameter xIndex: 84 | /// - returns: 85 | internal func getSelectionDetailsAtIndex(xIndex: Int) -> [ChartSelectionDetail] 86 | { 87 | var vals = [ChartSelectionDetail]() 88 | var pt = CGPoint() 89 | 90 | for (var i = 0, dataSetCount = _chart?.data?.dataSetCount; i < dataSetCount; i++) 91 | { 92 | let dataSet = _chart!.data!.getDataSetByIndex(i) 93 | 94 | // dont include datasets that cannot be highlighted 95 | if !dataSet.isHighlightEnabled 96 | { 97 | continue 98 | } 99 | 100 | // extract all y-values from all DataSets at the given x-index 101 | let yVal: Double = dataSet.yValForXIndex(xIndex) 102 | if yVal.isNaN 103 | { 104 | continue 105 | } 106 | 107 | pt.y = CGFloat(yVal) 108 | 109 | _chart!.getTransformer(dataSet.axisDependency).pointValueToPixel(&pt) 110 | 111 | if !pt.y.isNaN 112 | { 113 | vals.append(ChartSelectionDetail(value: Double(pt.y), dataSetIndex: i, dataSet: dataSet)) 114 | } 115 | } 116 | 117 | return vals 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Charts/Classes/Highlight/ChartRange.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartRange.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/7/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | 17 | public class ChartRange: NSObject 18 | { 19 | public var from: Double 20 | public var to: Double 21 | 22 | public init(from: Double, to: Double) 23 | { 24 | self.from = from 25 | self.to = to 26 | 27 | super.init() 28 | } 29 | 30 | /// Returns true if this range contains (if the value is in between) the given value, false if not. 31 | /// - parameter value: 32 | public func contains(value: Double) -> Bool 33 | { 34 | if value > from && value <= to 35 | { 36 | return true 37 | } 38 | else 39 | { 40 | return false 41 | } 42 | } 43 | 44 | public func isLarger(value: Double) -> Bool 45 | { 46 | return value > to 47 | } 48 | 49 | public func isSmaller(value: Double) -> Bool 50 | { 51 | return value < from 52 | } 53 | } -------------------------------------------------------------------------------- /Charts/Classes/Highlight/CombinedHighlighter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CombinedHighlighter.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/7/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | import CoreGraphics 17 | 18 | internal class CombinedHighlighter: ChartHighlighter 19 | { 20 | internal init(chart: CombinedChartView) 21 | { 22 | super.init(chart: chart) 23 | } 24 | 25 | /// Returns a list of SelectionDetail object corresponding to the given xIndex. 26 | /// - parameter xIndex: 27 | /// - returns: 28 | internal override func getSelectionDetailsAtIndex(xIndex: Int) -> [ChartSelectionDetail] 29 | { 30 | var vals = [ChartSelectionDetail]() 31 | 32 | if let data = _chart?.data as? CombinedChartData 33 | { 34 | // get all chartdata objects 35 | var dataObjects = data.allData 36 | 37 | var pt = CGPoint() 38 | 39 | for var i = 0; i < dataObjects.count; i++ 40 | { 41 | for var j = 0; j < dataObjects[i].dataSetCount; j++ 42 | { 43 | let dataSet = dataObjects[i].getDataSetByIndex(j) 44 | 45 | // dont include datasets that cannot be highlighted 46 | if !dataSet.isHighlightEnabled 47 | { 48 | continue 49 | } 50 | 51 | // extract all y-values from all DataSets at the given x-index 52 | let yVal = dataSet.yValForXIndex(xIndex) 53 | if yVal.isNaN 54 | { 55 | continue 56 | } 57 | 58 | pt.y = CGFloat(yVal) 59 | 60 | _chart!.getTransformer(dataSet.axisDependency).pointValueToPixel(&pt) 61 | 62 | if !pt.y.isNaN 63 | { 64 | vals.append(ChartSelectionDetail(value: Double(pt.y), dataSetIndex: j, dataSet: dataSet)) 65 | } 66 | } 67 | } 68 | } 69 | 70 | return vals 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Charts/Classes/Highlight/HorizontalBarChartHighlighter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HorizontalBarChartHighlighter.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 26/7/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | import CoreGraphics 17 | 18 | internal class HorizontalBarChartHighlighter: BarChartHighlighter 19 | { 20 | internal override func getHighlight(x x: Double, y: Double) -> ChartHighlight? 21 | { 22 | let h = super.getHighlight(x: x, y: y) 23 | 24 | if h === nil 25 | { 26 | return h 27 | } 28 | else 29 | { 30 | if let set = _chart?.data?.getDataSetByIndex(h!.dataSetIndex) as? BarChartDataSet 31 | { 32 | if set.isStacked 33 | { 34 | // create an array of the touch-point 35 | var pt = CGPoint() 36 | pt.x = CGFloat(y) 37 | 38 | // take any transformer to determine the x-axis value 39 | _chart?.getTransformer(set.axisDependency).pixelToValue(&pt) 40 | 41 | return getStackedHighlight(old: h, set: set, xIndex: h!.xIndex, dataSetIndex: h!.dataSetIndex, yValue: Double(pt.x)) 42 | } 43 | } 44 | 45 | return h 46 | } 47 | } 48 | 49 | internal override func getXIndex(x: Double) -> Int 50 | { 51 | if let barChartData = _chart?.data as? BarChartData 52 | { 53 | if !barChartData.isGrouped 54 | { 55 | // create an array of the touch-point 56 | var pt = CGPoint(x: 0.0, y: x) 57 | 58 | // take any transformer to determine the x-axis value 59 | _chart?.getTransformer(ChartYAxis.AxisDependency.Left).pixelToValue(&pt) 60 | 61 | return Int(round(pt.y)) 62 | } 63 | else 64 | { 65 | let baseNoSpace = getBase(x) 66 | 67 | let setCount = barChartData.dataSetCount 68 | var xIndex = Int(baseNoSpace) / setCount 69 | 70 | let valCount = barChartData.xValCount 71 | 72 | if xIndex < 0 73 | { 74 | xIndex = 0 75 | } 76 | else if xIndex >= valCount 77 | { 78 | xIndex = valCount - 1 79 | } 80 | 81 | return xIndex 82 | } 83 | } 84 | else 85 | { 86 | return 0 87 | } 88 | } 89 | 90 | /// Returns the base y-value to the corresponding x-touch value in pixels. 91 | /// - parameter y: 92 | /// - returns: 93 | internal override func getBase(y: Double) -> Double 94 | { 95 | if let barChartData = _chart?.data as? BarChartData 96 | { 97 | // create an array of the touch-point 98 | var pt = CGPoint() 99 | pt.y = CGFloat(y) 100 | 101 | // take any transformer to determine the x-axis value 102 | _chart?.getTransformer(ChartYAxis.AxisDependency.Left).pixelToValue(&pt) 103 | let yVal = Double(pt.y) 104 | 105 | let setCount = barChartData.dataSetCount ?? 0 106 | 107 | // calculate how often the group-space appears 108 | let steps = Int(yVal / (Double(setCount) + Double(barChartData.groupSpace))) 109 | 110 | let groupSpaceSum = Double(barChartData.groupSpace) * Double(steps) 111 | 112 | let baseNoSpace = yVal - groupSpaceSum 113 | 114 | return baseNoSpace 115 | } 116 | else 117 | { 118 | return 0.0 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Charts/Classes/Interfaces/BarChartDataProvider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BarChartDataProvider.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 27/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | @objc 18 | public protocol BarChartDataProvider: BarLineScatterCandleBubbleChartDataProvider 19 | { 20 | var barData: BarChartData? { get } 21 | 22 | var isDrawBarShadowEnabled: Bool { get } 23 | var isDrawValueAboveBarEnabled: Bool { get } 24 | var isDrawHighlightArrowEnabled: Bool { get } 25 | } -------------------------------------------------------------------------------- /Charts/Classes/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BarLineScatterCandleBubbleChartDataProvider.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 27/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | @objc 18 | public protocol BarLineScatterCandleBubbleChartDataProvider: ChartDataProvider 19 | { 20 | func getTransformer(which: ChartYAxis.AxisDependency) -> ChartTransformer 21 | var maxVisibleValueCount: Int { get } 22 | func isInverted(axis: ChartYAxis.AxisDependency) -> Bool 23 | 24 | var lowestVisibleXIndex: Int { get } 25 | var highestVisibleXIndex: Int { get } 26 | } -------------------------------------------------------------------------------- /Charts/Classes/Interfaces/BubbleChartDataProvider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BubbleChartDataProvider.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 27/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | @objc 18 | public protocol BubbleChartDataProvider: BarLineScatterCandleBubbleChartDataProvider 19 | { 20 | var bubbleData: BubbleChartData? { get } 21 | } -------------------------------------------------------------------------------- /Charts/Classes/Interfaces/CandleChartDataProvider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CandleChartDataProvider.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 27/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | @objc 18 | public protocol CandleChartDataProvider: BarLineScatterCandleBubbleChartDataProvider 19 | { 20 | var candleData: CandleChartData? { get } 21 | } -------------------------------------------------------------------------------- /Charts/Classes/Interfaces/ChartDataProvider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartDataProvider.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 27/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | @objc 18 | public protocol ChartDataProvider 19 | { 20 | var chartXMin: Double { get } 21 | var chartXMax: Double { get } 22 | var chartYMin: Double { get } 23 | var chartYMax: Double { get } 24 | var xValCount: Int { get } 25 | var centerOffsets: CGPoint { get } 26 | var data: ChartData? { get } 27 | } -------------------------------------------------------------------------------- /Charts/Classes/Interfaces/LineChartDataProvider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LineChartDataProvider.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 27/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | @objc 18 | public protocol LineChartDataProvider: BarLineScatterCandleBubbleChartDataProvider 19 | { 20 | var lineData: LineChartData? { get } 21 | 22 | func getAxis(axis: ChartYAxis.AxisDependency) -> ChartYAxis 23 | } -------------------------------------------------------------------------------- /Charts/Classes/Interfaces/ScatterChartDataProvider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScatterChartDataProvider.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 27/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | @objc 18 | public protocol ScatterChartDataProvider: BarLineScatterCandleBubbleChartDataProvider 19 | { 20 | var scatterData: ScatterChartData? { get } 21 | } -------------------------------------------------------------------------------- /Charts/Classes/Renderers/ChartAxisRendererBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartAxisRendererBase.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 3/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import UIKit 16 | 17 | public class ChartAxisRendererBase: ChartRendererBase 18 | { 19 | public var transformer: ChartTransformer! 20 | 21 | public override init() 22 | { 23 | super.init() 24 | } 25 | 26 | public init(viewPortHandler: ChartViewPortHandler, transformer: ChartTransformer!) 27 | { 28 | super.init(viewPortHandler: viewPortHandler) 29 | 30 | self.transformer = transformer 31 | } 32 | 33 | /// Draws the axis labels on the specified context 34 | public func renderAxisLabels(context context: CGContext) 35 | { 36 | fatalError("renderAxisLabels() cannot be called on ChartAxisRendererBase") 37 | } 38 | 39 | /// Draws the grid lines belonging to the axis. 40 | public func renderGridLines(context context: CGContext) 41 | { 42 | fatalError("renderGridLines() cannot be called on ChartAxisRendererBase") 43 | } 44 | 45 | /// Draws the line that goes alongside the axis. 46 | public func renderAxisLine(context context: CGContext) 47 | { 48 | fatalError("renderAxisLine() cannot be called on ChartAxisRendererBase") 49 | } 50 | 51 | /// Draws the LimitLines associated with this axis to the screen. 52 | public func renderLimitLines(context context: CGContext) 53 | { 54 | fatalError("renderLimitLines() cannot be called on ChartAxisRendererBase") 55 | } 56 | } -------------------------------------------------------------------------------- /Charts/Classes/Renderers/ChartDataRendererBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartDataRendererBase.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 4/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | public class ChartDataRendererBase: ChartRendererBase 18 | { 19 | internal var _animator: ChartAnimator! 20 | 21 | public init(animator: ChartAnimator?, viewPortHandler: ChartViewPortHandler) 22 | { 23 | super.init(viewPortHandler: viewPortHandler) 24 | _animator = animator 25 | } 26 | 27 | public func drawData(context context: CGContext) 28 | { 29 | fatalError("drawData() cannot be called on ChartDataRendererBase") 30 | } 31 | 32 | public func drawValues(context context: CGContext) 33 | { 34 | fatalError("drawValues() cannot be called on ChartDataRendererBase") 35 | } 36 | 37 | public func drawExtras(context context: CGContext) 38 | { 39 | fatalError("drawExtras() cannot be called on ChartDataRendererBase") 40 | } 41 | 42 | /// Draws all highlight indicators for the values that are currently highlighted. 43 | /// 44 | /// - parameter indices: the highlighted values 45 | public func drawHighlighted(context context: CGContext, indices: [ChartHighlight]) 46 | { 47 | fatalError("drawHighlighted() cannot be called on ChartDataRendererBase") 48 | } 49 | } -------------------------------------------------------------------------------- /Charts/Classes/Renderers/ChartRendererBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartRendererBase.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 3/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | public class ChartRendererBase: NSObject 18 | { 19 | /// the component that handles the drawing area of the chart and it's offsets 20 | public var viewPortHandler: ChartViewPortHandler! 21 | 22 | /// the minimum value on the x-axis that should be plotted 23 | internal var _minX: Int = 0 24 | 25 | /// the maximum value on the x-axis that should be plotted 26 | internal var _maxX: Int = 0 27 | 28 | public override init() 29 | { 30 | super.init() 31 | } 32 | 33 | public init(viewPortHandler: ChartViewPortHandler) 34 | { 35 | super.init() 36 | self.viewPortHandler = viewPortHandler 37 | } 38 | 39 | /// - returns: true if the specified value fits in between the provided min and max bounds, false if not. 40 | internal func fitsBounds(val: Double, min: Double, max: Double) -> Bool 41 | { 42 | if (val < min || val > max) 43 | { 44 | return false 45 | } 46 | else 47 | { 48 | return true 49 | } 50 | } 51 | 52 | /// Calculates the minimum and maximum x-value the chart can currently display (with the given zoom level). 53 | public func calcXBounds(chart chart: BarLineChartViewBase, xAxisModulus: Int) 54 | { 55 | let low = chart.lowestVisibleXIndex 56 | let high = chart.highestVisibleXIndex 57 | 58 | let subLow = (low % xAxisModulus == 0) ? xAxisModulus : 0 59 | 60 | _maxX = min((high / xAxisModulus) * (xAxisModulus) + xAxisModulus, Int(chart.chartXMax)) 61 | _minX = min(max((low / xAxisModulus) * (xAxisModulus) - subLow, 0), _maxX) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Charts/Classes/Renderers/ChartXAxisRendererRadarChart.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartXAxisRendererRadarChart.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 3/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | import UIKit 17 | 18 | public class ChartXAxisRendererRadarChart: ChartXAxisRenderer 19 | { 20 | private weak var _chart: RadarChartView! 21 | 22 | public init(viewPortHandler: ChartViewPortHandler, xAxis: ChartXAxis, chart: RadarChartView) 23 | { 24 | super.init(viewPortHandler: viewPortHandler, xAxis: xAxis, transformer: nil) 25 | 26 | _chart = chart 27 | } 28 | 29 | public override func renderAxisLabels(context context: CGContext) 30 | { 31 | if (!_xAxis.isEnabled || !_xAxis.isDrawLabelsEnabled) 32 | { 33 | return 34 | } 35 | 36 | let labelFont = _xAxis.labelFont 37 | let labelTextColor = _xAxis.labelTextColor 38 | let labelRotationAngleRadians = _xAxis.labelRotationAngle * ChartUtils.Math.FDEG2RAD 39 | let drawLabelAnchor = CGPoint(x: 0.5, y: 0.0) 40 | 41 | let sliceangle = _chart.sliceAngle 42 | 43 | // calculate the factor that is needed for transforming the value to pixels 44 | let factor = _chart.factor 45 | 46 | let center = _chart.centerOffsets 47 | 48 | let modulus = _xAxis.axisLabelModulus 49 | for var i = 0, count = _xAxis.values.count; i < count; i += modulus 50 | { 51 | let label = _xAxis.values[i] 52 | 53 | if (label == nil) 54 | { 55 | continue 56 | } 57 | 58 | let angle = (sliceangle * CGFloat(i) + _chart.rotationAngle) % 360.0 59 | 60 | let p = ChartUtils.getPosition(center: center, dist: CGFloat(_chart.yRange) * factor + _xAxis.labelRotatedWidth / 2.0, angle: angle) 61 | 62 | drawLabel(context: context, label: label!, xIndex: i, x: p.x, y: p.y - _xAxis.labelRotatedHeight / 2.0, attributes: [NSFontAttributeName: labelFont, NSForegroundColorAttributeName: labelTextColor], anchor: drawLabelAnchor, angleRadians: labelRotationAngleRadians) 63 | } 64 | } 65 | 66 | internal func drawLabel(context context: CGContext, label: String, xIndex: Int, x: CGFloat, y: CGFloat, attributes: [String: NSObject], anchor: CGPoint, angleRadians: CGFloat) 67 | { 68 | let formattedLabel = _xAxis.valueFormatter?.stringForXValue(xIndex, original: label, viewPortHandler: viewPortHandler) ?? label 69 | ChartUtils.drawText(context: context, text: formattedLabel, point: CGPoint(x: x, y: y), attributes: attributes, anchor: anchor, angleRadians: angleRadians) 70 | } 71 | 72 | public override func renderLimitLines(context context: CGContext) 73 | { 74 | /// XAxis LimitLines on RadarChart not yet supported. 75 | } 76 | } -------------------------------------------------------------------------------- /Charts/Classes/Renderers/LineScatterCandleRadarChartRenderer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LineScatterCandleRadarChartRenderer.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 29/7/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | import UIKit 17 | 18 | public class LineScatterCandleRadarChartRenderer: ChartDataRendererBase 19 | { 20 | public override init(animator: ChartAnimator?, viewPortHandler: ChartViewPortHandler) 21 | { 22 | super.init(animator: animator, viewPortHandler: viewPortHandler) 23 | } 24 | 25 | /// Draws vertical & horizontal highlight-lines if enabled. 26 | /// :param: context 27 | /// :param: points 28 | /// :param: horizontal 29 | /// :param: vertical 30 | public func drawHighlightLines(context context: CGContext, point: CGPoint, set: LineScatterCandleChartDataSet) 31 | { 32 | // draw vertical highlight lines 33 | if set.isVerticalHighlightIndicatorEnabled 34 | { 35 | CGContextBeginPath(context) 36 | CGContextMoveToPoint(context, point.x, viewPortHandler.contentTop) 37 | CGContextAddLineToPoint(context, point.x, viewPortHandler.contentBottom) 38 | CGContextStrokePath(context) 39 | } 40 | 41 | // draw horizontal highlight lines 42 | if set.isHorizontalHighlightIndicatorEnabled 43 | { 44 | CGContextBeginPath(context) 45 | CGContextMoveToPoint(context, viewPortHandler.contentLeft, point.y) 46 | CGContextAddLineToPoint(context, viewPortHandler.contentRight, point.y) 47 | CGContextStrokePath(context) 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Charts/Classes/Utils/ChartColorTemplates.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartColorTemplates.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 23/2/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | import UIKit 17 | 18 | public class ChartColorTemplates: NSObject 19 | { 20 | public class func liberty () -> [UIColor] 21 | { 22 | return [ 23 | UIColor(red: 207/255.0, green: 248/255.0, blue: 246/255.0, alpha: 1.0), 24 | UIColor(red: 148/255.0, green: 212/255.0, blue: 212/255.0, alpha: 1.0), 25 | UIColor(red: 136/255.0, green: 180/255.0, blue: 187/255.0, alpha: 1.0), 26 | UIColor(red: 118/255.0, green: 174/255.0, blue: 175/255.0, alpha: 1.0), 27 | UIColor(red: 42/255.0, green: 109/255.0, blue: 130/255.0, alpha: 1.0) 28 | ] 29 | } 30 | 31 | public class func joyful () -> [UIColor] 32 | { 33 | return [ 34 | UIColor(red: 217/255.0, green: 80/255.0, blue: 138/255.0, alpha: 1.0), 35 | UIColor(red: 254/255.0, green: 149/255.0, blue: 7/255.0, alpha: 1.0), 36 | UIColor(red: 254/255.0, green: 247/255.0, blue: 120/255.0, alpha: 1.0), 37 | UIColor(red: 106/255.0, green: 167/255.0, blue: 134/255.0, alpha: 1.0), 38 | UIColor(red: 53/255.0, green: 194/255.0, blue: 209/255.0, alpha: 1.0) 39 | ] 40 | } 41 | 42 | public class func pastel () -> [UIColor] 43 | { 44 | return [ 45 | UIColor(red: 64/255.0, green: 89/255.0, blue: 128/255.0, alpha: 1.0), 46 | UIColor(red: 149/255.0, green: 165/255.0, blue: 124/255.0, alpha: 1.0), 47 | UIColor(red: 217/255.0, green: 184/255.0, blue: 162/255.0, alpha: 1.0), 48 | UIColor(red: 191/255.0, green: 134/255.0, blue: 134/255.0, alpha: 1.0), 49 | UIColor(red: 179/255.0, green: 48/255.0, blue: 80/255.0, alpha: 1.0) 50 | ] 51 | } 52 | 53 | public class func colorful () -> [UIColor] 54 | { 55 | return [ 56 | UIColor(red: 193/255.0, green: 37/255.0, blue: 82/255.0, alpha: 1.0), 57 | UIColor(red: 255/255.0, green: 102/255.0, blue: 0/255.0, alpha: 1.0), 58 | UIColor(red: 245/255.0, green: 199/255.0, blue: 0/255.0, alpha: 1.0), 59 | UIColor(red: 106/255.0, green: 150/255.0, blue: 31/255.0, alpha: 1.0), 60 | UIColor(red: 179/255.0, green: 100/255.0, blue: 53/255.0, alpha: 1.0) 61 | ] 62 | } 63 | 64 | public class func vordiplom () -> [UIColor] 65 | { 66 | return [ 67 | UIColor(red: 192/255.0, green: 255/255.0, blue: 140/255.0, alpha: 1.0), 68 | UIColor(red: 255/255.0, green: 247/255.0, blue: 140/255.0, alpha: 1.0), 69 | UIColor(red: 255/255.0, green: 208/255.0, blue: 140/255.0, alpha: 1.0), 70 | UIColor(red: 140/255.0, green: 234/255.0, blue: 255/255.0, alpha: 1.0), 71 | UIColor(red: 255/255.0, green: 140/255.0, blue: 157/255.0, alpha: 1.0) 72 | ] 73 | } 74 | } -------------------------------------------------------------------------------- /Charts/Classes/Utils/ChartSelectionDetail.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartSelectionDetail.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 23/2/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | import Foundation 16 | 17 | public class ChartSelectionDetail: NSObject 18 | { 19 | private var _value = Double(0) 20 | private var _dataSetIndex = Int(0) 21 | private var _dataSet: ChartDataSet! 22 | 23 | public override init() 24 | { 25 | super.init() 26 | } 27 | 28 | public init(value: Double, dataSetIndex: Int, dataSet: ChartDataSet) 29 | { 30 | super.init() 31 | 32 | _value = value 33 | _dataSetIndex = dataSetIndex 34 | _dataSet = dataSet 35 | } 36 | 37 | public var value: Double 38 | { 39 | return _value 40 | } 41 | 42 | public var dataSetIndex: Int 43 | { 44 | return _dataSetIndex 45 | } 46 | 47 | public var dataSet: ChartDataSet? 48 | { 49 | return _dataSet 50 | } 51 | 52 | // MARK: NSObject 53 | 54 | public override func isEqual(object: AnyObject?) -> Bool 55 | { 56 | if (object === nil) 57 | { 58 | return false 59 | } 60 | 61 | if (!object!.isKindOfClass(self.dynamicType)) 62 | { 63 | return false 64 | } 65 | 66 | if (object!.value != _value) 67 | { 68 | return false 69 | } 70 | 71 | if (object!.dataSetIndex != _dataSetIndex) 72 | { 73 | return false 74 | } 75 | 76 | if (object!.dataSet !== _dataSet) 77 | { 78 | return false 79 | } 80 | 81 | return true 82 | } 83 | } 84 | 85 | public func ==(lhs: ChartSelectionDetail, rhs: ChartSelectionDetail) -> Bool 86 | { 87 | if (lhs === rhs) 88 | { 89 | return true 90 | } 91 | 92 | if (!lhs.isKindOfClass(rhs.dynamicType)) 93 | { 94 | return false 95 | } 96 | 97 | if (lhs.value != rhs.value) 98 | { 99 | return false 100 | } 101 | 102 | if (lhs.dataSetIndex != rhs.dataSetIndex) 103 | { 104 | return false 105 | } 106 | 107 | if (lhs.dataSet !== rhs.dataSet) 108 | { 109 | return false 110 | } 111 | 112 | return true 113 | } -------------------------------------------------------------------------------- /Charts/Classes/Utils/ChartTransformerHorizontalBarChart.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChartTransformerHorizontalBarChart.swift 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 1/4/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | import Foundation 15 | import CoreGraphics 16 | 17 | public class ChartTransformerHorizontalBarChart: ChartTransformer 18 | { 19 | /// Prepares the matrix that contains all offsets. 20 | public override func prepareMatrixOffset(inverted: Bool) 21 | { 22 | if (!inverted) 23 | { 24 | _matrixOffset = CGAffineTransformMakeTranslation(_viewPortHandler.offsetLeft, _viewPortHandler.chartHeight - _viewPortHandler.offsetBottom) 25 | } 26 | else 27 | { 28 | _matrixOffset = CGAffineTransformMakeScale(-1.0, 1.0) 29 | _matrixOffset = CGAffineTransformTranslate(_matrixOffset, 30 | -(_viewPortHandler.chartWidth - _viewPortHandler.offsetRight), 31 | _viewPortHandler.chartHeight - _viewPortHandler.offsetBottom) 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Charts/Supporting Files/Charts.h: -------------------------------------------------------------------------------- 1 | // 2 | // Charts.h 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 23/2/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | #import 16 | 17 | //! Project version number for Charts. 18 | FOUNDATION_EXPORT double ChartsVersionNumber; 19 | 20 | //! Project version string for Charts. 21 | FOUNDATION_EXPORT const unsigned char ChartsVersionString[]; 22 | 23 | // In this header, you should import all the public headers of your framework using statements like #import 24 | 25 | 26 | -------------------------------------------------------------------------------- /Charts/Supporting Files/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 2.1.6 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 16 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 23/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | 16 | @interface AppDelegate : UIResponder 17 | 18 | @property (strong, nonatomic) UIWindow *window; 19 | 20 | 21 | @end 22 | 23 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 23/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import "AppDelegate.h" 15 | #import "DemoListViewController.h" 16 | 17 | @interface AppDelegate () 18 | 19 | @end 20 | 21 | @implementation AppDelegate 22 | 23 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 24 | { 25 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 26 | 27 | DemoListViewController *vc = [[DemoListViewController alloc] init]; 28 | UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc]; 29 | 30 | _window.rootViewController = nvc; 31 | [_window makeKeyAndVisible]; 32 | 33 | return YES; 34 | } 35 | 36 | - (void)applicationWillResignActive:(UIApplication *)application { 37 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 38 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 39 | } 40 | 41 | - (void)applicationDidEnterBackground:(UIApplication *)application { 42 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 43 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 44 | } 45 | 46 | - (void)applicationWillEnterForeground:(UIApplication *)application { 47 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 48 | } 49 | 50 | - (void)applicationDidBecomeActive:(UIApplication *)application { 51 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 52 | } 53 | 54 | - (void)applicationWillTerminate:(UIApplication *)application { 55 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Components/MyCustomXValueFormatter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MyCustomXValueFormatter.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 21/9/15. 6 | // Copyright © 2015 dcg. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface MyCustomXValueFormatter : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Components/MyCustomXValueFormatter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MyCustomXValueFormatter.m 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 21/9/15. 6 | // Copyright © 2015 dcg. All rights reserved. 7 | // 8 | 9 | #import "MyCustomXValueFormatter.h" 10 | 11 | @implementation MyCustomXValueFormatter 12 | 13 | - (NSString *)stringForXValue:(NSInteger)index 14 | original:(NSString *)original 15 | viewPortHandler:(ChartViewPortHandler *)viewPortHandler 16 | { 17 | // e.g. adjust the x-axis values depending on scale / zoom level 18 | if (viewPortHandler.scaleX > 5.f) 19 | { 20 | return @"4"; 21 | } 22 | else if (viewPortHandler.scaleX > 3.f) 23 | { 24 | return @"3"; 25 | } 26 | else if (viewPortHandler.scaleX > 1.f) 27 | { 28 | return @"2"; 29 | } 30 | else 31 | { 32 | return original; 33 | } 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/DemoBaseViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DemoBaseViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 13/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | 16 | @interface DemoBaseViewController : UIViewController 17 | { 18 | @protected 19 | NSArray *months; 20 | NSArray *parties; 21 | } 22 | 23 | @property (nonatomic, strong) IBOutlet UIButton *optionsButton; 24 | @property (nonatomic, strong) IBOutlet NSArray *options; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/DemoListViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DemoListViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 23/2/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | 16 | @interface DemoListViewController : UIViewController 17 | 18 | 19 | @end 20 | 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/DemoListViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/AnotherBarChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AnotherBarChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface AnotherBarChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/BarChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BarChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface BarChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/BubbleChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BubbleChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Bubble chart implementation: 6 | // Copyright 2015 Pierre-Marc Airoldi 7 | // Licensed under Apache License 2.0 8 | // 9 | // https://github.com/danielgindi/ios-charts 10 | // 11 | 12 | #import 13 | #import "DemoBaseViewController.h" 14 | #import 15 | 16 | @interface BubbleChartViewController : DemoBaseViewController 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/CandleStickChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CandleStickChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface CandleStickChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/ColoredLineChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ColoredLineChartViewController.m 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface ColoredLineChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/ColoredLineChartViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ColoredLineChartViewController.m 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import "ColoredLineChartViewController.h" 15 | #import "ChartsDemo-Swift.h" 16 | 17 | @interface ColoredLineChartViewController () 18 | 19 | @property (nonatomic, strong) IBOutletCollection(LineChartView) NSArray *chartViews; 20 | 21 | @end 22 | 23 | @implementation ColoredLineChartViewController 24 | 25 | - (void)viewDidLoad 26 | { 27 | [super viewDidLoad]; 28 | 29 | self.title = @"Colored Line Chart"; 30 | 31 | LineChartData *data = [self dataWithCount:36 range:100]; 32 | [data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:7.f]]; 33 | 34 | NSArray *colors = @[ 35 | [UIColor colorWithRed:137/255.f green:230/255.f blue:81/255.f alpha:1.f], 36 | [UIColor colorWithRed:240/255.f green:240/255.f blue:30/255.f alpha:1.f], 37 | [UIColor colorWithRed:89/255.f green:199/255.f blue:250/255.f alpha:1.f], 38 | [UIColor colorWithRed:250/255.f green:104/255.f blue:104/255.f alpha:1.f], 39 | ]; 40 | 41 | for (int i = 0; i < _chartViews.count; i++) 42 | { 43 | [self setupChart:_chartViews[i] data:data color:colors[i % colors.count]]; 44 | } 45 | } 46 | 47 | - (void)setupChart:(LineChartView *)chart data:(LineChartData *)data color:(UIColor *)color 48 | { 49 | chart.delegate = self; 50 | chart.backgroundColor = color; 51 | 52 | chart.descriptionText = @""; 53 | chart.noDataTextDescription = @"You need to provide data for the chart."; 54 | 55 | chart.drawGridBackgroundEnabled = NO; 56 | chart.dragEnabled = YES; 57 | [chart setScaleEnabled:YES]; 58 | chart.pinchZoomEnabled = NO; 59 | [chart setViewPortOffsetsWithLeft:10.0 top:0.0 right:10.0 bottom:0.0]; 60 | 61 | chart.legend.enabled = NO; 62 | 63 | chart.leftAxis.enabled = NO; 64 | chart.rightAxis.enabled = NO; 65 | chart.xAxis.enabled = NO; 66 | 67 | chart.data = data; 68 | 69 | [chart animateWithXAxisDuration:2.5]; 70 | } 71 | 72 | - (void)didReceiveMemoryWarning 73 | { 74 | [super didReceiveMemoryWarning]; 75 | // Dispose of any resources that can be recreated. 76 | } 77 | 78 | - (LineChartData *)dataWithCount:(int)count range:(double)range 79 | { 80 | NSMutableArray *xVals = [[NSMutableArray alloc] init]; 81 | 82 | for (int i = 0; i < count; i++) 83 | { 84 | [xVals addObject:[@(i % 12) stringValue]]; 85 | } 86 | 87 | NSMutableArray *yVals = [[NSMutableArray alloc] init]; 88 | 89 | for (int i = 0; i < count; i++) 90 | { 91 | double val = (double) (arc4random_uniform(range)) + 3; 92 | [yVals addObject:[[ChartDataEntry alloc] initWithValue:val xIndex:i]]; 93 | } 94 | 95 | LineChartDataSet *set1 = [[LineChartDataSet alloc] initWithYVals:yVals label:@"DataSet 1"]; 96 | 97 | set1.lineWidth = 1.75; 98 | set1.circleRadius = 3.0; 99 | [set1 setColor:UIColor.whiteColor]; 100 | [set1 setCircleColor:UIColor.whiteColor]; 101 | set1.highlightColor = UIColor.whiteColor; 102 | set1.drawValuesEnabled = NO; 103 | 104 | return [[LineChartData alloc] initWithXVals:xVals dataSet:set1]; 105 | } 106 | 107 | #pragma mark - ChartViewDelegate 108 | 109 | - (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartDataEntry * __nonnull)entry dataSetIndex:(NSInteger)dataSetIndex highlight:(ChartHighlight * __nonnull)highlight 110 | { 111 | NSLog(@"chartValueSelected"); 112 | } 113 | 114 | - (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView 115 | { 116 | NSLog(@"chartValueNothingSelected"); 117 | } 118 | 119 | @end 120 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/CombinedChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CombinedChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface CombinedChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/CombinedChartViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/CubicLineChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CubicLineChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface CubicLineChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/HorizontalBarChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HorizontalBarChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface HorizontalBarChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/LineChart1ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // LineChart1ViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface LineChart1ViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/LineChart2ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // LineChart2ViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface LineChart2ViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/MultipleBarChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MultipleBarChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface MultipleBarChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/MultipleLinesChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MultipleLinesChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface MultipleLinesChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/NegativeStackedBarChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NegativeStackedBarChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface NegativeStackedBarChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/NegativeStackedBarChartViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/PieChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PieChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface PieChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/RadarChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RadarChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface RadarChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/RadarChartViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/ScatterChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ScatterChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface ScatterChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/SinusBarChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SinusBarChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface SinusBarChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Classes/Demos/StackedBarChartViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // StackedBarChartViewController.h 3 | // ChartsDemo 4 | // 5 | // Created by Daniel Cohen Gindi on 17/3/15. 6 | // 7 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 8 | // A port of MPAndroidChart for iOS 9 | // Licensed under Apache License 2.0 10 | // 11 | // https://github.com/danielgindi/ios-charts 12 | // 13 | 14 | #import 15 | #import "DemoBaseViewController.h" 16 | #import 17 | 18 | @interface StackedBarChartViewController : DemoBaseViewController 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-29@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-29@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-40@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-40@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-60@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-60@3x.png", 37 | "scale" : "3x" 38 | } 39 | ], 40 | "info" : { 41 | "version" : 1, 42 | "author" : "xcode" 43 | } 44 | } -------------------------------------------------------------------------------- /ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Icon-29@2x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Icon-29@3x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Icon-40@3x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "extent" : "full-screen", 5 | "idiom" : "iphone", 6 | "subtype" : "736h", 7 | "filename" : "Default-736h@3x.png", 8 | "minimum-system-version" : "8.0", 9 | "orientation" : "portrait", 10 | "scale" : "3x" 11 | }, 12 | { 13 | "extent" : "full-screen", 14 | "idiom" : "iphone", 15 | "subtype" : "667h", 16 | "filename" : "Default-667h@2x.png", 17 | "minimum-system-version" : "8.0", 18 | "orientation" : "portrait", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "orientation" : "portrait", 23 | "idiom" : "iphone", 24 | "extent" : "full-screen", 25 | "minimum-system-version" : "7.0", 26 | "filename" : "Default@2x.png", 27 | "scale" : "2x" 28 | }, 29 | { 30 | "extent" : "full-screen", 31 | "idiom" : "iphone", 32 | "subtype" : "retina4", 33 | "filename" : "Default-568h@2x.png", 34 | "minimum-system-version" : "7.0", 35 | "orientation" : "portrait", 36 | "scale" : "2x" 37 | } 38 | ], 39 | "info" : { 40 | "version" : 1, 41 | "author" : "xcode" 42 | } 43 | } -------------------------------------------------------------------------------- /ChartsDemo/Resources/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/Images.xcassets/LaunchImage.launchimage/Default-667h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/Images.xcassets/LaunchImage.launchimage/Default-667h@2x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/Images.xcassets/LaunchImage.launchimage/Default-736h@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/Images.xcassets/LaunchImage.launchimage/Default-736h@3x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/Images.xcassets/LaunchImage.launchimage/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/Images.xcassets/LaunchImage.launchimage/Default@2x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/app-icon/Icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/app-icon/Icon-29@2x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/app-icon/Icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/app-icon/Icon-29@3x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/app-icon/Icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/app-icon/Icon-40@2x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/app-icon/Icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/app-icon/Icon-40@3x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/app-icon/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/app-icon/Icon-60@2x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/app-icon/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/app-icon/Icon-60@3x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/app-icon/iTunesArtwork: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/app-icon/iTunesArtwork -------------------------------------------------------------------------------- /ChartsDemo/Resources/app-icon/iTunesArtwork@2x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/app-icon/iTunesArtwork@2x -------------------------------------------------------------------------------- /ChartsDemo/Resources/launch-image/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/launch-image/Default-568h@2x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/launch-image/Default-667h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/launch-image/Default-667h@2x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/launch-image/Default-736h@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/launch-image/Default-736h@3x.png -------------------------------------------------------------------------------- /ChartsDemo/Resources/launch-image/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmartlabs/ios-charts/141c18c16df41e485ab400adc94e9b7d214ff5b5/ChartsDemo/Resources/launch-image/Default@2x.png -------------------------------------------------------------------------------- /ChartsDemo/Supporting Files/ChartsDemo-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /ChartsDemo/Supporting Files/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /ChartsDemo/Supporting Files/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Charts 4 | // 5 | // Created by Daniel Cohen Gindi on 23/2/15. 6 | 7 | // 8 | // Copyright 2015 Daniel Cohen Gindi & Philipp Jahoda 9 | // A port of MPAndroidChart for iOS 10 | // Licensed under Apache License 2.0 11 | // 12 | // https://github.com/danielgindi/ios-charts 13 | // 14 | 15 | #import 16 | #import "AppDelegate.h" 17 | 18 | int main(int argc, char * argv[]) { 19 | @autoreleasepool { 20 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 21 | } 22 | } 23 | --------------------------------------------------------------------------------