├── .gitignore ├── LICENSE ├── README.md ├── TWRCharts.podspec ├── TWRCharts ├── ChartNew.min.js ├── TWRBarChart.h ├── TWRBarChart.m ├── TWRChart.h ├── TWRChartBuilder.h ├── TWRChartBuilder.m ├── TWRChartView.h ├── TWRChartView.m ├── TWRCircularChart.h ├── TWRCircularChart.m ├── TWRDataSet+Strings.h ├── TWRDataSet+Strings.m ├── TWRDataSet.h ├── TWRDataSet.m ├── TWRLineChart.h ├── TWRLineChart.m ├── UIColor+HexString.h ├── UIColor+HexString.m └── index.html └── TWRChartsDemo ├── ChartJS.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── ChartJS.xccheckout ├── ChartJS ├── Base.lproj │ └── Main.storyboard ├── ChartJS-Info.plist ├── ChartJS-Prefix.pch ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── TWRAppDelegate.h ├── TWRAppDelegate.m ├── TWRBarChart.h ├── TWRBarChart.m ├── TWRChart.h ├── TWRChartBuilder.h ├── TWRChartBuilder.m ├── TWRChartView.h ├── TWRChartView.m ├── TWRCircularChart.h ├── TWRCircularChart.m ├── TWRDataSet+Strings.h ├── TWRDataSet+Strings.m ├── TWRDataSet.h ├── TWRDataSet.m ├── TWRLineChart.h ├── TWRLineChart.m ├── TWRViewController.h ├── TWRViewController.m ├── UIColor+HexString.h ├── UIColor+HexString.m ├── en.lproj │ └── InfoPlist.strings ├── index.js └── main.m └── ChartJSTests ├── ChartJSTests-Info.plist ├── ChartJSTests.m └── en.lproj └── InfoPlist.strings /.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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Michelangelo Chasseur. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | TWRCharts 2 | ================= 3 | 4 | ## TWRCharts 5 | 6 | An Obj-C wrapper for ChartJS. Easily build animated charts by leveraging the power of native code. 7 | 8 | TWRCharts is yet another charting library for iOS. TWRCharts is basically an effort to port the famous ChartJS Javascript library to native Obj-C code; its power lies in the fact that it gives developers the flexibility to choose between loading a ChartJS Javascript file (more on this later) into a TWRChartView, or using native methods to build either a line / bar or circular (pie / doughnut) chart. 9 | 10 | Loading the chart from a Javascript file is very easy though little configurable and dynamic, whereas by using the native extension the user can update and refresh data on the fly. The final choice is up to you! 11 | 12 | Native code API does not yet support all type of charts provided by ChartJS; only line, bars, pies and doughnuts are currently available. 13 | 14 | TWRCharts's main class is ```TWRChartView```, a subclass of ```UIWebView``` backed by an HTML file that the user never has to deal with. The API has been engineered to make it feel like a fully native experience, both from a developer and an end user point of view. 15 | 16 | ![TWRCharts Demo](http://cocoahunter-blog.s3.amazonaws.com/TWRCharts/twrcharts_optimized.gif) 17 | 18 | ## Usage 19 | 20 | Usage is easy. 21 | 22 | Add the dependency to your `Podfile`: 23 | 24 | ```ruby 25 | platform :ios 26 | pod 'TWRCharts' 27 | ``` 28 | 29 | Run `pod install` to install the dependencies. 30 | 31 | Next, import the header file wherever you want to use the custom view: 32 | 33 | ```objc 34 | #import 35 | ``` 36 | 37 | In the Xcode target "Build Phases" add the files (index.html and Chart.js) under "Copy Bundle Resources". 38 | 39 | ### Creating the chart view 40 | 41 | Just declare a ```TWRChartView``` property in your header file and instantiate it as you would do with a normal view by defining its frame rect. Then just add it to your controller's view hierarchy. 42 | 43 | ```objc 44 | // Chart View 45 | _chartView = [[TWRChartView alloc] initWithFrame:CGRectMake(0, 64, 320, 300)]; 46 | 47 | // Optionally assign here a JS file (see below) 48 | 49 | // Add the chart view to the controller's view 50 | [self.view addSubview:_chartView]; 51 | ``` 52 | 53 | ### Loading a chart from a JS file 54 | 55 | Drop in your Xcode project a .js file and make sure it's been added to the resources that are being bundled with the project in the build phases of your project. 56 | 57 | Then just get a handle on the file and set its path to the TWRChartView that's being added to the controller's view. 58 | 59 | ```objc 60 | NSString *jsFilePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"js"]; 61 | [_chartView setChartJsFilePath:jsFilePath]; 62 | ``` 63 | 64 | You can use any of the chart types currently supported by [ChartJS](http://www.chartjs.org). Here's an example of how you would load a Polar Chart. 65 | 66 | ```js 67 | var context = document.getElementById("canvas").getContext("2d"); 68 | var polarData = [ 69 | { 70 | value : 30, 71 | color: "#D97041" 72 | }, 73 | { 74 | value : 90, 75 | color: "#C7604C" 76 | }, 77 | { 78 | value : 24, 79 | color: "#21323D" 80 | }, 81 | { 82 | value : 58, 83 | color: "#9D9B7F" 84 | }, 85 | { 86 | value : 82, 87 | color: "#7D4F6D" 88 | }, 89 | { 90 | value : 8, 91 | color: "#584A5E" 92 | } 93 | ] 94 | 95 | var polarArea = new Chart(context).PolarArea(polarData); 96 | ``` 97 | 98 | If you're planning on to use JS files to load your charts, be sure to make the following as the first line of your *.js* file: 99 | 100 | ```js 101 | var context = document.getElementById("canvas").getContext("2d"); 102 | ``` 103 | 104 | This code retrieves the correct context from the HTML file that backs the TWRChartView. 105 | 106 | ### Loading a chart using native Obj-C code 107 | 108 | Depending on the type of chart you want to plot (bar / line / pie...) you need to instantiate different objects, but mainly you need to follow these steps: 109 | 110 | - Instantiate data objects; 111 | - Instantiate a chart object by passing the data objects along with labels; 112 | - Load the chart object onto the chart view. 113 | 114 | Here's some example code: 115 | 116 | ```objc 117 | // Build chart data 118 | TWRDataSet *dataSet1 = [[TWRDataSet alloc] initWithDataPoints:@[@10, @15, @5, @15, @5]]; 119 | TWRDataSet *dataSet2 = [[TWRDataSet alloc] initWithDataPoints:@[@5, @10, @5, @15, @10]]; 120 | 121 | NSArray *labels = @[@"A", @"B", @"C", @"D", @"E"]; 122 | 123 | // Instantiate the chart object 124 | TWRLineChart *line = [[TWRLineChart alloc] initWithLabels:labels 125 | dataSets:@[dataSet1, dataSet2] 126 | animated:NO]; 127 | 128 | // Load the chart object onto the view 129 | [_chartView loadLineChart:line]; 130 | ``` 131 | 132 | #### Data Sets 133 | 134 | TWRDataSet (which represents the data for bar and line charts) can be instantiated with the following *init* method: 135 | 136 | ```objc 137 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints 138 | fillColor:(UIColor *)fillColor 139 | strokeColor:(UIColor *)strokeColor 140 | pointColor:(UIColor *)pointColor 141 | pointStrokeColor:(UIColor *)pointStrokeColor; 142 | ``` 143 | 144 | You can customize the fill and stroke colors for either the bar or the line chart. For the latter one you can also choose the point fill and point stroke colors. 145 | 146 | At a minimum you have to provide the data points, which is an array of NSNumbers. 147 | 148 | #### Line / Bar Charts 149 | 150 | Line and bar charts can be instantiated as such: 151 | 152 | ```objc 153 | - (instancetype)initWithLabels:(NSArray *)labels 154 | dataSets:(NSArray *)dataSets 155 | animated:(BOOL)animated; 156 | ``` 157 | 158 | When passing the chart objects to the chart view, you need to call one of the following methods called on your instance of ```TWRChartView``` according to the type of object you are dealing with: 159 | 160 | ```objc 161 | - (void)loadBarChart:(TWRBarChart *)barChart; 162 | - (void)loadLineChart:(TWRLineChart *)lineChart; 163 | ``` 164 | 165 | A sweet final touch: you even have an option to call the above methods with a completion handler to get a callback whenever the chart animation finishes. You wouldn't even guess that there's a bunch of Javascript code running underneath! 166 | 167 | ```objc 168 | - (void)loadBarChart:(TWRBarChart *)barChart withCompletionHandler:(TWRAnimationCompletionBlock)block; 169 | - (void)loadLineChart:(TWRLineChart *)lineChart withCompletionHandler:(TWRAnimationCompletionBlock)block; 170 | ``` 171 | 172 | #### Circular Charts 173 | 174 | And finally, circular charts can be instantiated with the following method: 175 | 176 | ```objc 177 | - (instancetype)initWithValues:(NSArray *)values 178 | colors:(NSArray *)colors 179 | type:(TWRCircularChartType)type 180 | animated:(BOOL)animated; 181 | ``` 182 | 183 | You even get a chance to choose the chart type, either a pie chart (TWRCircularChartTypePie) or a doughnut (TWRCircularChartTypeDoughnut). 184 | 185 | And again, once you have the chart object, you can add it to the chart view with one of the following two methods called on your instance of ```TWRChartView```: 186 | 187 | ```objc 188 | - (void)loadCircularChart:(TWRCircularChart *)circularChart; 189 | - (void)loadCircularChart:(TWRCircularChart *)circularChart withCompletionHandler:(TWRAnimationCompletionBlock)block; 190 | ``` 191 | 192 | ## Requirements 193 | 194 | `TWRCharts` requires iOS 6.x or greater. 195 | 196 | 197 | ## License 198 | 199 | Usage is provided under the [MIT License](http://opensource.org/licenses/mit-license.php). See LICENSE for the full details. 200 | -------------------------------------------------------------------------------- /TWRCharts.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "TWRCharts" 4 | s.version = "0.3" 5 | s.summary = "An Obj-C wrapper for ChartJS. Easily build animated charts by leveraging the power of native code." 6 | s.homepage = "https://github.com/chasseurmic/TWRCharts" 7 | 8 | s.license = { :type => 'MIT', :file => 'LICENSE' } 9 | s.author = { "Michelangelo Chasseur" => "chasseurmic@gmail.com" } 10 | s.social_media_url = "http://twitter.com/chasseurmic" 11 | s.source = { 12 | :git => "https://github.com/chasseurmic/TWRCharts.git", 13 | :tag => "0.2" 14 | } 15 | s.resource = ['TWRCharts/*.js', 'TWRCharts/*.html'] 16 | s.platform = :ios, '6.0' 17 | s.source_files = 'TWRCharts/*.{h,m}' 18 | s.requires_arc = true 19 | 20 | end 21 | -------------------------------------------------------------------------------- /TWRCharts/TWRBarChart.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRBarChart.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 22/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | @class TWRDataSet; 11 | 12 | @interface TWRBarChart : NSObject 13 | 14 | @property (copy, nonatomic) NSMutableArray *labels; 15 | @property (copy, nonatomic) NSMutableArray *dataSets; 16 | @property (assign, nonatomic) BOOL animated; 17 | 18 | /** 19 | * Initializing the Bar Chart object 20 | * 21 | * @param labels an NSArray of labels (NSString) to go along with the data 22 | * @param dataSets an NSArray of TWRDataSet objects containing the data to be plotted 23 | * @param animated a BOOL defining whether the chart should be animated or not 24 | * 25 | * @return an instance of TWRBarChart 26 | */ 27 | - (instancetype)initWithLabels:(NSArray *)labels 28 | dataSets:(NSArray *)dataSets 29 | animated:(BOOL)animated; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /TWRCharts/TWRBarChart.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRBarChart.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 22/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRBarChart.h" 10 | 11 | @implementation TWRBarChart 12 | 13 | - (instancetype)initWithLabels:(NSArray *)labels 14 | dataSets:(NSArray *)dataSets 15 | animated:(BOOL)animated { 16 | self = [super init]; 17 | if (self) { 18 | _labels = labels.mutableCopy; 19 | _dataSets = dataSets.mutableCopy; 20 | _animated = animated; 21 | } 22 | return self; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /TWRCharts/TWRChart.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRChart.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 23/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #ifndef ChartJS_TWRChart_h 10 | #define ChartJS_TWRChart_h 11 | 12 | #import "TWRChartView.h" 13 | #import "TWRLineChart.h" 14 | #import "TWRBarChart.h" 15 | #import "TWRCircularChart.h" 16 | #import "TWRDataSet.h" 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /TWRCharts/TWRChartBuilder.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRChartBuilder.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TWRChartBuilder : NSObject 12 | 13 | + (NSString *)buildChartWithElement:(id)element; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /TWRCharts/TWRChartBuilder.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRChartBuilder.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRChartBuilder.h" 10 | #import "TWRLineChart.h" 11 | #import "TWRBarChart.h" 12 | #import "TWRCircularChart.h" 13 | #import "TWRDataSet.h" 14 | #import "TWRDataSet+Strings.h" 15 | #import "UIColor+HexString.h" 16 | 17 | @interface TWRChartBuilder () 18 | 19 | + (NSString *)buildLineChartStringForElement:(TWRLineChart *)element; 20 | + (NSString *)buildBarChartStringForElement:(TWRBarChart *)element; 21 | + (NSString *)buildCircularChartStringForElement:(TWRCircularChart *)element; 22 | 23 | @end 24 | 25 | @implementation TWRChartBuilder 26 | 27 | + (NSString *)buildChartWithElement:(id)element { 28 | __block NSString *retString; 29 | if ([element isKindOfClass:[TWRLineChart class]]) { 30 | retString = [self buildLineChartStringForElement:element]; 31 | } else if ([element isKindOfClass:[TWRBarChart class]]) { 32 | retString = [self buildBarChartStringForElement:element]; 33 | } else if ([element isKindOfClass:[TWRCircularChart class]]) { 34 | retString = [self buildCircularChartStringForElement:element]; 35 | } 36 | 37 | return retString; 38 | } 39 | 40 | #pragma mark - Private API 41 | 42 | + (NSString *)buildLineChartStringForElement:(TWRLineChart *)element { 43 | __block NSString *retString; 44 | retString = @"var context = document.getElementById(\"canvas\").getContext(\"2d\"); var lineChartData = { labels:["; 45 | TWRLineChart *lineChart = (TWRLineChart *)element; 46 | [lineChart.labels enumerateObjectsUsingBlock:^(NSString *label, NSUInteger idx, BOOL *stop) { 47 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"\"%@\"", label]]; 48 | if (idx != lineChart.labels.count - 1) { 49 | retString = [retString stringByAppendingString:@","]; 50 | } else { 51 | // close the array 52 | retString = [retString stringByAppendingString:@"], datasets:["]; 53 | } 54 | }]; 55 | 56 | [lineChart.dataSets enumerateObjectsUsingBlock:^(TWRDataSet *dataset, NSUInteger idx, BOOL *stop) { 57 | NSString *fillColorString = [dataset fillColorString]; 58 | NSString *strokeColorString = [dataset strokeColorString]; 59 | NSString *pointColorString = [dataset pointColorString]; 60 | NSString *pointStrokeColorString = [dataset pointStrokeColorString]; 61 | NSString *dataString = [dataset dataString]; 62 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"{fillColor:%@,strokeColor:%@,pointColor:%@,pointStrokeColor:%@,data:%@}", fillColorString, strokeColorString, pointColorString, pointStrokeColorString, dataString]]; 63 | if (idx != lineChart.dataSets.count - 1) { 64 | retString = [retString stringByAppendingString:@","]; 65 | } else { 66 | retString = [retString stringByAppendingString:@"]};"]; 67 | } 68 | }]; 69 | 70 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"var options = {animation:%@, bezierCurve :%@};", lineChart.animated ? @"true" : @"false", lineChart.curveLines ? @"true" : @"false"]]; 71 | retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Line(lineChartData,options);"]; 72 | return retString; 73 | } 74 | 75 | + (NSString *)buildBarChartStringForElement:(TWRBarChart *)element { 76 | __block NSString *retString; 77 | retString = @"var context = document.getElementById(\"canvas\").getContext(\"2d\"); var barChartData = { labels:["; 78 | TWRBarChart *barChart = (TWRBarChart *)element; 79 | [barChart.labels enumerateObjectsUsingBlock:^(NSString *label, NSUInteger idx, BOOL *stop) { 80 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"\"%@\"", label]]; 81 | if (idx != barChart.labels.count - 1) { 82 | retString = [retString stringByAppendingString:@","]; 83 | } else { 84 | // close the array 85 | retString = [retString stringByAppendingString:@"], datasets:["]; 86 | } 87 | }]; 88 | 89 | [barChart.dataSets enumerateObjectsUsingBlock:^(TWRDataSet *dataset, NSUInteger idx, BOOL *stop) { 90 | NSString *fillColorString = [dataset fillColorString]; 91 | NSString *strokeColorString = [dataset strokeColorString]; 92 | NSString *pointColorString = [dataset pointColorString]; 93 | NSString *pointStrokeColorString = [dataset pointStrokeColorString]; 94 | NSString *dataString = [dataset dataString]; 95 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"{fillColor:%@,strokeColor:%@,pointColor:%@,pointStrokeColor:%@,data:%@}", fillColorString, strokeColorString, pointColorString, pointStrokeColorString, dataString]]; 96 | if (idx != barChart.dataSets.count - 1) { 97 | retString = [retString stringByAppendingString:@","]; 98 | } else { 99 | retString = [retString stringByAppendingString:@"]};"]; 100 | } 101 | }]; 102 | 103 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"var options = {animation:%@};", barChart.animated ? @"true" : @"false"]]; 104 | retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Bar(barChartData,options);"]; 105 | return retString; 106 | } 107 | 108 | + (NSString *)buildCircularChartStringForElement:(TWRCircularChart *)element { 109 | __block NSString *retString; 110 | retString = @"var context = document.getElementById(\"canvas\").getContext(\"2d\"); var pieChartData = ["; 111 | TWRCircularChart *pieChart = (TWRCircularChart *)element; 112 | [pieChart.values enumerateObjectsUsingBlock:^(NSNumber *number, NSUInteger idx, BOOL *stop) { 113 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"{value:%@, color:\"%@\"}",number, [(UIColor *)pieChart.colors[idx] hexString]]]; 114 | if (idx != pieChart.values.count - 1) { 115 | retString = [retString stringByAppendingString:@","]; 116 | } else { 117 | retString = [retString stringByAppendingString:@"];"]; 118 | } 119 | }]; 120 | retString = [retString stringByAppendingString:@"function onFinish(){document.getElementById('callback').click();};"]; 121 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"var options = {animation:%@, onAnimationComplete:%@};", pieChart.animated ? @"true" : @"false", @"onFinish"]]; 122 | 123 | // Doughnut or Pie 124 | if (pieChart.type == TWRCircularChartTypePie) { 125 | retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Pie(pieChartData, options);"]; 126 | } else if (pieChart.type == TWRCircularChartTypeDoughnut) { 127 | retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Doughnut(pieChartData,options);"]; 128 | } 129 | 130 | return retString; 131 | } 132 | 133 | @end 134 | -------------------------------------------------------------------------------- /TWRCharts/TWRChartView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRChartView.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | typedef void(^TWRAnimationCompletionBlock)(BOOL finished); 10 | 11 | #import 12 | @class TWRBarChart; 13 | @class TWRLineChart; 14 | @class TWRCircularChart; 15 | 16 | @interface TWRChartView : UIWebView 17 | 18 | @property (copy, nonatomic) NSString *chartJsFilePath; 19 | 20 | /** 21 | * Loading a Bar chart 22 | * 23 | * @param barChart the TWRBarChart object that needs to be drawn by the view 24 | */ 25 | - (void)loadBarChart:(TWRBarChart *)barChart; 26 | 27 | /** 28 | * Loading a Bar chart 29 | * 30 | * @param barChart the TWRBarChart object that needs to be drawn by the view 31 | * @param block the completion block that gets called once the animation has completed 32 | */ 33 | - (void)loadBarChart:(TWRBarChart *)barChart withCompletionHandler:(TWRAnimationCompletionBlock)block; 34 | 35 | /** 36 | * Loading a Line chart 37 | * 38 | * @param lineChart the TWRLineChart object that needs to be drawn by the view 39 | */ 40 | - (void)loadLineChart:(TWRLineChart *)lineChart; 41 | 42 | /** 43 | * Loading a Line chart 44 | * 45 | * @param lineChart the TWRLineChart object that needs to be drawn by the view 46 | * @param block the completion block that gets called once the animation has completed 47 | */ 48 | - (void)loadLineChart:(TWRLineChart *)lineChart withCompletionHandler:(TWRAnimationCompletionBlock)block; 49 | 50 | /** 51 | * Loading a Circular chart 52 | * 53 | * @param circularChart the TWRCircularChart object that needs to be drawn by the view 54 | */ 55 | - (void)loadCircularChart:(TWRCircularChart *)circularChart; 56 | 57 | /** 58 | * Loading a Circular chart 59 | * 60 | * @param circularChart the TWRCircularChart object that needs to be drawn by the view 61 | * @param block the completion block that gets called once the animation has completed 62 | */ 63 | - (void)loadCircularChart:(TWRCircularChart *)circularChart withCompletionHandler:(TWRAnimationCompletionBlock)block; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /TWRCharts/TWRChartView.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRChartView.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRChartView.h" 10 | #import "TWRLineChart.h" 11 | #import "TWRBarChart.h" 12 | #import "TWRChartBuilder.h" 13 | #import "TWRCircularChart.h" 14 | 15 | @interface TWRChartView () 16 | 17 | @property (copy, nonatomic) NSString *htmlFilePath; 18 | @property (copy, nonatomic) NSString *jsFileString; 19 | @property (copy, nonatomic) TWRAnimationCompletionBlock block; 20 | 21 | @end 22 | 23 | @implementation TWRChartView 24 | 25 | - (id)initWithFrame:(CGRect)frame 26 | { 27 | self = [super initWithFrame:frame]; 28 | if (self) { 29 | // Initialization code 30 | [self commonInit]; 31 | } 32 | return self; 33 | } 34 | 35 | - (id)initWithCoder:(NSCoder *)coder 36 | { 37 | self = [super initWithCoder:coder]; 38 | if ( self ) 39 | { 40 | [self commonInit]; 41 | } 42 | 43 | return self; 44 | } 45 | 46 | 47 | - (id)init 48 | { 49 | self = [super init]; 50 | if ( self ) 51 | { 52 | [self commonInit]; 53 | } 54 | 55 | return self; 56 | } 57 | 58 | - (void)commonInit { 59 | // Setting self as the delegate 60 | self.delegate = self; 61 | 62 | // Let the view be transparent 63 | self.opaque = NO; 64 | 65 | // HTML index file 66 | 67 | NSString *htmlFilePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; 68 | _htmlFilePath = htmlFilePath; 69 | self.userInteractionEnabled = NO; 70 | } 71 | 72 | - (void)didMoveToSuperview { 73 | // Init request 74 | NSError *error; 75 | 76 | // Load Javascript and store it in local ivar 77 | _jsFileString = [NSString stringWithContentsOfFile:_chartJsFilePath encoding:NSUTF8StringEncoding error:&error]; 78 | 79 | [self loadIndex]; 80 | // [self loadRequest:request]; 81 | } 82 | 83 | - (void)loadBarChart:(TWRBarChart *)barChart { 84 | if ([barChart isKindOfClass:[TWRBarChart class]] ) { 85 | _jsFileString = [TWRChartBuilder buildChartWithElement:barChart]; 86 | [self stringByEvaluatingJavaScriptFromString:_jsFileString]; 87 | [self loadIndex]; 88 | } else { 89 | NSException *exception = [NSException exceptionWithName:@"TWRChartInvalicChartElement" 90 | reason:@"The element object provided to the chart view is not a valid bar chart." 91 | userInfo:nil]; 92 | [exception raise]; 93 | } 94 | } 95 | 96 | - (void)loadBarChart:(TWRBarChart *)barChart withCompletionHandler:(TWRAnimationCompletionBlock)block { 97 | _block = block; 98 | [self loadBarChart:barChart]; 99 | } 100 | 101 | - (void)loadLineChart:(TWRLineChart *)lineChart { 102 | if ([lineChart isKindOfClass:[TWRLineChart class]]) { 103 | _jsFileString = [TWRChartBuilder buildChartWithElement:lineChart]; 104 | [self stringByEvaluatingJavaScriptFromString:_jsFileString]; 105 | [self loadIndex]; 106 | } else { 107 | NSException *exception = [NSException exceptionWithName:@"TWRChartInvalicChartElement" 108 | reason:@"The element object provided to the chart view is not a valid line chart." 109 | userInfo:nil]; 110 | [exception raise]; 111 | } 112 | } 113 | 114 | - (void)loadLineChart:(TWRLineChart *)lineChart withCompletionHandler:(TWRAnimationCompletionBlock)block { 115 | _block = block; 116 | [self loadLineChart:lineChart]; 117 | } 118 | 119 | - (void)loadCircularChart:(TWRCircularChart *)circularChart { 120 | if ([circularChart isKindOfClass:[TWRCircularChart class]]) { 121 | _jsFileString = [TWRChartBuilder buildChartWithElement:circularChart]; 122 | [self stringByEvaluatingJavaScriptFromString:_jsFileString]; 123 | [self loadIndex]; 124 | } else { 125 | NSException *exception = [NSException exceptionWithName:@"TWRChartInvalicChartElement" 126 | reason:@"The element object provided to the chart view is not a valid circular chart." 127 | userInfo:nil]; 128 | [exception raise]; 129 | } 130 | } 131 | 132 | - (void)loadCircularChart:(TWRCircularChart *)circularChart withCompletionHandler:(TWRAnimationCompletionBlock)block { 133 | _block = block; 134 | [self loadCircularChart:circularChart]; 135 | } 136 | 137 | #pragma mark - Private API 138 | 139 | - (void)loadIndex { 140 | NSError *error; 141 | // Load index.html 142 | NSString *htmlString = [NSString stringWithContentsOfFile:_htmlFilePath encoding:NSUTF8StringEncoding error:&error]; 143 | 144 | // Set canvas size according to frame dimensions. Leave space for labels at the bottom. 145 | NSString *canvasString = [NSString stringWithFormat:@"", (int)CGRectGetHeight(self.frame)-20, (int)CGRectGetWidth(self.frame) - 10]; 146 | htmlString = [htmlString stringByReplacingOccurrencesOfString:@"" withString:canvasString]; 147 | 148 | // Load it! 149 | [self loadHTMLString:htmlString baseURL:[[NSBundle mainBundle] bundleURL]]; 150 | } 151 | 152 | #pragma mark - Web View Delegate methods 153 | 154 | -(void)webViewDidFinishLoad:(UIWebView *)webView { 155 | [self stringByEvaluatingJavaScriptFromString:_jsFileString]; 156 | } 157 | 158 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { 159 | // Listen for Javasrcipt callback when chart ends animation 160 | if ( [[[request URL] scheme] isEqualToString:@"callback"] ) { 161 | if (_block) { 162 | _block(YES); 163 | } 164 | return NO; 165 | } 166 | return YES; 167 | } 168 | 169 | @end 170 | -------------------------------------------------------------------------------- /TWRCharts/TWRCircularChart.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRPieChart.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 22/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | typedef NS_ENUM(NSUInteger, TWRCircularChartType) { 10 | TWRCircularChartTypePie = 0, 11 | TWRCircularChartTypeDoughnut 12 | }; 13 | 14 | #import 15 | 16 | @interface TWRCircularChart : NSObject 17 | 18 | @property (copy, nonatomic) NSMutableArray *values; 19 | @property (copy, nonatomic) NSMutableArray *colors; 20 | @property (assign, nonatomic) BOOL animated; 21 | @property (assign, nonatomic) TWRCircularChartType type; 22 | 23 | /** 24 | * Initializing the Circular Chart object 25 | * 26 | * @param values an array of NSNumber objects that represent the data to be plotted 27 | * @param colors an array of UIColor objects to go along with the previously provided data 28 | * @param type the type of the circular chart to be instantiated, either a Pie chart or a Doughnut chart 29 | * @param animated a BOOL defining whether the chart should be animated or not 30 | * 31 | * @return an instance of TWRCircularChart 32 | */ 33 | - (instancetype)initWithValues:(NSArray *)values 34 | colors:(NSArray *)colors 35 | type:(TWRCircularChartType)type 36 | animated:(BOOL)animated; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /TWRCharts/TWRCircularChart.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRPieChart.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 22/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRCircularChart.h" 10 | 11 | @implementation TWRCircularChart 12 | 13 | - (instancetype)initWithValues:(NSArray *)values 14 | colors:(NSArray *)colors 15 | type:(TWRCircularChartType)type 16 | animated:(BOOL)animated { 17 | self = [super init]; 18 | if (self) { 19 | _values = values.mutableCopy; 20 | _colors = colors.mutableCopy; 21 | _type = type; 22 | _animated = animated; 23 | } 24 | return self; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /TWRCharts/TWRDataSet+Strings.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRDataSet+Strings.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 22/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRDataSet.h" 10 | 11 | @interface TWRDataSet (Strings) 12 | 13 | - (NSString *)fillColorString; 14 | - (NSString *)strokeColorString; 15 | - (NSString *)pointColorString; 16 | - (NSString *)pointStrokeColorString; 17 | - (NSString *)dataString; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /TWRCharts/TWRDataSet+Strings.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRDataSet+Strings.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 22/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRDataSet+Strings.h" 10 | 11 | @implementation TWRDataSet (Strings) 12 | 13 | - (NSString *)fillColorString { 14 | CGFloat red; 15 | CGFloat green; 16 | CGFloat blue; 17 | CGFloat alpha; 18 | BOOL valid = [self.fillColor getRed:&red green:&green blue:&blue alpha:&alpha]; 19 | NSString *retString; 20 | if (valid) { 21 | retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha]; 22 | } 23 | return retString; 24 | } 25 | 26 | - (NSString *)strokeColorString { 27 | CGFloat red; 28 | CGFloat green; 29 | CGFloat blue; 30 | CGFloat alpha; 31 | BOOL valid = [self.strokeColor getRed:&red green:&green blue:&blue alpha:&alpha]; 32 | NSString *retString; 33 | if (valid) { 34 | retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha]; 35 | } 36 | return retString; 37 | } 38 | 39 | - (NSString *)pointColorString { 40 | CGFloat red; 41 | CGFloat green; 42 | CGFloat blue; 43 | CGFloat alpha; 44 | BOOL valid = [self.pointColor getRed:&red green:&green blue:&blue alpha:&alpha]; 45 | NSString *retString; 46 | if (valid) { 47 | retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha]; 48 | } 49 | return retString; 50 | } 51 | 52 | - (NSString *)pointStrokeColorString { 53 | CGFloat red; 54 | CGFloat green; 55 | CGFloat blue; 56 | CGFloat alpha; 57 | BOOL valid = [self.pointStrokeColor getRed:&red green:&green blue:&blue alpha:&alpha]; 58 | NSString *retString; 59 | if (valid) { 60 | retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha]; 61 | } 62 | return retString; 63 | } 64 | 65 | - (NSString *)dataString { 66 | __block NSString *retString = @"["; 67 | [self.dataPoints enumerateObjectsUsingBlock:^(NSNumber *number, NSUInteger idx, BOOL *stop) { 68 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"%@", number]]; 69 | if (idx != self.dataPoints.count - 1) { 70 | retString = [retString stringByAppendingString:@","]; 71 | } else { 72 | retString = [retString stringByAppendingString:@"]"]; 73 | } 74 | }]; 75 | return retString; 76 | } 77 | 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /TWRCharts/TWRDataSet.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRDataSet.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TWRDataSet : NSObject 12 | 13 | @property (strong, nonatomic) UIColor *fillColor; 14 | @property (strong, nonatomic) UIColor *strokeColor; 15 | @property (strong, nonatomic) UIColor *pointColor; 16 | @property (strong, nonatomic) UIColor *pointStrokeColor; 17 | @property (copy, nonatomic) NSMutableArray *dataPoints; 18 | 19 | /** 20 | * Initializing the Data Set (Line charts only) 21 | * 22 | * @param dataPoints an array of NSNumber objects representing the data to be plotted 23 | * @param fillColor an array of UIColor objects to go along with the provided data that represent the fill color of the bar / line 24 | * @param strokeColor an array of UIColor objects to go along with the provided data that represent the stroke color of the bar / line 25 | * @param pointColor an array of UIColor objects to go along with the provided data that represent the fill color of line points 26 | * @param pointStrokeColor an array of UIColor objects to go along with the provided data that represent the stroke color of line points 27 | * 28 | * @return an instance of TWRDataSet 29 | */ 30 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints 31 | fillColor:(UIColor *)fillColor 32 | strokeColor:(UIColor *)strokeColor 33 | pointColor:(UIColor *)pointColor 34 | pointStrokeColor:(UIColor *)pointStrokeColor; 35 | 36 | /** 37 | * Initializing the Data Set (Line and Bar charts) 38 | * 39 | * @param dataPoints an array of NSNumber objects representing the data to be plotted 40 | * @param fillColor an array of UIColor objects to go along with the provided data that represent the fill color of the bar / line 41 | * @param strokeColor an array of UIColor objects to go along with the provided data that represent the stroke color of the bar / line 42 | * 43 | * @return an instance of TWRDataSet 44 | */ 45 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints 46 | fillColor:(UIColor *)fillColor 47 | strokeColor:(UIColor *)strokeColor; 48 | 49 | /** 50 | * Initializing the Data Set (Line and Bar charts) 51 | * 52 | * @param dataPoints an array of NSNumber objects representing the data to be plotted 53 | * 54 | * @return an instance of TWRDataSet 55 | */ 56 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /TWRCharts/TWRDataSet.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRDataSet.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRDataSet.h" 10 | 11 | @implementation TWRDataSet 12 | 13 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints { 14 | // Default color: light gray 15 | UIColor *fillColor = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:220/255.0f alpha:0.5]; 16 | UIColor *strokeColor = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:220/255.0f alpha:1.0]; 17 | UIColor *pointColor = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:220/255.0f alpha:1.0]; 18 | UIColor *pointStrokeColor = [UIColor whiteColor]; 19 | self = [self initWithDataPoints:dataPoints fillColor:fillColor strokeColor:strokeColor pointColor:pointColor pointStrokeColor:pointStrokeColor]; 20 | 21 | return self; 22 | } 23 | 24 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints 25 | fillColor:(UIColor *)fillColor 26 | strokeColor:(UIColor *)strokeColor { 27 | UIColor *pointColor = strokeColor; 28 | UIColor *pointStrokeColor = strokeColor; 29 | self = [self initWithDataPoints:dataPoints fillColor:fillColor strokeColor:strokeColor pointColor:pointColor pointStrokeColor:pointStrokeColor]; 30 | 31 | return self; 32 | } 33 | 34 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints 35 | fillColor:(UIColor *)fillColor 36 | strokeColor:(UIColor *)strokeColor 37 | pointColor:(UIColor *)pointColor 38 | pointStrokeColor:(UIColor *)pointStrokeColor { 39 | self = [super init]; 40 | if (self) { 41 | _dataPoints = dataPoints.mutableCopy; 42 | _fillColor = fillColor; 43 | _strokeColor = strokeColor; 44 | _pointColor = pointColor; 45 | _pointStrokeColor = pointStrokeColor; 46 | } 47 | return self; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /TWRCharts/TWRLineChart.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRLineChart.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | @class TWRDataSet; 11 | 12 | @interface TWRLineChart : NSObject 13 | 14 | @property (copy, nonatomic) NSMutableArray *labels; 15 | @property (copy, nonatomic) NSMutableArray *dataSets; 16 | @property (assign, nonatomic) BOOL animated; 17 | @property(nonatomic) BOOL curveLines; 18 | 19 | /** 20 | * Initializing the Line Chart object 21 | * 22 | * @param labels an NSArray of labels (NSString) to go along with the data 23 | * @param dataSets an NSArray of TWRDataSet objects containing the data to be plotted 24 | * @param animated a BOOL defining whether the chart should be animated or not 25 | * 26 | * @return an instance of TWRLineChart 27 | */ 28 | - (instancetype)initWithLabels:(NSArray *)labels 29 | dataSets:(NSArray *)dataSets 30 | animated:(BOOL)animated; 31 | 32 | /** 33 | * Initializing the Line Chart object 34 | * 35 | * @param labels an NSArray of labels (NSString) to go along with the data 36 | * @param dataSets an NSArray of TWRDataSet objects containing the data to be plotted 37 | * @param animated a BOOL defining whether the chart should be animated or not 38 | * @param curved a BOOL defining whether the chart should be curved or not 39 | * 40 | * @return an instance of TWRLineChart 41 | */ 42 | - (instancetype)initWithLabels:(NSArray *)labels 43 | dataSets:(NSArray *)dataSets 44 | animated:(BOOL)animated 45 | curved:(BOOL)curved; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /TWRCharts/TWRLineChart.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRLineChart.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRLineChart.h" 10 | 11 | @interface TWRLineChart () 12 | 13 | @end 14 | 15 | @implementation TWRLineChart 16 | 17 | - (instancetype)initWithLabels:(NSArray *)labels 18 | dataSets:(NSArray *)dataSets 19 | animated:(BOOL)animated { 20 | return [self initWithLabels:labels dataSets:dataSets animated:animated 21 | curved:YES]; 22 | } 23 | 24 | - (instancetype)initWithLabels:(NSArray *)labels 25 | dataSets:(NSArray *)dataSets 26 | animated:(BOOL)animated 27 | curved:(BOOL)curved 28 | { 29 | self = [super init]; 30 | if (self) { 31 | _labels = labels.mutableCopy; 32 | _dataSets = dataSets.mutableCopy; 33 | _animated = animated; 34 | _curveLines = curved; 35 | } 36 | return self; 37 | } 38 | 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /TWRCharts/UIColor+HexString.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HexString.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 23/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIColor (HexString) 12 | 13 | - (NSString *)hexString; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /TWRCharts/UIColor+HexString.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HexString.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 23/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "UIColor+HexString.h" 10 | 11 | @implementation UIColor (HexString) 12 | 13 | - (NSString *)hexString { 14 | const CGFloat *components = CGColorGetComponents(self.CGColor); 15 | CGFloat r = components[0]; 16 | CGFloat g = components[1]; 17 | CGFloat b = components[2]; 18 | NSString *hexString=[NSString stringWithFormat:@"#%02X%02X%02X", (int)(r * 255), (int)(g * 255), (int)(b * 255)]; 19 | return hexString; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /TWRCharts/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 156FFB4E1905956F00DF7D3F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 156FFB4D1905956F00DF7D3F /* Foundation.framework */; }; 11 | 156FFB501905956F00DF7D3F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 156FFB4F1905956F00DF7D3F /* CoreGraphics.framework */; }; 12 | 156FFB521905956F00DF7D3F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 156FFB511905956F00DF7D3F /* UIKit.framework */; }; 13 | 156FFB581905956F00DF7D3F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 156FFB561905956F00DF7D3F /* InfoPlist.strings */; }; 14 | 156FFB5A1905956F00DF7D3F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 156FFB591905956F00DF7D3F /* main.m */; }; 15 | 156FFB5E1905956F00DF7D3F /* TWRAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 156FFB5D1905956F00DF7D3F /* TWRAppDelegate.m */; }; 16 | 156FFB611905956F00DF7D3F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 156FFB5F1905956F00DF7D3F /* Main.storyboard */; }; 17 | 156FFB641905956F00DF7D3F /* TWRViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 156FFB631905956F00DF7D3F /* TWRViewController.m */; }; 18 | 156FFB661905956F00DF7D3F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 156FFB651905956F00DF7D3F /* Images.xcassets */; }; 19 | 156FFB6D1905957000DF7D3F /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 156FFB6C1905957000DF7D3F /* XCTest.framework */; }; 20 | 156FFB6E1905957000DF7D3F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 156FFB4D1905956F00DF7D3F /* Foundation.framework */; }; 21 | 156FFB6F1905957000DF7D3F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 156FFB511905956F00DF7D3F /* UIKit.framework */; }; 22 | 156FFB771905957000DF7D3F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 156FFB751905957000DF7D3F /* InfoPlist.strings */; }; 23 | 156FFB791905957000DF7D3F /* ChartJSTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 156FFB781905957000DF7D3F /* ChartJSTests.m */; }; 24 | 1588B7BA1905B41A00ED1D1B /* index.js in Resources */ = {isa = PBXBuildFile; fileRef = 1588B7B81905B40B00ED1D1B /* index.js */; }; 25 | 159E868E191C02FE002CCE9A /* ChartNew.min.js in Resources */ = {isa = PBXBuildFile; fileRef = 159E868C191C02FE002CCE9A /* ChartNew.min.js */; }; 26 | 159E868F191C02FE002CCE9A /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 159E868D191C02FE002CCE9A /* index.html */; }; 27 | 15D1CB03190D6BB4004F64BE /* TWRBarChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAF1190D6BB4004F64BE /* TWRBarChart.m */; }; 28 | 15D1CB04190D6BB4004F64BE /* TWRChartBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAF4190D6BB4004F64BE /* TWRChartBuilder.m */; }; 29 | 15D1CB05190D6BB4004F64BE /* TWRChartView.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAF6190D6BB4004F64BE /* TWRChartView.m */; }; 30 | 15D1CB06190D6BB4004F64BE /* TWRCircularChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAF8190D6BB4004F64BE /* TWRCircularChart.m */; }; 31 | 15D1CB07190D6BB4004F64BE /* TWRDataSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAFA190D6BB4004F64BE /* TWRDataSet.m */; }; 32 | 15D1CB08190D6BB4004F64BE /* TWRDataSet+Strings.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAFC190D6BB4004F64BE /* TWRDataSet+Strings.m */; }; 33 | 15D1CB09190D6BB4004F64BE /* TWRLineChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAFE190D6BB4004F64BE /* TWRLineChart.m */; }; 34 | 15D1CB0A190D6BB4004F64BE /* UIColor+HexString.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CB00190D6BB4004F64BE /* UIColor+HexString.m */; }; 35 | /* End PBXBuildFile section */ 36 | 37 | /* Begin PBXContainerItemProxy section */ 38 | 156FFB701905957000DF7D3F /* PBXContainerItemProxy */ = { 39 | isa = PBXContainerItemProxy; 40 | containerPortal = 156FFB421905956F00DF7D3F /* Project object */; 41 | proxyType = 1; 42 | remoteGlobalIDString = 156FFB491905956F00DF7D3F; 43 | remoteInfo = ChartJS; 44 | }; 45 | /* End PBXContainerItemProxy section */ 46 | 47 | /* Begin PBXFileReference section */ 48 | 156FFB4A1905956F00DF7D3F /* ChartJS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChartJS.app; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | 156FFB4D1905956F00DF7D3F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 50 | 156FFB4F1905956F00DF7D3F /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 51 | 156FFB511905956F00DF7D3F /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 52 | 156FFB551905956F00DF7D3F /* ChartJS-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ChartJS-Info.plist"; sourceTree = ""; }; 53 | 156FFB571905956F00DF7D3F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 54 | 156FFB591905956F00DF7D3F /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 55 | 156FFB5B1905956F00DF7D3F /* ChartJS-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ChartJS-Prefix.pch"; sourceTree = ""; }; 56 | 156FFB5C1905956F00DF7D3F /* TWRAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TWRAppDelegate.h; sourceTree = ""; }; 57 | 156FFB5D1905956F00DF7D3F /* TWRAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TWRAppDelegate.m; sourceTree = ""; }; 58 | 156FFB601905956F00DF7D3F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 59 | 156FFB621905956F00DF7D3F /* TWRViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TWRViewController.h; sourceTree = ""; }; 60 | 156FFB631905956F00DF7D3F /* TWRViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TWRViewController.m; sourceTree = ""; }; 61 | 156FFB651905956F00DF7D3F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 62 | 156FFB6B1905957000DF7D3F /* ChartJSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ChartJSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 63 | 156FFB6C1905957000DF7D3F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 64 | 156FFB741905957000DF7D3F /* ChartJSTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ChartJSTests-Info.plist"; sourceTree = ""; }; 65 | 156FFB761905957000DF7D3F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 66 | 156FFB781905957000DF7D3F /* ChartJSTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ChartJSTests.m; sourceTree = ""; }; 67 | 1588B7B81905B40B00ED1D1B /* index.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = index.js; sourceTree = ""; }; 68 | 159E868C191C02FE002CCE9A /* ChartNew.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = ChartNew.min.js; path = ../../TWRCharts/ChartNew.min.js; sourceTree = ""; }; 69 | 159E868D191C02FE002CCE9A /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = index.html; path = ../../TWRCharts/index.html; sourceTree = ""; }; 70 | 15D1CAF0190D6BB4004F64BE /* TWRBarChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRBarChart.h; path = ../../TWRCharts/TWRBarChart.h; sourceTree = ""; }; 71 | 15D1CAF1190D6BB4004F64BE /* TWRBarChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TWRBarChart.m; path = ../../TWRCharts/TWRBarChart.m; sourceTree = ""; }; 72 | 15D1CAF2190D6BB4004F64BE /* TWRChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRChart.h; path = ../../TWRCharts/TWRChart.h; sourceTree = ""; }; 73 | 15D1CAF3190D6BB4004F64BE /* TWRChartBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRChartBuilder.h; path = ../../TWRCharts/TWRChartBuilder.h; sourceTree = ""; }; 74 | 15D1CAF4190D6BB4004F64BE /* TWRChartBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TWRChartBuilder.m; path = ../../TWRCharts/TWRChartBuilder.m; sourceTree = ""; }; 75 | 15D1CAF5190D6BB4004F64BE /* TWRChartView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRChartView.h; path = ../../TWRCharts/TWRChartView.h; sourceTree = ""; }; 76 | 15D1CAF6190D6BB4004F64BE /* TWRChartView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TWRChartView.m; path = ../../TWRCharts/TWRChartView.m; sourceTree = ""; }; 77 | 15D1CAF7190D6BB4004F64BE /* TWRCircularChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRCircularChart.h; path = ../../TWRCharts/TWRCircularChart.h; sourceTree = ""; }; 78 | 15D1CAF8190D6BB4004F64BE /* TWRCircularChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TWRCircularChart.m; path = ../../TWRCharts/TWRCircularChart.m; sourceTree = ""; }; 79 | 15D1CAF9190D6BB4004F64BE /* TWRDataSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRDataSet.h; path = ../../TWRCharts/TWRDataSet.h; sourceTree = ""; }; 80 | 15D1CAFA190D6BB4004F64BE /* TWRDataSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TWRDataSet.m; path = ../../TWRCharts/TWRDataSet.m; sourceTree = ""; }; 81 | 15D1CAFB190D6BB4004F64BE /* TWRDataSet+Strings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "TWRDataSet+Strings.h"; path = "../../TWRCharts/TWRDataSet+Strings.h"; sourceTree = ""; }; 82 | 15D1CAFC190D6BB4004F64BE /* TWRDataSet+Strings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "TWRDataSet+Strings.m"; path = "../../TWRCharts/TWRDataSet+Strings.m"; sourceTree = ""; }; 83 | 15D1CAFD190D6BB4004F64BE /* TWRLineChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRLineChart.h; path = ../../TWRCharts/TWRLineChart.h; sourceTree = ""; }; 84 | 15D1CAFE190D6BB4004F64BE /* TWRLineChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TWRLineChart.m; path = ../../TWRCharts/TWRLineChart.m; sourceTree = ""; }; 85 | 15D1CAFF190D6BB4004F64BE /* UIColor+HexString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIColor+HexString.h"; path = "../../TWRCharts/UIColor+HexString.h"; sourceTree = ""; }; 86 | 15D1CB00190D6BB4004F64BE /* UIColor+HexString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIColor+HexString.m"; path = "../../TWRCharts/UIColor+HexString.m"; sourceTree = ""; }; 87 | /* End PBXFileReference section */ 88 | 89 | /* Begin PBXFrameworksBuildPhase section */ 90 | 156FFB471905956F00DF7D3F /* Frameworks */ = { 91 | isa = PBXFrameworksBuildPhase; 92 | buildActionMask = 2147483647; 93 | files = ( 94 | 156FFB501905956F00DF7D3F /* CoreGraphics.framework in Frameworks */, 95 | 156FFB521905956F00DF7D3F /* UIKit.framework in Frameworks */, 96 | 156FFB4E1905956F00DF7D3F /* Foundation.framework in Frameworks */, 97 | ); 98 | runOnlyForDeploymentPostprocessing = 0; 99 | }; 100 | 156FFB681905957000DF7D3F /* Frameworks */ = { 101 | isa = PBXFrameworksBuildPhase; 102 | buildActionMask = 2147483647; 103 | files = ( 104 | 156FFB6D1905957000DF7D3F /* XCTest.framework in Frameworks */, 105 | 156FFB6F1905957000DF7D3F /* UIKit.framework in Frameworks */, 106 | 156FFB6E1905957000DF7D3F /* Foundation.framework in Frameworks */, 107 | ); 108 | runOnlyForDeploymentPostprocessing = 0; 109 | }; 110 | /* End PBXFrameworksBuildPhase section */ 111 | 112 | /* Begin PBXGroup section */ 113 | 156FFB411905956F00DF7D3F = { 114 | isa = PBXGroup; 115 | children = ( 116 | 156FFB531905956F00DF7D3F /* ChartJS */, 117 | 156FFB721905957000DF7D3F /* ChartJSTests */, 118 | 156FFB4C1905956F00DF7D3F /* Frameworks */, 119 | 156FFB4B1905956F00DF7D3F /* Products */, 120 | ); 121 | sourceTree = ""; 122 | }; 123 | 156FFB4B1905956F00DF7D3F /* Products */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 156FFB4A1905956F00DF7D3F /* ChartJS.app */, 127 | 156FFB6B1905957000DF7D3F /* ChartJSTests.xctest */, 128 | ); 129 | name = Products; 130 | sourceTree = ""; 131 | }; 132 | 156FFB4C1905956F00DF7D3F /* Frameworks */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 156FFB4D1905956F00DF7D3F /* Foundation.framework */, 136 | 156FFB4F1905956F00DF7D3F /* CoreGraphics.framework */, 137 | 156FFB511905956F00DF7D3F /* UIKit.framework */, 138 | 156FFB6C1905957000DF7D3F /* XCTest.framework */, 139 | ); 140 | name = Frameworks; 141 | sourceTree = ""; 142 | }; 143 | 156FFB531905956F00DF7D3F /* ChartJS */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 156FFB5C1905956F00DF7D3F /* TWRAppDelegate.h */, 147 | 156FFB5D1905956F00DF7D3F /* TWRAppDelegate.m */, 148 | 156FFB5F1905956F00DF7D3F /* Main.storyboard */, 149 | 156FFB621905956F00DF7D3F /* TWRViewController.h */, 150 | 156FFB631905956F00DF7D3F /* TWRViewController.m */, 151 | 157CF6201905C67100442DFA /* Charts */, 152 | 156FFB651905956F00DF7D3F /* Images.xcassets */, 153 | 156FFB541905956F00DF7D3F /* Supporting Files */, 154 | ); 155 | path = ChartJS; 156 | sourceTree = ""; 157 | }; 158 | 156FFB541905956F00DF7D3F /* Supporting Files */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | 1588B7B81905B40B00ED1D1B /* index.js */, 162 | 156FFB551905956F00DF7D3F /* ChartJS-Info.plist */, 163 | 156FFB561905956F00DF7D3F /* InfoPlist.strings */, 164 | 156FFB591905956F00DF7D3F /* main.m */, 165 | 156FFB5B1905956F00DF7D3F /* ChartJS-Prefix.pch */, 166 | ); 167 | name = "Supporting Files"; 168 | sourceTree = ""; 169 | }; 170 | 156FFB721905957000DF7D3F /* ChartJSTests */ = { 171 | isa = PBXGroup; 172 | children = ( 173 | 156FFB781905957000DF7D3F /* ChartJSTests.m */, 174 | 156FFB731905957000DF7D3F /* Supporting Files */, 175 | ); 176 | path = ChartJSTests; 177 | sourceTree = ""; 178 | }; 179 | 156FFB731905957000DF7D3F /* Supporting Files */ = { 180 | isa = PBXGroup; 181 | children = ( 182 | 156FFB741905957000DF7D3F /* ChartJSTests-Info.plist */, 183 | 156FFB751905957000DF7D3F /* InfoPlist.strings */, 184 | ); 185 | name = "Supporting Files"; 186 | sourceTree = ""; 187 | }; 188 | 157CF6201905C67100442DFA /* Charts */ = { 189 | isa = PBXGroup; 190 | children = ( 191 | 159E868C191C02FE002CCE9A /* ChartNew.min.js */, 192 | 159E868D191C02FE002CCE9A /* index.html */, 193 | 15D1CAF0190D6BB4004F64BE /* TWRBarChart.h */, 194 | 15D1CAF1190D6BB4004F64BE /* TWRBarChart.m */, 195 | 15D1CAF2190D6BB4004F64BE /* TWRChart.h */, 196 | 15D1CAF3190D6BB4004F64BE /* TWRChartBuilder.h */, 197 | 15D1CAF4190D6BB4004F64BE /* TWRChartBuilder.m */, 198 | 15D1CAF5190D6BB4004F64BE /* TWRChartView.h */, 199 | 15D1CAF6190D6BB4004F64BE /* TWRChartView.m */, 200 | 15D1CAF7190D6BB4004F64BE /* TWRCircularChart.h */, 201 | 15D1CAF8190D6BB4004F64BE /* TWRCircularChart.m */, 202 | 15D1CAF9190D6BB4004F64BE /* TWRDataSet.h */, 203 | 15D1CAFA190D6BB4004F64BE /* TWRDataSet.m */, 204 | 15D1CAFB190D6BB4004F64BE /* TWRDataSet+Strings.h */, 205 | 15D1CAFC190D6BB4004F64BE /* TWRDataSet+Strings.m */, 206 | 15D1CAFD190D6BB4004F64BE /* TWRLineChart.h */, 207 | 15D1CAFE190D6BB4004F64BE /* TWRLineChart.m */, 208 | 15D1CAFF190D6BB4004F64BE /* UIColor+HexString.h */, 209 | 15D1CB00190D6BB4004F64BE /* UIColor+HexString.m */, 210 | ); 211 | name = Charts; 212 | sourceTree = ""; 213 | }; 214 | /* End PBXGroup section */ 215 | 216 | /* Begin PBXNativeTarget section */ 217 | 156FFB491905956F00DF7D3F /* ChartJS */ = { 218 | isa = PBXNativeTarget; 219 | buildConfigurationList = 156FFB7C1905957000DF7D3F /* Build configuration list for PBXNativeTarget "ChartJS" */; 220 | buildPhases = ( 221 | 156FFB461905956F00DF7D3F /* Sources */, 222 | 156FFB471905956F00DF7D3F /* Frameworks */, 223 | 156FFB481905956F00DF7D3F /* Resources */, 224 | ); 225 | buildRules = ( 226 | ); 227 | dependencies = ( 228 | ); 229 | name = ChartJS; 230 | productName = ChartJS; 231 | productReference = 156FFB4A1905956F00DF7D3F /* ChartJS.app */; 232 | productType = "com.apple.product-type.application"; 233 | }; 234 | 156FFB6A1905957000DF7D3F /* ChartJSTests */ = { 235 | isa = PBXNativeTarget; 236 | buildConfigurationList = 156FFB7F1905957000DF7D3F /* Build configuration list for PBXNativeTarget "ChartJSTests" */; 237 | buildPhases = ( 238 | 156FFB671905957000DF7D3F /* Sources */, 239 | 156FFB681905957000DF7D3F /* Frameworks */, 240 | 156FFB691905957000DF7D3F /* Resources */, 241 | ); 242 | buildRules = ( 243 | ); 244 | dependencies = ( 245 | 156FFB711905957000DF7D3F /* PBXTargetDependency */, 246 | ); 247 | name = ChartJSTests; 248 | productName = ChartJSTests; 249 | productReference = 156FFB6B1905957000DF7D3F /* ChartJSTests.xctest */; 250 | productType = "com.apple.product-type.bundle.unit-test"; 251 | }; 252 | /* End PBXNativeTarget section */ 253 | 254 | /* Begin PBXProject section */ 255 | 156FFB421905956F00DF7D3F /* Project object */ = { 256 | isa = PBXProject; 257 | attributes = { 258 | CLASSPREFIX = TWR; 259 | LastUpgradeCheck = 0510; 260 | ORGANIZATIONNAME = Touchware; 261 | TargetAttributes = { 262 | 156FFB6A1905957000DF7D3F = { 263 | TestTargetID = 156FFB491905956F00DF7D3F; 264 | }; 265 | }; 266 | }; 267 | buildConfigurationList = 156FFB451905956F00DF7D3F /* Build configuration list for PBXProject "ChartJS" */; 268 | compatibilityVersion = "Xcode 3.2"; 269 | developmentRegion = English; 270 | hasScannedForEncodings = 0; 271 | knownRegions = ( 272 | en, 273 | Base, 274 | ); 275 | mainGroup = 156FFB411905956F00DF7D3F; 276 | productRefGroup = 156FFB4B1905956F00DF7D3F /* Products */; 277 | projectDirPath = ""; 278 | projectRoot = ""; 279 | targets = ( 280 | 156FFB491905956F00DF7D3F /* ChartJS */, 281 | 156FFB6A1905957000DF7D3F /* ChartJSTests */, 282 | ); 283 | }; 284 | /* End PBXProject section */ 285 | 286 | /* Begin PBXResourcesBuildPhase section */ 287 | 156FFB481905956F00DF7D3F /* Resources */ = { 288 | isa = PBXResourcesBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | 159E868F191C02FE002CCE9A /* index.html in Resources */, 292 | 159E868E191C02FE002CCE9A /* ChartNew.min.js in Resources */, 293 | 1588B7BA1905B41A00ED1D1B /* index.js in Resources */, 294 | 156FFB661905956F00DF7D3F /* Images.xcassets in Resources */, 295 | 156FFB581905956F00DF7D3F /* InfoPlist.strings in Resources */, 296 | 156FFB611905956F00DF7D3F /* Main.storyboard in Resources */, 297 | ); 298 | runOnlyForDeploymentPostprocessing = 0; 299 | }; 300 | 156FFB691905957000DF7D3F /* Resources */ = { 301 | isa = PBXResourcesBuildPhase; 302 | buildActionMask = 2147483647; 303 | files = ( 304 | 156FFB771905957000DF7D3F /* InfoPlist.strings in Resources */, 305 | ); 306 | runOnlyForDeploymentPostprocessing = 0; 307 | }; 308 | /* End PBXResourcesBuildPhase section */ 309 | 310 | /* Begin PBXSourcesBuildPhase section */ 311 | 156FFB461905956F00DF7D3F /* Sources */ = { 312 | isa = PBXSourcesBuildPhase; 313 | buildActionMask = 2147483647; 314 | files = ( 315 | 15D1CB09190D6BB4004F64BE /* TWRLineChart.m in Sources */, 316 | 156FFB641905956F00DF7D3F /* TWRViewController.m in Sources */, 317 | 15D1CB06190D6BB4004F64BE /* TWRCircularChart.m in Sources */, 318 | 15D1CB03190D6BB4004F64BE /* TWRBarChart.m in Sources */, 319 | 15D1CB05190D6BB4004F64BE /* TWRChartView.m in Sources */, 320 | 15D1CB04190D6BB4004F64BE /* TWRChartBuilder.m in Sources */, 321 | 15D1CB07190D6BB4004F64BE /* TWRDataSet.m in Sources */, 322 | 15D1CB08190D6BB4004F64BE /* TWRDataSet+Strings.m in Sources */, 323 | 156FFB5E1905956F00DF7D3F /* TWRAppDelegate.m in Sources */, 324 | 156FFB5A1905956F00DF7D3F /* main.m in Sources */, 325 | 15D1CB0A190D6BB4004F64BE /* UIColor+HexString.m in Sources */, 326 | ); 327 | runOnlyForDeploymentPostprocessing = 0; 328 | }; 329 | 156FFB671905957000DF7D3F /* Sources */ = { 330 | isa = PBXSourcesBuildPhase; 331 | buildActionMask = 2147483647; 332 | files = ( 333 | 156FFB791905957000DF7D3F /* ChartJSTests.m in Sources */, 334 | ); 335 | runOnlyForDeploymentPostprocessing = 0; 336 | }; 337 | /* End PBXSourcesBuildPhase section */ 338 | 339 | /* Begin PBXTargetDependency section */ 340 | 156FFB711905957000DF7D3F /* PBXTargetDependency */ = { 341 | isa = PBXTargetDependency; 342 | target = 156FFB491905956F00DF7D3F /* ChartJS */; 343 | targetProxy = 156FFB701905957000DF7D3F /* PBXContainerItemProxy */; 344 | }; 345 | /* End PBXTargetDependency section */ 346 | 347 | /* Begin PBXVariantGroup section */ 348 | 156FFB561905956F00DF7D3F /* InfoPlist.strings */ = { 349 | isa = PBXVariantGroup; 350 | children = ( 351 | 156FFB571905956F00DF7D3F /* en */, 352 | ); 353 | name = InfoPlist.strings; 354 | sourceTree = ""; 355 | }; 356 | 156FFB5F1905956F00DF7D3F /* Main.storyboard */ = { 357 | isa = PBXVariantGroup; 358 | children = ( 359 | 156FFB601905956F00DF7D3F /* Base */, 360 | ); 361 | name = Main.storyboard; 362 | sourceTree = ""; 363 | }; 364 | 156FFB751905957000DF7D3F /* InfoPlist.strings */ = { 365 | isa = PBXVariantGroup; 366 | children = ( 367 | 156FFB761905957000DF7D3F /* en */, 368 | ); 369 | name = InfoPlist.strings; 370 | sourceTree = ""; 371 | }; 372 | /* End PBXVariantGroup section */ 373 | 374 | /* Begin XCBuildConfiguration section */ 375 | 156FFB7A1905957000DF7D3F /* Debug */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | ALWAYS_SEARCH_USER_PATHS = NO; 379 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 380 | CLANG_CXX_LIBRARY = "libc++"; 381 | CLANG_ENABLE_MODULES = YES; 382 | CLANG_ENABLE_OBJC_ARC = YES; 383 | CLANG_WARN_BOOL_CONVERSION = YES; 384 | CLANG_WARN_CONSTANT_CONVERSION = YES; 385 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 386 | CLANG_WARN_EMPTY_BODY = YES; 387 | CLANG_WARN_ENUM_CONVERSION = YES; 388 | CLANG_WARN_INT_CONVERSION = YES; 389 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 390 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 391 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 392 | COPY_PHASE_STRIP = NO; 393 | GCC_C_LANGUAGE_STANDARD = gnu99; 394 | GCC_DYNAMIC_NO_PIC = NO; 395 | GCC_OPTIMIZATION_LEVEL = 0; 396 | GCC_PREPROCESSOR_DEFINITIONS = ( 397 | "DEBUG=1", 398 | "$(inherited)", 399 | ); 400 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 401 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 402 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 403 | GCC_WARN_UNDECLARED_SELECTOR = YES; 404 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 405 | GCC_WARN_UNUSED_FUNCTION = YES; 406 | GCC_WARN_UNUSED_VARIABLE = YES; 407 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 408 | ONLY_ACTIVE_ARCH = YES; 409 | SDKROOT = iphoneos; 410 | }; 411 | name = Debug; 412 | }; 413 | 156FFB7B1905957000DF7D3F /* Release */ = { 414 | isa = XCBuildConfiguration; 415 | buildSettings = { 416 | ALWAYS_SEARCH_USER_PATHS = NO; 417 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 418 | CLANG_CXX_LIBRARY = "libc++"; 419 | CLANG_ENABLE_MODULES = YES; 420 | CLANG_ENABLE_OBJC_ARC = YES; 421 | CLANG_WARN_BOOL_CONVERSION = YES; 422 | CLANG_WARN_CONSTANT_CONVERSION = YES; 423 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 424 | CLANG_WARN_EMPTY_BODY = YES; 425 | CLANG_WARN_ENUM_CONVERSION = YES; 426 | CLANG_WARN_INT_CONVERSION = YES; 427 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 428 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 429 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 430 | COPY_PHASE_STRIP = YES; 431 | ENABLE_NS_ASSERTIONS = NO; 432 | GCC_C_LANGUAGE_STANDARD = gnu99; 433 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 434 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 435 | GCC_WARN_UNDECLARED_SELECTOR = YES; 436 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 437 | GCC_WARN_UNUSED_FUNCTION = YES; 438 | GCC_WARN_UNUSED_VARIABLE = YES; 439 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 440 | SDKROOT = iphoneos; 441 | VALIDATE_PRODUCT = YES; 442 | }; 443 | name = Release; 444 | }; 445 | 156FFB7D1905957000DF7D3F /* Debug */ = { 446 | isa = XCBuildConfiguration; 447 | buildSettings = { 448 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 449 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 450 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 451 | GCC_PREFIX_HEADER = "ChartJS/ChartJS-Prefix.pch"; 452 | INFOPLIST_FILE = "ChartJS/ChartJS-Info.plist"; 453 | PRODUCT_NAME = "$(TARGET_NAME)"; 454 | WRAPPER_EXTENSION = app; 455 | }; 456 | name = Debug; 457 | }; 458 | 156FFB7E1905957000DF7D3F /* Release */ = { 459 | isa = XCBuildConfiguration; 460 | buildSettings = { 461 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 462 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 463 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 464 | GCC_PREFIX_HEADER = "ChartJS/ChartJS-Prefix.pch"; 465 | INFOPLIST_FILE = "ChartJS/ChartJS-Info.plist"; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | WRAPPER_EXTENSION = app; 468 | }; 469 | name = Release; 470 | }; 471 | 156FFB801905957000DF7D3F /* Debug */ = { 472 | isa = XCBuildConfiguration; 473 | buildSettings = { 474 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/ChartJS.app/ChartJS"; 475 | FRAMEWORK_SEARCH_PATHS = ( 476 | "$(SDKROOT)/Developer/Library/Frameworks", 477 | "$(inherited)", 478 | "$(DEVELOPER_FRAMEWORKS_DIR)", 479 | ); 480 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 481 | GCC_PREFIX_HEADER = "ChartJS/ChartJS-Prefix.pch"; 482 | GCC_PREPROCESSOR_DEFINITIONS = ( 483 | "DEBUG=1", 484 | "$(inherited)", 485 | ); 486 | INFOPLIST_FILE = "ChartJSTests/ChartJSTests-Info.plist"; 487 | PRODUCT_NAME = "$(TARGET_NAME)"; 488 | TEST_HOST = "$(BUNDLE_LOADER)"; 489 | WRAPPER_EXTENSION = xctest; 490 | }; 491 | name = Debug; 492 | }; 493 | 156FFB811905957000DF7D3F /* Release */ = { 494 | isa = XCBuildConfiguration; 495 | buildSettings = { 496 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/ChartJS.app/ChartJS"; 497 | FRAMEWORK_SEARCH_PATHS = ( 498 | "$(SDKROOT)/Developer/Library/Frameworks", 499 | "$(inherited)", 500 | "$(DEVELOPER_FRAMEWORKS_DIR)", 501 | ); 502 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 503 | GCC_PREFIX_HEADER = "ChartJS/ChartJS-Prefix.pch"; 504 | INFOPLIST_FILE = "ChartJSTests/ChartJSTests-Info.plist"; 505 | PRODUCT_NAME = "$(TARGET_NAME)"; 506 | TEST_HOST = "$(BUNDLE_LOADER)"; 507 | WRAPPER_EXTENSION = xctest; 508 | }; 509 | name = Release; 510 | }; 511 | /* End XCBuildConfiguration section */ 512 | 513 | /* Begin XCConfigurationList section */ 514 | 156FFB451905956F00DF7D3F /* Build configuration list for PBXProject "ChartJS" */ = { 515 | isa = XCConfigurationList; 516 | buildConfigurations = ( 517 | 156FFB7A1905957000DF7D3F /* Debug */, 518 | 156FFB7B1905957000DF7D3F /* Release */, 519 | ); 520 | defaultConfigurationIsVisible = 0; 521 | defaultConfigurationName = Release; 522 | }; 523 | 156FFB7C1905957000DF7D3F /* Build configuration list for PBXNativeTarget "ChartJS" */ = { 524 | isa = XCConfigurationList; 525 | buildConfigurations = ( 526 | 156FFB7D1905957000DF7D3F /* Debug */, 527 | 156FFB7E1905957000DF7D3F /* Release */, 528 | ); 529 | defaultConfigurationIsVisible = 0; 530 | defaultConfigurationName = Release; 531 | }; 532 | 156FFB7F1905957000DF7D3F /* Build configuration list for PBXNativeTarget "ChartJSTests" */ = { 533 | isa = XCConfigurationList; 534 | buildConfigurations = ( 535 | 156FFB801905957000DF7D3F /* Debug */, 536 | 156FFB811905957000DF7D3F /* Release */, 537 | ); 538 | defaultConfigurationIsVisible = 0; 539 | defaultConfigurationName = Release; 540 | }; 541 | /* End XCConfigurationList section */ 542 | }; 543 | rootObject = 156FFB421905956F00DF7D3F /* Project object */; 544 | } 545 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS.xcodeproj/project.xcworkspace/xcshareddata/ChartJS.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 00E03A49-C07C-4535-B4BA-A21B8C0ABA6D 9 | IDESourceControlProjectName 10 | ChartJS 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | D9970D84-C374-4B68-ADD9-3F22B8947B4D 14 | https://github.com/chasseurmic/TWRCharts.git 15 | 16 | IDESourceControlProjectPath 17 | TWRChartsDemo/ChartJS.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | D9970D84-C374-4B68-ADD9-3F22B8947B4D 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/chasseurmic/TWRCharts.git 25 | IDESourceControlProjectVersion 26 | 110 27 | IDESourceControlProjectWCCIdentifier 28 | D9970D84-C374-4B68-ADD9-3F22B8947B4D 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | D9970D84-C374-4B68-ADD9-3F22B8947B4D 36 | IDESourceControlWCCName 37 | TWRCharts 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 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 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/ChartJS-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | re.touchwa.${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 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/ChartJS-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_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/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 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/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 | } -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRAppDelegate.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TWRAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRAppDelegate.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRAppDelegate.h" 10 | 11 | @implementation TWRAppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // 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. 22 | // 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. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // 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. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // 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. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRBarChart.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRBarChart.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 22/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | @class TWRDataSet; 11 | 12 | @interface TWRBarChart : NSObject 13 | 14 | @property (copy, nonatomic) NSMutableArray *labels; 15 | @property (copy, nonatomic) NSMutableArray *dataSets; 16 | @property (assign, nonatomic) BOOL animated; 17 | 18 | /** 19 | * Initializing the Bar Chart object 20 | * 21 | * @param labels an NSArray of labels (NSString) to go along with the data 22 | * @param dataSets an NSArray of TWRDataSet objects containing the data to be plotted 23 | * @param animated a BOOL defining whether the chart should be animated or not 24 | * 25 | * @return an instance of TWRBarChart 26 | */ 27 | - (instancetype)initWithLabels:(NSArray *)labels 28 | dataSets:(NSArray *)dataSets 29 | animated:(BOOL)animated; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRBarChart.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRBarChart.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 22/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRBarChart.h" 10 | 11 | @implementation TWRBarChart 12 | 13 | - (instancetype)initWithLabels:(NSArray *)labels 14 | dataSets:(NSArray *)dataSets 15 | animated:(BOOL)animated { 16 | self = [super init]; 17 | if (self) { 18 | _labels = labels.mutableCopy; 19 | _dataSets = dataSets.mutableCopy; 20 | _animated = animated; 21 | } 22 | return self; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRChart.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRChart.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 23/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #ifndef ChartJS_TWRChart_h 10 | #define ChartJS_TWRChart_h 11 | 12 | #import "TWRChartView.h" 13 | #import "TWRLineChart.h" 14 | #import "TWRBarChart.h" 15 | #import "TWRCircularChart.h" 16 | #import "TWRDataSet.h" 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRChartBuilder.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRChartBuilder.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TWRChartBuilder : NSObject 12 | 13 | + (NSString *)buildChartWithElement:(id)element; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRChartBuilder.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRChartBuilder.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRChartBuilder.h" 10 | #import "TWRLineChart.h" 11 | #import "TWRBarChart.h" 12 | #import "TWRCircularChart.h" 13 | #import "TWRDataSet.h" 14 | #import "TWRDataSet+Strings.h" 15 | #import "UIColor+HexString.h" 16 | 17 | @interface TWRChartBuilder () 18 | 19 | + (NSString *)buildLineChartStringForElement:(TWRLineChart *)element; 20 | + (NSString *)buildBarChartStringForElement:(TWRBarChart *)element; 21 | + (NSString *)buildCircularChartStringForElement:(TWRCircularChart *)element; 22 | 23 | @end 24 | 25 | @implementation TWRChartBuilder 26 | 27 | + (NSString *)buildChartWithElement:(id)element { 28 | __block NSString *retString; 29 | if ([element isKindOfClass:[TWRLineChart class]]) { 30 | retString = [self buildLineChartStringForElement:element]; 31 | } else if ([element isKindOfClass:[TWRBarChart class]]) { 32 | retString = [self buildBarChartStringForElement:element]; 33 | } else if ([element isKindOfClass:[TWRCircularChart class]]) { 34 | retString = [self buildCircularChartStringForElement:element]; 35 | } 36 | 37 | return retString; 38 | } 39 | 40 | #pragma mark - Private API 41 | 42 | + (NSString *)buildLineChartStringForElement:(TWRLineChart *)element { 43 | __block NSString *retString; 44 | retString = @"var context = document.getElementById(\"canvas\").getContext(\"2d\"); var lineChartData = { labels:["; 45 | TWRLineChart *lineChart = (TWRLineChart *)element; 46 | [lineChart.labels enumerateObjectsUsingBlock:^(NSString *label, NSUInteger idx, BOOL *stop) { 47 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"\"%@\"", label]]; 48 | if (idx != lineChart.labels.count - 1) { 49 | retString = [retString stringByAppendingString:@","]; 50 | } else { 51 | // close the array 52 | retString = [retString stringByAppendingString:@"], datasets:["]; 53 | } 54 | }]; 55 | 56 | [lineChart.dataSets enumerateObjectsUsingBlock:^(TWRDataSet *dataset, NSUInteger idx, BOOL *stop) { 57 | NSString *fillColorString = [dataset fillColorString]; 58 | NSString *strokeColorString = [dataset strokeColorString]; 59 | NSString *pointColorString = [dataset pointColorString]; 60 | NSString *pointStrokeColorString = [dataset pointStrokeColorString]; 61 | NSString *dataString = [dataset dataString]; 62 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"{fillColor:%@,strokeColor:%@,pointColor:%@,pointStrokeColor:%@,data:%@}", fillColorString, strokeColorString, pointColorString, pointStrokeColorString, dataString]]; 63 | if (idx != lineChart.dataSets.count - 1) { 64 | retString = [retString stringByAppendingString:@","]; 65 | } else { 66 | retString = [retString stringByAppendingString:@"]};"]; 67 | } 68 | }]; 69 | 70 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"var options = {animation:%@};", lineChart.animated ? @"true" : @"false"]]; 71 | retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Line(lineChartData,options);"]; 72 | return retString; 73 | } 74 | 75 | + (NSString *)buildBarChartStringForElement:(TWRBarChart *)element { 76 | __block NSString *retString; 77 | retString = @"var context = document.getElementById(\"canvas\").getContext(\"2d\"); var barChartData = { labels:["; 78 | TWRBarChart *barChart = (TWRBarChart *)element; 79 | [barChart.labels enumerateObjectsUsingBlock:^(NSString *label, NSUInteger idx, BOOL *stop) { 80 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"\"%@\"", label]]; 81 | if (idx != barChart.labels.count - 1) { 82 | retString = [retString stringByAppendingString:@","]; 83 | } else { 84 | // close the array 85 | retString = [retString stringByAppendingString:@"], datasets:["]; 86 | } 87 | }]; 88 | 89 | [barChart.dataSets enumerateObjectsUsingBlock:^(TWRDataSet *dataset, NSUInteger idx, BOOL *stop) { 90 | NSString *fillColorString = [dataset fillColorString]; 91 | NSString *strokeColorString = [dataset strokeColorString]; 92 | NSString *pointColorString = [dataset pointColorString]; 93 | NSString *pointStrokeColorString = [dataset pointStrokeColorString]; 94 | NSString *dataString = [dataset dataString]; 95 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"{fillColor:%@,strokeColor:%@,pointColor:%@,pointStrokeColor:%@,data:%@}", fillColorString, strokeColorString, pointColorString, pointStrokeColorString, dataString]]; 96 | if (idx != barChart.dataSets.count - 1) { 97 | retString = [retString stringByAppendingString:@","]; 98 | } else { 99 | retString = [retString stringByAppendingString:@"]};"]; 100 | } 101 | }]; 102 | 103 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"var options = {animation:%@};", barChart.animated ? @"true" : @"false"]]; 104 | retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Bar(barChartData,options);"]; 105 | return retString; 106 | } 107 | 108 | + (NSString *)buildCircularChartStringForElement:(TWRCircularChart *)element { 109 | __block NSString *retString; 110 | retString = @"var context = document.getElementById(\"canvas\").getContext(\"2d\"); var pieChartData = ["; 111 | TWRCircularChart *pieChart = (TWRCircularChart *)element; 112 | [pieChart.values enumerateObjectsUsingBlock:^(NSNumber *number, NSUInteger idx, BOOL *stop) { 113 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"{value:%@, color:\"%@\"}",number, [(UIColor *)pieChart.colors[idx] hexString]]]; 114 | if (idx != pieChart.values.count - 1) { 115 | retString = [retString stringByAppendingString:@","]; 116 | } else { 117 | retString = [retString stringByAppendingString:@"];"]; 118 | } 119 | }]; 120 | retString = [retString stringByAppendingString:@"function onFinish(){document.getElementById('callback').click();};"]; 121 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"var options = {animation:%@, onAnimationComplete:%@};", pieChart.animated ? @"true" : @"false", @"onFinish"]]; 122 | 123 | // Doughnut or Pie 124 | if (pieChart.type == TWRCircularChartTypePie) { 125 | retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Pie(pieChartData, options);"]; 126 | } else if (pieChart.type == TWRCircularChartTypeDoughnut) { 127 | retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Doughnut(pieChartData,options);"]; 128 | } 129 | 130 | return retString; 131 | } 132 | 133 | @end 134 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRChartView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRChartView.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | typedef void(^TWRAnimationCompletionBlock)(BOOL finished); 10 | 11 | #import 12 | @class TWRBarChart; 13 | @class TWRLineChart; 14 | @class TWRCircularChart; 15 | 16 | @interface TWRChartView : UIWebView 17 | 18 | @property (copy, nonatomic) NSString *chartJsFilePath; 19 | 20 | /** 21 | * Loading a Bar chart 22 | * 23 | * @param barChart the TWRBarChart object that needs to be drawn by the view 24 | */ 25 | - (void)loadBarChart:(TWRBarChart *)barChart; 26 | 27 | /** 28 | * Loading a Bar chart 29 | * 30 | * @param barChart the TWRBarChart object that needs to be drawn by the view 31 | * @param block the completion block that gets called once the animation has completed 32 | */ 33 | - (void)loadBarChart:(TWRBarChart *)barChart withCompletionHandler:(TWRAnimationCompletionBlock)block; 34 | 35 | /** 36 | * Loading a Line chart 37 | * 38 | * @param lineChart the TWRLineChart object that needs to be drawn by the view 39 | */ 40 | - (void)loadLineChart:(TWRLineChart *)lineChart; 41 | 42 | /** 43 | * Loading a Line chart 44 | * 45 | * @param lineChart the TWRLineChart object that needs to be drawn by the view 46 | * @param block the completion block that gets called once the animation has completed 47 | */ 48 | - (void)loadLineChart:(TWRLineChart *)lineChart withCompletionHandler:(TWRAnimationCompletionBlock)block; 49 | 50 | /** 51 | * Loading a Circular chart 52 | * 53 | * @param circularChart the TWRCircularChart object that needs to be drawn by the view 54 | */ 55 | - (void)loadCircularChart:(TWRCircularChart *)circularChart; 56 | 57 | /** 58 | * Loading a Circular chart 59 | * 60 | * @param circularChart the TWRCircularChart object that needs to be drawn by the view 61 | * @param block the completion block that gets called once the animation has completed 62 | */ 63 | - (void)loadCircularChart:(TWRCircularChart *)circularChart withCompletionHandler:(TWRAnimationCompletionBlock)block; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRChartView.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRChartView.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRChartView.h" 10 | #import "TWRLineChart.h" 11 | #import "TWRBarChart.h" 12 | #import "TWRChartBuilder.h" 13 | #import "TWRCircularChart.h" 14 | 15 | @interface TWRChartView () 16 | 17 | @property (copy, nonatomic) NSString *htmlFilePath; 18 | @property (copy, nonatomic) NSString *jsFileString; 19 | @property (copy, nonatomic) TWRAnimationCompletionBlock block; 20 | 21 | @end 22 | 23 | @implementation TWRChartView 24 | 25 | - (id)initWithFrame:(CGRect)frame 26 | { 27 | self = [super initWithFrame:frame]; 28 | if (self) { 29 | // Initialization code 30 | [self commonInit]; 31 | } 32 | return self; 33 | } 34 | 35 | - (void)commonInit { 36 | // Setting self as the delegate 37 | self.delegate = self; 38 | 39 | // Let the view be transparent 40 | self.opaque = NO; 41 | 42 | // HTML index file 43 | NSString *htmlFilePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; 44 | _htmlFilePath = htmlFilePath; 45 | self.userInteractionEnabled = NO; 46 | } 47 | 48 | - (void)didMoveToSuperview { 49 | // Init request 50 | NSError *error; 51 | 52 | // Load Javascript and store it in local ivar 53 | _jsFileString = [NSString stringWithContentsOfFile:_chartJsFilePath encoding:NSUTF8StringEncoding error:&error]; 54 | 55 | [self loadIndex]; 56 | // [self loadRequest:request]; 57 | } 58 | 59 | - (void)loadBarChart:(TWRBarChart *)barChart { 60 | if ([barChart isKindOfClass:[TWRBarChart class]] ) { 61 | _jsFileString = [TWRChartBuilder buildChartWithElement:barChart]; 62 | [self stringByEvaluatingJavaScriptFromString:_jsFileString]; 63 | [self loadIndex]; 64 | } else { 65 | NSException *exception = [NSException exceptionWithName:@"TWRChartInvalicChartElement" 66 | reason:@"The element object provided to the chart view is not a valid bar chart." 67 | userInfo:nil]; 68 | [exception raise]; 69 | } 70 | } 71 | 72 | - (void)loadBarChart:(TWRBarChart *)barChart withCompletionHandler:(TWRAnimationCompletionBlock)block { 73 | _block = block; 74 | [self loadBarChart:barChart]; 75 | } 76 | 77 | - (void)loadLineChart:(TWRLineChart *)lineChart { 78 | if ([lineChart isKindOfClass:[TWRLineChart class]]) { 79 | _jsFileString = [TWRChartBuilder buildChartWithElement:lineChart]; 80 | [self stringByEvaluatingJavaScriptFromString:_jsFileString]; 81 | [self loadIndex]; 82 | } else { 83 | NSException *exception = [NSException exceptionWithName:@"TWRChartInvalicChartElement" 84 | reason:@"The element object provided to the chart view is not a valid line chart." 85 | userInfo:nil]; 86 | [exception raise]; 87 | } 88 | } 89 | 90 | - (void)loadLineChart:(TWRLineChart *)lineChart withCompletionHandler:(TWRAnimationCompletionBlock)block { 91 | _block = block; 92 | [self loadLineChart:lineChart]; 93 | } 94 | 95 | - (void)loadCircularChart:(TWRCircularChart *)circularChart { 96 | if ([circularChart isKindOfClass:[TWRCircularChart class]]) { 97 | _jsFileString = [TWRChartBuilder buildChartWithElement:circularChart]; 98 | [self stringByEvaluatingJavaScriptFromString:_jsFileString]; 99 | [self loadIndex]; 100 | } else { 101 | NSException *exception = [NSException exceptionWithName:@"TWRChartInvalicChartElement" 102 | reason:@"The element object provided to the chart view is not a valid circular chart." 103 | userInfo:nil]; 104 | [exception raise]; 105 | } 106 | } 107 | 108 | - (void)loadCircularChart:(TWRCircularChart *)circularChart withCompletionHandler:(TWRAnimationCompletionBlock)block { 109 | _block = block; 110 | [self loadCircularChart:circularChart]; 111 | } 112 | 113 | #pragma mark - Private API 114 | 115 | - (void)loadIndex { 116 | NSError *error; 117 | // Load index.html 118 | NSString *htmlString = [NSString stringWithContentsOfFile:_htmlFilePath encoding:NSUTF8StringEncoding error:&error]; 119 | 120 | // Set canvas size according to frame dimensions. Leave space for labels at the bottom. 121 | NSString *canvasString = [NSString stringWithFormat:@"", (int)CGRectGetHeight(self.frame)-20, (int)CGRectGetWidth(self.frame) - 10]; 122 | htmlString = [htmlString stringByReplacingOccurrencesOfString:@"" withString:canvasString]; 123 | 124 | // Load it! 125 | [self loadHTMLString:htmlString baseURL:[[NSBundle mainBundle] bundleURL]]; 126 | } 127 | 128 | #pragma mark - Web View Delegate methods 129 | 130 | -(void)webViewDidFinishLoad:(UIWebView *)webView { 131 | [self stringByEvaluatingJavaScriptFromString:_jsFileString]; 132 | } 133 | 134 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { 135 | // Listen for Javasrcipt callback when chart ends animation 136 | if ( [[[request URL] scheme] isEqualToString:@"callback"] ) { 137 | if (_block) { 138 | _block(YES); 139 | } 140 | return NO; 141 | } 142 | return YES; 143 | } 144 | 145 | @end 146 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRCircularChart.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRPieChart.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 22/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | typedef NS_ENUM(NSUInteger, TWRCircularChartType) { 10 | TWRCircularChartTypePie = 0, 11 | TWRCircularChartTypeDoughnut 12 | }; 13 | 14 | #import 15 | 16 | @interface TWRCircularChart : NSObject 17 | 18 | @property (copy, nonatomic) NSMutableArray *values; 19 | @property (copy, nonatomic) NSMutableArray *colors; 20 | @property (assign, nonatomic) BOOL animated; 21 | @property (assign, nonatomic) TWRCircularChartType type; 22 | 23 | /** 24 | * Initializing the Circular Chart object 25 | * 26 | * @param values an array of NSNumber objects that represent the data to be plotted 27 | * @param colors an array of UIColor objects to go along with the previously provided data 28 | * @param type the type of the circular chart to be instantiated, either a Pie chart or a Doughnut chart 29 | * @param animated a BOOL defining whether the chart should be animated or not 30 | * 31 | * @return an instance of TWRCircularChart 32 | */ 33 | - (instancetype)initWithValues:(NSArray *)values 34 | colors:(NSArray *)colors 35 | type:(TWRCircularChartType)type 36 | animated:(BOOL)animated; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRCircularChart.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRPieChart.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 22/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRCircularChart.h" 10 | 11 | @implementation TWRCircularChart 12 | 13 | - (instancetype)initWithValues:(NSArray *)values 14 | colors:(NSArray *)colors 15 | type:(TWRCircularChartType)type 16 | animated:(BOOL)animated { 17 | self = [super init]; 18 | if (self) { 19 | _values = values.mutableCopy; 20 | _colors = colors.mutableCopy; 21 | _type = type; 22 | _animated = animated; 23 | } 24 | return self; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRDataSet+Strings.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRDataSet+Strings.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 22/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRDataSet.h" 10 | 11 | @interface TWRDataSet (Strings) 12 | 13 | - (NSString *)fillColorString; 14 | - (NSString *)strokeColorString; 15 | - (NSString *)pointColorString; 16 | - (NSString *)pointStrokeColorString; 17 | - (NSString *)dataString; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRDataSet+Strings.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRDataSet+Strings.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 22/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRDataSet+Strings.h" 10 | 11 | @implementation TWRDataSet (Strings) 12 | 13 | - (NSString *)fillColorString { 14 | CGFloat red; 15 | CGFloat green; 16 | CGFloat blue; 17 | CGFloat alpha; 18 | BOOL valid = [self.fillColor getRed:&red green:&green blue:&blue alpha:&alpha]; 19 | NSString *retString; 20 | if (valid) { 21 | retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha]; 22 | } 23 | return retString; 24 | } 25 | 26 | - (NSString *)strokeColorString { 27 | CGFloat red; 28 | CGFloat green; 29 | CGFloat blue; 30 | CGFloat alpha; 31 | BOOL valid = [self.strokeColor getRed:&red green:&green blue:&blue alpha:&alpha]; 32 | NSString *retString; 33 | if (valid) { 34 | retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha]; 35 | } 36 | return retString; 37 | } 38 | 39 | - (NSString *)pointColorString { 40 | CGFloat red; 41 | CGFloat green; 42 | CGFloat blue; 43 | CGFloat alpha; 44 | BOOL valid = [self.pointColor getRed:&red green:&green blue:&blue alpha:&alpha]; 45 | NSString *retString; 46 | if (valid) { 47 | retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha]; 48 | } 49 | return retString; 50 | } 51 | 52 | - (NSString *)pointStrokeColorString { 53 | CGFloat red; 54 | CGFloat green; 55 | CGFloat blue; 56 | CGFloat alpha; 57 | BOOL valid = [self.pointStrokeColor getRed:&red green:&green blue:&blue alpha:&alpha]; 58 | NSString *retString; 59 | if (valid) { 60 | retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha]; 61 | } 62 | return retString; 63 | } 64 | 65 | - (NSString *)dataString { 66 | __block NSString *retString = @"["; 67 | [self.dataPoints enumerateObjectsUsingBlock:^(NSNumber *number, NSUInteger idx, BOOL *stop) { 68 | retString = [retString stringByAppendingString:[NSString stringWithFormat:@"%@", number]]; 69 | if (idx != self.dataPoints.count - 1) { 70 | retString = [retString stringByAppendingString:@","]; 71 | } else { 72 | retString = [retString stringByAppendingString:@"]"]; 73 | } 74 | }]; 75 | return retString; 76 | } 77 | 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRDataSet.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRDataSet.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TWRDataSet : NSObject 12 | 13 | @property (strong, nonatomic) UIColor *fillColor; 14 | @property (strong, nonatomic) UIColor *strokeColor; 15 | @property (strong, nonatomic) UIColor *pointColor; 16 | @property (strong, nonatomic) UIColor *pointStrokeColor; 17 | @property (copy, nonatomic) NSMutableArray *dataPoints; 18 | 19 | /** 20 | * Initializing the Data Set (Line charts only) 21 | * 22 | * @param dataPoints an array of NSNumber objects representing the data to be plotted 23 | * @param fillColor an array of UIColor objects to go along with the provided data that represent the fill color of the bar / line 24 | * @param strokeColor an array of UIColor objects to go along with the provided data that represent the stroke color of the bar / line 25 | * @param pointColor an array of UIColor objects to go along with the provided data that represent the fill color of line points 26 | * @param pointStrokeColor an array of UIColor objects to go along with the provided data that represent the stroke color of line points 27 | * 28 | * @return an instance of TWRDataSet 29 | */ 30 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints 31 | fillColor:(UIColor *)fillColor 32 | strokeColor:(UIColor *)strokeColor 33 | pointColor:(UIColor *)pointColor 34 | pointStrokeColor:(UIColor *)pointStrokeColor; 35 | 36 | /** 37 | * Initializing the Data Set (Line and Bar charts) 38 | * 39 | * @param dataPoints an array of NSNumber objects representing the data to be plotted 40 | * @param fillColor an array of UIColor objects to go along with the provided data that represent the fill color of the bar / line 41 | * @param strokeColor an array of UIColor objects to go along with the provided data that represent the stroke color of the bar / line 42 | * 43 | * @return an instance of TWRDataSet 44 | */ 45 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints 46 | fillColor:(UIColor *)fillColor 47 | strokeColor:(UIColor *)strokeColor; 48 | 49 | /** 50 | * Initializing the Data Set (Line and Bar charts) 51 | * 52 | * @param dataPoints an array of NSNumber objects representing the data to be plotted 53 | * 54 | * @return an instance of TWRDataSet 55 | */ 56 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRDataSet.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRDataSet.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRDataSet.h" 10 | 11 | @implementation TWRDataSet 12 | 13 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints { 14 | // Default color: light gray 15 | UIColor *fillColor = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:220/255.0f alpha:0.5]; 16 | UIColor *strokeColor = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:220/255.0f alpha:1.0]; 17 | UIColor *pointColor = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:220/255.0f alpha:1.0]; 18 | UIColor *pointStrokeColor = [UIColor whiteColor]; 19 | self = [self initWithDataPoints:dataPoints fillColor:fillColor strokeColor:strokeColor pointColor:pointColor pointStrokeColor:pointStrokeColor]; 20 | 21 | return self; 22 | } 23 | 24 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints 25 | fillColor:(UIColor *)fillColor 26 | strokeColor:(UIColor *)strokeColor { 27 | UIColor *pointColor = strokeColor; 28 | UIColor *pointStrokeColor = strokeColor; 29 | self = [self initWithDataPoints:dataPoints fillColor:fillColor strokeColor:strokeColor pointColor:pointColor pointStrokeColor:pointStrokeColor]; 30 | 31 | return self; 32 | } 33 | 34 | - (instancetype)initWithDataPoints:(NSArray *)dataPoints 35 | fillColor:(UIColor *)fillColor 36 | strokeColor:(UIColor *)strokeColor 37 | pointColor:(UIColor *)pointColor 38 | pointStrokeColor:(UIColor *)pointStrokeColor { 39 | self = [super init]; 40 | if (self) { 41 | _dataPoints = dataPoints.mutableCopy; 42 | _fillColor = fillColor; 43 | _strokeColor = strokeColor; 44 | _pointColor = pointColor; 45 | _pointStrokeColor = pointStrokeColor; 46 | } 47 | return self; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRLineChart.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRLineChart.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | @class TWRDataSet; 11 | 12 | @interface TWRLineChart : NSObject 13 | 14 | @property (copy, nonatomic) NSMutableArray *labels; 15 | @property (copy, nonatomic) NSMutableArray *dataSets; 16 | @property (assign, nonatomic) BOOL animated; 17 | @property(nonatomic) BOOL curveLines; 18 | 19 | - (instancetype)initWithLabels:(NSArray *)labels dataSets:(NSArray *)dataSets animated:(BOOL)animated; 20 | 21 | /** 22 | * Initializing the Line Chart object 23 | * 24 | * @param labels an NSArray of labels (NSString) to go along with the data 25 | * @param dataSets an NSArray of TWRDataSet objects containing the data to be plotted 26 | * @param animated a BOOL defining whether the chart should be animated or not 27 | * 28 | * @return an instance of TWRLineChart 29 | */ 30 | - (instancetype)initWithLabels:(NSArray *)labels 31 | dataSets:(NSArray *)dataSets 32 | animated:(BOOL)animated 33 | curved:(BOOL)curved; 34 | 35 | /** 36 | * Initializing the Line Chart object 37 | * 38 | * @param labels an NSArray of labels (NSString) to go along with the data 39 | * @param dataSets an NSArray of TWRDataSet objects containing the data to be plotted 40 | * @param animated a BOOL defining whether the chart should be animated or not 41 | * @param curved a BOOL defining whether the chart should be curved or not 42 | * 43 | * @return an instance of TWRLineChart 44 | */ 45 | - (instancetype)initWithLabels:(NSArray *)labels 46 | dataSets:(NSArray *)dataSets 47 | animated:(BOOL)animated 48 | curved:(BOOL)curved; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRLineChart.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRLineChart.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRLineChart.h" 10 | 11 | @interface TWRLineChart () 12 | 13 | @end 14 | 15 | @implementation TWRLineChart 16 | 17 | - (instancetype)initWithLabels:(NSArray *)labels 18 | dataSets:(NSArray *)dataSets 19 | animated:(BOOL)animated { 20 | self = [super init]; 21 | if (self) { 22 | _labels = labels.mutableCopy; 23 | _dataSets = dataSets.mutableCopy; 24 | _animated = animated; 25 | } 26 | return self; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TWRViewController.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TWRViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/TWRViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TWRViewController.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "TWRViewController.h" 10 | #import "TWRChart.h" 11 | 12 | @interface TWRViewController () 13 | 14 | @property(strong, nonatomic) TWRChartView *chartView; 15 | @property(weak, nonatomic) IBOutlet UISegmentedControl *segmentedControl; 16 | 17 | - (void)switchChart:(UISegmentedControl *)sender; 18 | 19 | @end 20 | 21 | @implementation TWRViewController 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | self.title = @"Charts"; 26 | 27 | // Segmented Control 28 | [_segmentedControl addTarget:self action:@selector(switchChart:) forControlEvents:UIControlEventValueChanged]; 29 | 30 | // Chart View 31 | _chartView = [[TWRChartView alloc] initWithFrame:CGRectMake(0, 64, 320, 300)]; 32 | _chartView.backgroundColor = [UIColor clearColor]; 33 | 34 | // User interaction is disabled by default. You can enable it again if you want 35 | // _chartView.userInteractionEnabled = YES; 36 | 37 | // Load chart by using a ChartJS javascript file 38 | NSString *jsFilePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"js"]; 39 | [_chartView setChartJsFilePath:jsFilePath]; 40 | 41 | // Add the chart view to the controller's view 42 | [self.view addSubview:_chartView]; 43 | } 44 | 45 | - (void)didReceiveMemoryWarning { 46 | [super didReceiveMemoryWarning]; 47 | // Dispose of any resources that can be recreated. 48 | } 49 | 50 | /** 51 | * Loads a bar chart using native code 52 | */ 53 | - (void)loadBarChart { 54 | // Build chart data 55 | TWRDataSet *dataSet1 = [[TWRDataSet alloc] initWithDataPoints:@[@10, @15, @5, @15, @5] 56 | fillColor:[[UIColor orangeColor] colorWithAlphaComponent:0.5] 57 | strokeColor:[UIColor orangeColor]]; 58 | 59 | TWRDataSet *dataSet2 = [[TWRDataSet alloc] initWithDataPoints:@[@5, @10, @5, @15, @10] 60 | fillColor:[[UIColor redColor] colorWithAlphaComponent:0.5] 61 | strokeColor:[UIColor redColor]]; 62 | 63 | NSArray *labels = @[@"A", @"B", @"C", @"D", @"E"]; 64 | TWRBarChart *bar = [[TWRBarChart alloc] initWithLabels:labels 65 | dataSets:@[dataSet1, dataSet2] 66 | animated:YES]; 67 | // Load data 68 | [_chartView loadBarChart:bar]; 69 | } 70 | 71 | /** 72 | * Loads a line chart using native code 73 | */ 74 | - (void)loadLineChart { 75 | // Build chart data 76 | TWRDataSet *dataSet1 = [[TWRDataSet alloc] initWithDataPoints:@[@10, @15, @5, @15, @5]]; 77 | TWRDataSet *dataSet2 = [[TWRDataSet alloc] initWithDataPoints:@[@5, @10, @5, @15, @10]]; 78 | 79 | NSArray *labels = @[@"A", @"B", @"C", @"D", @"E"]; 80 | 81 | TWRLineChart *line = [[TWRLineChart alloc] initWithLabels:labels 82 | dataSets:@[dataSet1, dataSet2] 83 | animated:NO]; 84 | // Load data 85 | [_chartView loadLineChart:line]; 86 | } 87 | 88 | /** 89 | * Loads a pie / doughnut chart using native code 90 | */ 91 | - (void)loadPieChart { 92 | // Values 93 | NSArray *values = @[@20, @30, @15, @5]; 94 | 95 | // Colors 96 | UIColor *color1 = [UIColor colorWithHue:0.5 saturation:0.6 brightness:0.6 alpha:1.0]; 97 | UIColor *color2 = [UIColor colorWithHue:0.6 saturation:0.6 brightness:0.6 alpha:1.0]; 98 | UIColor *color3 = [UIColor colorWithHue:0.7 saturation:0.6 brightness:0.6 alpha:1.0]; 99 | UIColor *color4 = [UIColor colorWithHue:0.8 saturation:0.6 brightness:0.6 alpha:1.0]; 100 | NSArray *colors = @[color1, color2, color3, color4]; 101 | 102 | // Doughnut Chart 103 | TWRCircularChart *pieChart = [[TWRCircularChart alloc] initWithValues:values 104 | colors:colors 105 | type:TWRCircularChartTypeDoughnut 106 | animated:YES]; 107 | 108 | // You can even leverage callbacks when chart animation ends! 109 | [_chartView loadCircularChart:pieChart withCompletionHandler:^(BOOL finished) { 110 | if (finished) { 111 | NSLog(@"Animation finished!!!"); 112 | } 113 | }]; 114 | } 115 | 116 | #pragma mark - UISegmentedController switch methods 117 | 118 | - (void)switchChart:(UISegmentedControl *)sender { 119 | switch (sender.selectedSegmentIndex) { 120 | //Line 121 | case 0: { 122 | [self loadLineChart]; 123 | } 124 | break; 125 | 126 | //Bar 127 | case 1: { 128 | [self loadBarChart]; 129 | } 130 | break; 131 | 132 | //Pie 133 | case 2: { 134 | [self loadPieChart]; 135 | } 136 | break; 137 | 138 | default: 139 | break; 140 | } 141 | } 142 | 143 | @end 144 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/UIColor+HexString.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HexString.h 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 23/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIColor (HexString) 12 | 13 | - (NSString *)hexString; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/UIColor+HexString.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HexString.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 23/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import "UIColor+HexString.h" 10 | 11 | @implementation UIColor (HexString) 12 | 13 | - (NSString *)hexString { 14 | const CGFloat *components = CGColorGetComponents(self.CGColor); 15 | CGFloat r = components[0]; 16 | CGFloat g = components[1]; 17 | CGFloat b = components[2]; 18 | NSString *hexString=[NSString stringWithFormat:@"#%02X%02X%02X", (int)(r * 255), (int)(g * 255), (int)(b * 255)]; 19 | return hexString; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/index.js: -------------------------------------------------------------------------------- 1 | var context = document.getElementById("canvas").getContext("2d"); 2 | 3 | var polarData = [ 4 | { 5 | value : 30, 6 | color: "#D97041" 7 | }, 8 | { 9 | value : 90, 10 | color: "#C7604C" 11 | }, 12 | { 13 | value : 24, 14 | color: "#21323D" 15 | }, 16 | { 17 | value : 58, 18 | color: "#9D9B7F" 19 | }, 20 | { 21 | value : 82, 22 | color: "#7D4F6D" 23 | }, 24 | { 25 | value : 8, 26 | color: "#584A5E" 27 | } 28 | ] 29 | 30 | var polarArea = new Chart(context).PolarArea(polarData); -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJS/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ChartJS 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "TWRAppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([TWRAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJSTests/ChartJSTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | re.touchwa.${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 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJSTests/ChartJSTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ChartJSTests.m 3 | // ChartJSTests 4 | // 5 | // Created by Michelangelo Chasseur on 21/04/14. 6 | // Copyright (c) 2014 Touchware. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ChartJSTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ChartJSTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /TWRChartsDemo/ChartJSTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | --------------------------------------------------------------------------------