Repository: chasseurmic/TWRCharts
Branch: master
Commit: f5c0e0f08175
Files: 56
Total size: 106.2 KB
Directory structure:
gitextract_1j08ohm7/
├── .gitignore
├── LICENSE
├── README.md
├── TWRCharts/
│ ├── 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
├── TWRCharts.podspec
└── TWRChartsDemo/
├── 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
├── ChartJS.xcodeproj/
│ ├── project.pbxproj
│ └── project.xcworkspace/
│ └── contents.xcworkspacedata
└── ChartJSTests/
├── ChartJSTests-Info.plist
├── ChartJSTests.m
└── en.lproj/
└── InfoPlist.strings
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
================================================
FILE: LICENSE
================================================
Copyright (c) 2014 Michelangelo Chasseur.
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.
================================================
FILE: README.md
================================================
TWRCharts
=================
## TWRCharts
An Obj-C wrapper for ChartJS. Easily build animated charts by leveraging the power of native code.
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.
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!
Native code API does not yet support all type of charts provided by ChartJS; only line, bars, pies and doughnuts are currently available.
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.

## Usage
Usage is easy.
Add the dependency to your `Podfile`:
```ruby
platform :ios
pod 'TWRCharts'
```
Run `pod install` to install the dependencies.
Next, import the header file wherever you want to use the custom view:
```objc
#import <TWRCharts/TWRChart.h>
```
In the Xcode target "Build Phases" add the files (index.html and Chart.js) under "Copy Bundle Resources".
### Creating the chart view
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.
```objc
// Chart View
_chartView = [[TWRChartView alloc] initWithFrame:CGRectMake(0, 64, 320, 300)];
// Optionally assign here a JS file (see below)
// Add the chart view to the controller's view
[self.view addSubview:_chartView];
```
### Loading a chart from a JS file
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.
Then just get a handle on the file and set its path to the TWRChartView that's being added to the controller's view.
```objc
NSString *jsFilePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"js"];
[_chartView setChartJsFilePath:jsFilePath];
```
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.
```js
var context = document.getElementById("canvas").getContext("2d");
var polarData = [
{
value : 30,
color: "#D97041"
},
{
value : 90,
color: "#C7604C"
},
{
value : 24,
color: "#21323D"
},
{
value : 58,
color: "#9D9B7F"
},
{
value : 82,
color: "#7D4F6D"
},
{
value : 8,
color: "#584A5E"
}
]
var polarArea = new Chart(context).PolarArea(polarData);
```
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:
```js
var context = document.getElementById("canvas").getContext("2d");
```
This code retrieves the correct context from the HTML file that backs the TWRChartView.
### Loading a chart using native Obj-C code
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:
- Instantiate data objects;
- Instantiate a chart object by passing the data objects along with labels;
- Load the chart object onto the chart view.
Here's some example code:
```objc
// Build chart data
TWRDataSet *dataSet1 = [[TWRDataSet alloc] initWithDataPoints:@[@10, @15, @5, @15, @5]];
TWRDataSet *dataSet2 = [[TWRDataSet alloc] initWithDataPoints:@[@5, @10, @5, @15, @10]];
NSArray *labels = @[@"A", @"B", @"C", @"D", @"E"];
// Instantiate the chart object
TWRLineChart *line = [[TWRLineChart alloc] initWithLabels:labels
dataSets:@[dataSet1, dataSet2]
animated:NO];
// Load the chart object onto the view
[_chartView loadLineChart:line];
```
#### Data Sets
TWRDataSet (which represents the data for bar and line charts) can be instantiated with the following *init* method:
```objc
- (instancetype)initWithDataPoints:(NSArray *)dataPoints
fillColor:(UIColor *)fillColor
strokeColor:(UIColor *)strokeColor
pointColor:(UIColor *)pointColor
pointStrokeColor:(UIColor *)pointStrokeColor;
```
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.
At a minimum you have to provide the data points, which is an array of NSNumbers.
#### Line / Bar Charts
Line and bar charts can be instantiated as such:
```objc
- (instancetype)initWithLabels:(NSArray *)labels
dataSets:(NSArray *)dataSets
animated:(BOOL)animated;
```
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:
```objc
- (void)loadBarChart:(TWRBarChart *)barChart;
- (void)loadLineChart:(TWRLineChart *)lineChart;
```
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!
```objc
- (void)loadBarChart:(TWRBarChart *)barChart withCompletionHandler:(TWRAnimationCompletionBlock)block;
- (void)loadLineChart:(TWRLineChart *)lineChart withCompletionHandler:(TWRAnimationCompletionBlock)block;
```
#### Circular Charts
And finally, circular charts can be instantiated with the following method:
```objc
- (instancetype)initWithValues:(NSArray *)values
colors:(NSArray *)colors
type:(TWRCircularChartType)type
animated:(BOOL)animated;
```
You even get a chance to choose the chart type, either a pie chart (TWRCircularChartTypePie) or a doughnut (TWRCircularChartTypeDoughnut).
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```:
```objc
- (void)loadCircularChart:(TWRCircularChart *)circularChart;
- (void)loadCircularChart:(TWRCircularChart *)circularChart withCompletionHandler:(TWRAnimationCompletionBlock)block;
```
## Requirements
`TWRCharts` requires iOS 6.x or greater.
## License
Usage is provided under the [MIT License](http://opensource.org/licenses/mit-license.php). See LICENSE for the full details.
================================================
FILE: TWRCharts/TWRBarChart.h
================================================
//
// TWRBarChart.h
// ChartJS
//
// Created by Michelangelo Chasseur on 22/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <Foundation/Foundation.h>
@class TWRDataSet;
@interface TWRBarChart : NSObject
@property (copy, nonatomic) NSMutableArray *labels;
@property (copy, nonatomic) NSMutableArray *dataSets;
@property (assign, nonatomic) BOOL animated;
/**
* Initializing the Bar Chart object
*
* @param labels an NSArray of labels (NSString) to go along with the data
* @param dataSets an NSArray of TWRDataSet objects containing the data to be plotted
* @param animated a BOOL defining whether the chart should be animated or not
*
* @return an instance of TWRBarChart
*/
- (instancetype)initWithLabels:(NSArray *)labels
dataSets:(NSArray *)dataSets
animated:(BOOL)animated;
@end
================================================
FILE: TWRCharts/TWRBarChart.m
================================================
//
// TWRBarChart.m
// ChartJS
//
// Created by Michelangelo Chasseur on 22/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRBarChart.h"
@implementation TWRBarChart
- (instancetype)initWithLabels:(NSArray *)labels
dataSets:(NSArray *)dataSets
animated:(BOOL)animated {
self = [super init];
if (self) {
_labels = labels.mutableCopy;
_dataSets = dataSets.mutableCopy;
_animated = animated;
}
return self;
}
@end
================================================
FILE: TWRCharts/TWRChart.h
================================================
//
// TWRChart.h
// ChartJS
//
// Created by Michelangelo Chasseur on 23/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#ifndef ChartJS_TWRChart_h
#define ChartJS_TWRChart_h
#import "TWRChartView.h"
#import "TWRLineChart.h"
#import "TWRBarChart.h"
#import "TWRCircularChart.h"
#import "TWRDataSet.h"
#endif
================================================
FILE: TWRCharts/TWRChartBuilder.h
================================================
//
// TWRChartBuilder.h
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TWRChartBuilder : NSObject
+ (NSString *)buildChartWithElement:(id)element;
@end
================================================
FILE: TWRCharts/TWRChartBuilder.m
================================================
//
// TWRChartBuilder.m
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRChartBuilder.h"
#import "TWRLineChart.h"
#import "TWRBarChart.h"
#import "TWRCircularChart.h"
#import "TWRDataSet.h"
#import "TWRDataSet+Strings.h"
#import "UIColor+HexString.h"
@interface TWRChartBuilder ()
+ (NSString *)buildLineChartStringForElement:(TWRLineChart *)element;
+ (NSString *)buildBarChartStringForElement:(TWRBarChart *)element;
+ (NSString *)buildCircularChartStringForElement:(TWRCircularChart *)element;
@end
@implementation TWRChartBuilder
+ (NSString *)buildChartWithElement:(id)element {
__block NSString *retString;
if ([element isKindOfClass:[TWRLineChart class]]) {
retString = [self buildLineChartStringForElement:element];
} else if ([element isKindOfClass:[TWRBarChart class]]) {
retString = [self buildBarChartStringForElement:element];
} else if ([element isKindOfClass:[TWRCircularChart class]]) {
retString = [self buildCircularChartStringForElement:element];
}
return retString;
}
#pragma mark - Private API
+ (NSString *)buildLineChartStringForElement:(TWRLineChart *)element {
__block NSString *retString;
retString = @"var context = document.getElementById(\"canvas\").getContext(\"2d\"); var lineChartData = { labels:[";
TWRLineChart *lineChart = (TWRLineChart *)element;
[lineChart.labels enumerateObjectsUsingBlock:^(NSString *label, NSUInteger idx, BOOL *stop) {
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"\"%@\"", label]];
if (idx != lineChart.labels.count - 1) {
retString = [retString stringByAppendingString:@","];
} else {
// close the array
retString = [retString stringByAppendingString:@"], datasets:["];
}
}];
[lineChart.dataSets enumerateObjectsUsingBlock:^(TWRDataSet *dataset, NSUInteger idx, BOOL *stop) {
NSString *fillColorString = [dataset fillColorString];
NSString *strokeColorString = [dataset strokeColorString];
NSString *pointColorString = [dataset pointColorString];
NSString *pointStrokeColorString = [dataset pointStrokeColorString];
NSString *dataString = [dataset dataString];
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"{fillColor:%@,strokeColor:%@,pointColor:%@,pointStrokeColor:%@,data:%@}", fillColorString, strokeColorString, pointColorString, pointStrokeColorString, dataString]];
if (idx != lineChart.dataSets.count - 1) {
retString = [retString stringByAppendingString:@","];
} else {
retString = [retString stringByAppendingString:@"]};"];
}
}];
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"var options = {animation:%@, bezierCurve :%@};", lineChart.animated ? @"true" : @"false", lineChart.curveLines ? @"true" : @"false"]];
retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Line(lineChartData,options);"];
return retString;
}
+ (NSString *)buildBarChartStringForElement:(TWRBarChart *)element {
__block NSString *retString;
retString = @"var context = document.getElementById(\"canvas\").getContext(\"2d\"); var barChartData = { labels:[";
TWRBarChart *barChart = (TWRBarChart *)element;
[barChart.labels enumerateObjectsUsingBlock:^(NSString *label, NSUInteger idx, BOOL *stop) {
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"\"%@\"", label]];
if (idx != barChart.labels.count - 1) {
retString = [retString stringByAppendingString:@","];
} else {
// close the array
retString = [retString stringByAppendingString:@"], datasets:["];
}
}];
[barChart.dataSets enumerateObjectsUsingBlock:^(TWRDataSet *dataset, NSUInteger idx, BOOL *stop) {
NSString *fillColorString = [dataset fillColorString];
NSString *strokeColorString = [dataset strokeColorString];
NSString *pointColorString = [dataset pointColorString];
NSString *pointStrokeColorString = [dataset pointStrokeColorString];
NSString *dataString = [dataset dataString];
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"{fillColor:%@,strokeColor:%@,pointColor:%@,pointStrokeColor:%@,data:%@}", fillColorString, strokeColorString, pointColorString, pointStrokeColorString, dataString]];
if (idx != barChart.dataSets.count - 1) {
retString = [retString stringByAppendingString:@","];
} else {
retString = [retString stringByAppendingString:@"]};"];
}
}];
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"var options = {animation:%@};", barChart.animated ? @"true" : @"false"]];
retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Bar(barChartData,options);"];
return retString;
}
+ (NSString *)buildCircularChartStringForElement:(TWRCircularChart *)element {
__block NSString *retString;
retString = @"var context = document.getElementById(\"canvas\").getContext(\"2d\"); var pieChartData = [";
TWRCircularChart *pieChart = (TWRCircularChart *)element;
[pieChart.values enumerateObjectsUsingBlock:^(NSNumber *number, NSUInteger idx, BOOL *stop) {
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"{value:%@, color:\"%@\"}",number, [(UIColor *)pieChart.colors[idx] hexString]]];
if (idx != pieChart.values.count - 1) {
retString = [retString stringByAppendingString:@","];
} else {
retString = [retString stringByAppendingString:@"];"];
}
}];
retString = [retString stringByAppendingString:@"function onFinish(){document.getElementById('callback').click();};"];
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"var options = {animation:%@, onAnimationComplete:%@};", pieChart.animated ? @"true" : @"false", @"onFinish"]];
// Doughnut or Pie
if (pieChart.type == TWRCircularChartTypePie) {
retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Pie(pieChartData, options);"];
} else if (pieChart.type == TWRCircularChartTypeDoughnut) {
retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Doughnut(pieChartData,options);"];
}
return retString;
}
@end
================================================
FILE: TWRCharts/TWRChartView.h
================================================
//
// TWRChartView.h
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
typedef void(^TWRAnimationCompletionBlock)(BOOL finished);
#import <UIKit/UIKit.h>
@class TWRBarChart;
@class TWRLineChart;
@class TWRCircularChart;
@interface TWRChartView : UIWebView
@property (copy, nonatomic) NSString *chartJsFilePath;
/**
* Loading a Bar chart
*
* @param barChart the TWRBarChart object that needs to be drawn by the view
*/
- (void)loadBarChart:(TWRBarChart *)barChart;
/**
* Loading a Bar chart
*
* @param barChart the TWRBarChart object that needs to be drawn by the view
* @param block the completion block that gets called once the animation has completed
*/
- (void)loadBarChart:(TWRBarChart *)barChart withCompletionHandler:(TWRAnimationCompletionBlock)block;
/**
* Loading a Line chart
*
* @param lineChart the TWRLineChart object that needs to be drawn by the view
*/
- (void)loadLineChart:(TWRLineChart *)lineChart;
/**
* Loading a Line chart
*
* @param lineChart the TWRLineChart object that needs to be drawn by the view
* @param block the completion block that gets called once the animation has completed
*/
- (void)loadLineChart:(TWRLineChart *)lineChart withCompletionHandler:(TWRAnimationCompletionBlock)block;
/**
* Loading a Circular chart
*
* @param circularChart the TWRCircularChart object that needs to be drawn by the view
*/
- (void)loadCircularChart:(TWRCircularChart *)circularChart;
/**
* Loading a Circular chart
*
* @param circularChart the TWRCircularChart object that needs to be drawn by the view
* @param block the completion block that gets called once the animation has completed
*/
- (void)loadCircularChart:(TWRCircularChart *)circularChart withCompletionHandler:(TWRAnimationCompletionBlock)block;
@end
================================================
FILE: TWRCharts/TWRChartView.m
================================================
//
// TWRChartView.m
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRChartView.h"
#import "TWRLineChart.h"
#import "TWRBarChart.h"
#import "TWRChartBuilder.h"
#import "TWRCircularChart.h"
@interface TWRChartView () <UIWebViewDelegate>
@property (copy, nonatomic) NSString *htmlFilePath;
@property (copy, nonatomic) NSString *jsFileString;
@property (copy, nonatomic) TWRAnimationCompletionBlock block;
@end
@implementation TWRChartView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self commonInit];
}
return self;
}
- (id)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if ( self )
{
[self commonInit];
}
return self;
}
- (id)init
{
self = [super init];
if ( self )
{
[self commonInit];
}
return self;
}
- (void)commonInit {
// Setting self as the delegate
self.delegate = self;
// Let the view be transparent
self.opaque = NO;
// HTML index file
NSString *htmlFilePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
_htmlFilePath = htmlFilePath;
self.userInteractionEnabled = NO;
}
- (void)didMoveToSuperview {
// Init request
NSError *error;
// Load Javascript and store it in local ivar
_jsFileString = [NSString stringWithContentsOfFile:_chartJsFilePath encoding:NSUTF8StringEncoding error:&error];
[self loadIndex];
// [self loadRequest:request];
}
- (void)loadBarChart:(TWRBarChart *)barChart {
if ([barChart isKindOfClass:[TWRBarChart class]] ) {
_jsFileString = [TWRChartBuilder buildChartWithElement:barChart];
[self stringByEvaluatingJavaScriptFromString:_jsFileString];
[self loadIndex];
} else {
NSException *exception = [NSException exceptionWithName:@"TWRChartInvalicChartElement"
reason:@"The element object provided to the chart view is not a valid bar chart."
userInfo:nil];
[exception raise];
}
}
- (void)loadBarChart:(TWRBarChart *)barChart withCompletionHandler:(TWRAnimationCompletionBlock)block {
_block = block;
[self loadBarChart:barChart];
}
- (void)loadLineChart:(TWRLineChart *)lineChart {
if ([lineChart isKindOfClass:[TWRLineChart class]]) {
_jsFileString = [TWRChartBuilder buildChartWithElement:lineChart];
[self stringByEvaluatingJavaScriptFromString:_jsFileString];
[self loadIndex];
} else {
NSException *exception = [NSException exceptionWithName:@"TWRChartInvalicChartElement"
reason:@"The element object provided to the chart view is not a valid line chart."
userInfo:nil];
[exception raise];
}
}
- (void)loadLineChart:(TWRLineChart *)lineChart withCompletionHandler:(TWRAnimationCompletionBlock)block {
_block = block;
[self loadLineChart:lineChart];
}
- (void)loadCircularChart:(TWRCircularChart *)circularChart {
if ([circularChart isKindOfClass:[TWRCircularChart class]]) {
_jsFileString = [TWRChartBuilder buildChartWithElement:circularChart];
[self stringByEvaluatingJavaScriptFromString:_jsFileString];
[self loadIndex];
} else {
NSException *exception = [NSException exceptionWithName:@"TWRChartInvalicChartElement"
reason:@"The element object provided to the chart view is not a valid circular chart."
userInfo:nil];
[exception raise];
}
}
- (void)loadCircularChart:(TWRCircularChart *)circularChart withCompletionHandler:(TWRAnimationCompletionBlock)block {
_block = block;
[self loadCircularChart:circularChart];
}
#pragma mark - Private API
- (void)loadIndex {
NSError *error;
// Load index.html
NSString *htmlString = [NSString stringWithContentsOfFile:_htmlFilePath encoding:NSUTF8StringEncoding error:&error];
// Set canvas size according to frame dimensions. Leave space for labels at the bottom.
NSString *canvasString = [NSString stringWithFormat:@"<canvas id=\"canvas\" height=\"%d\" width=\"%d\"></canvas>", (int)CGRectGetHeight(self.frame)-20, (int)CGRectGetWidth(self.frame) - 10];
htmlString = [htmlString stringByReplacingOccurrencesOfString:@"<canvas></canvas>" withString:canvasString];
// Load it!
[self loadHTMLString:htmlString baseURL:[[NSBundle mainBundle] bundleURL]];
}
#pragma mark - Web View Delegate methods
-(void)webViewDidFinishLoad:(UIWebView *)webView {
[self stringByEvaluatingJavaScriptFromString:_jsFileString];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
// Listen for Javasrcipt callback when chart ends animation
if ( [[[request URL] scheme] isEqualToString:@"callback"] ) {
if (_block) {
_block(YES);
}
return NO;
}
return YES;
}
@end
================================================
FILE: TWRCharts/TWRCircularChart.h
================================================
//
// TWRPieChart.h
// ChartJS
//
// Created by Michelangelo Chasseur on 22/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
typedef NS_ENUM(NSUInteger, TWRCircularChartType) {
TWRCircularChartTypePie = 0,
TWRCircularChartTypeDoughnut
};
#import <Foundation/Foundation.h>
@interface TWRCircularChart : NSObject
@property (copy, nonatomic) NSMutableArray *values;
@property (copy, nonatomic) NSMutableArray *colors;
@property (assign, nonatomic) BOOL animated;
@property (assign, nonatomic) TWRCircularChartType type;
/**
* Initializing the Circular Chart object
*
* @param values an array of NSNumber objects that represent the data to be plotted
* @param colors an array of UIColor objects to go along with the previously provided data
* @param type the type of the circular chart to be instantiated, either a Pie chart or a Doughnut chart
* @param animated a BOOL defining whether the chart should be animated or not
*
* @return an instance of TWRCircularChart
*/
- (instancetype)initWithValues:(NSArray *)values
colors:(NSArray *)colors
type:(TWRCircularChartType)type
animated:(BOOL)animated;
@end
================================================
FILE: TWRCharts/TWRCircularChart.m
================================================
//
// TWRPieChart.m
// ChartJS
//
// Created by Michelangelo Chasseur on 22/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRCircularChart.h"
@implementation TWRCircularChart
- (instancetype)initWithValues:(NSArray *)values
colors:(NSArray *)colors
type:(TWRCircularChartType)type
animated:(BOOL)animated {
self = [super init];
if (self) {
_values = values.mutableCopy;
_colors = colors.mutableCopy;
_type = type;
_animated = animated;
}
return self;
}
@end
================================================
FILE: TWRCharts/TWRDataSet+Strings.h
================================================
//
// TWRDataSet+Strings.h
// ChartJS
//
// Created by Michelangelo Chasseur on 22/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRDataSet.h"
@interface TWRDataSet (Strings)
- (NSString *)fillColorString;
- (NSString *)strokeColorString;
- (NSString *)pointColorString;
- (NSString *)pointStrokeColorString;
- (NSString *)dataString;
@end
================================================
FILE: TWRCharts/TWRDataSet+Strings.m
================================================
//
// TWRDataSet+Strings.m
// ChartJS
//
// Created by Michelangelo Chasseur on 22/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRDataSet+Strings.h"
@implementation TWRDataSet (Strings)
- (NSString *)fillColorString {
CGFloat red;
CGFloat green;
CGFloat blue;
CGFloat alpha;
BOOL valid = [self.fillColor getRed:&red green:&green blue:&blue alpha:&alpha];
NSString *retString;
if (valid) {
retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha];
}
return retString;
}
- (NSString *)strokeColorString {
CGFloat red;
CGFloat green;
CGFloat blue;
CGFloat alpha;
BOOL valid = [self.strokeColor getRed:&red green:&green blue:&blue alpha:&alpha];
NSString *retString;
if (valid) {
retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha];
}
return retString;
}
- (NSString *)pointColorString {
CGFloat red;
CGFloat green;
CGFloat blue;
CGFloat alpha;
BOOL valid = [self.pointColor getRed:&red green:&green blue:&blue alpha:&alpha];
NSString *retString;
if (valid) {
retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha];
}
return retString;
}
- (NSString *)pointStrokeColorString {
CGFloat red;
CGFloat green;
CGFloat blue;
CGFloat alpha;
BOOL valid = [self.pointStrokeColor getRed:&red green:&green blue:&blue alpha:&alpha];
NSString *retString;
if (valid) {
retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha];
}
return retString;
}
- (NSString *)dataString {
__block NSString *retString = @"[";
[self.dataPoints enumerateObjectsUsingBlock:^(NSNumber *number, NSUInteger idx, BOOL *stop) {
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"%@", number]];
if (idx != self.dataPoints.count - 1) {
retString = [retString stringByAppendingString:@","];
} else {
retString = [retString stringByAppendingString:@"]"];
}
}];
return retString;
}
@end
================================================
FILE: TWRCharts/TWRDataSet.h
================================================
//
// TWRDataSet.h
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TWRDataSet : NSObject
@property (strong, nonatomic) UIColor *fillColor;
@property (strong, nonatomic) UIColor *strokeColor;
@property (strong, nonatomic) UIColor *pointColor;
@property (strong, nonatomic) UIColor *pointStrokeColor;
@property (copy, nonatomic) NSMutableArray *dataPoints;
/**
* Initializing the Data Set (Line charts only)
*
* @param dataPoints an array of NSNumber objects representing the data to be plotted
* @param fillColor an array of UIColor objects to go along with the provided data that represent the fill color of the bar / line
* @param strokeColor an array of UIColor objects to go along with the provided data that represent the stroke color of the bar / line
* @param pointColor an array of UIColor objects to go along with the provided data that represent the fill color of line points
* @param pointStrokeColor an array of UIColor objects to go along with the provided data that represent the stroke color of line points
*
* @return an instance of TWRDataSet
*/
- (instancetype)initWithDataPoints:(NSArray *)dataPoints
fillColor:(UIColor *)fillColor
strokeColor:(UIColor *)strokeColor
pointColor:(UIColor *)pointColor
pointStrokeColor:(UIColor *)pointStrokeColor;
/**
* Initializing the Data Set (Line and Bar charts)
*
* @param dataPoints an array of NSNumber objects representing the data to be plotted
* @param fillColor an array of UIColor objects to go along with the provided data that represent the fill color of the bar / line
* @param strokeColor an array of UIColor objects to go along with the provided data that represent the stroke color of the bar / line
*
* @return an instance of TWRDataSet
*/
- (instancetype)initWithDataPoints:(NSArray *)dataPoints
fillColor:(UIColor *)fillColor
strokeColor:(UIColor *)strokeColor;
/**
* Initializing the Data Set (Line and Bar charts)
*
* @param dataPoints an array of NSNumber objects representing the data to be plotted
*
* @return an instance of TWRDataSet
*/
- (instancetype)initWithDataPoints:(NSArray *)dataPoints;
@end
================================================
FILE: TWRCharts/TWRDataSet.m
================================================
//
// TWRDataSet.m
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRDataSet.h"
@implementation TWRDataSet
- (instancetype)initWithDataPoints:(NSArray *)dataPoints {
// Default color: light gray
UIColor *fillColor = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:220/255.0f alpha:0.5];
UIColor *strokeColor = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:220/255.0f alpha:1.0];
UIColor *pointColor = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:220/255.0f alpha:1.0];
UIColor *pointStrokeColor = [UIColor whiteColor];
self = [self initWithDataPoints:dataPoints fillColor:fillColor strokeColor:strokeColor pointColor:pointColor pointStrokeColor:pointStrokeColor];
return self;
}
- (instancetype)initWithDataPoints:(NSArray *)dataPoints
fillColor:(UIColor *)fillColor
strokeColor:(UIColor *)strokeColor {
UIColor *pointColor = strokeColor;
UIColor *pointStrokeColor = strokeColor;
self = [self initWithDataPoints:dataPoints fillColor:fillColor strokeColor:strokeColor pointColor:pointColor pointStrokeColor:pointStrokeColor];
return self;
}
- (instancetype)initWithDataPoints:(NSArray *)dataPoints
fillColor:(UIColor *)fillColor
strokeColor:(UIColor *)strokeColor
pointColor:(UIColor *)pointColor
pointStrokeColor:(UIColor *)pointStrokeColor {
self = [super init];
if (self) {
_dataPoints = dataPoints.mutableCopy;
_fillColor = fillColor;
_strokeColor = strokeColor;
_pointColor = pointColor;
_pointStrokeColor = pointStrokeColor;
}
return self;
}
@end
================================================
FILE: TWRCharts/TWRLineChart.h
================================================
//
// TWRLineChart.h
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <Foundation/Foundation.h>
@class TWRDataSet;
@interface TWRLineChart : NSObject
@property (copy, nonatomic) NSMutableArray *labels;
@property (copy, nonatomic) NSMutableArray *dataSets;
@property (assign, nonatomic) BOOL animated;
@property(nonatomic) BOOL curveLines;
/**
* Initializing the Line Chart object
*
* @param labels an NSArray of labels (NSString) to go along with the data
* @param dataSets an NSArray of TWRDataSet objects containing the data to be plotted
* @param animated a BOOL defining whether the chart should be animated or not
*
* @return an instance of TWRLineChart
*/
- (instancetype)initWithLabels:(NSArray *)labels
dataSets:(NSArray *)dataSets
animated:(BOOL)animated;
/**
* Initializing the Line Chart object
*
* @param labels an NSArray of labels (NSString) to go along with the data
* @param dataSets an NSArray of TWRDataSet objects containing the data to be plotted
* @param animated a BOOL defining whether the chart should be animated or not
* @param curved a BOOL defining whether the chart should be curved or not
*
* @return an instance of TWRLineChart
*/
- (instancetype)initWithLabels:(NSArray *)labels
dataSets:(NSArray *)dataSets
animated:(BOOL)animated
curved:(BOOL)curved;
@end
================================================
FILE: TWRCharts/TWRLineChart.m
================================================
//
// TWRLineChart.m
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRLineChart.h"
@interface TWRLineChart ()
@end
@implementation TWRLineChart
- (instancetype)initWithLabels:(NSArray *)labels
dataSets:(NSArray *)dataSets
animated:(BOOL)animated {
return [self initWithLabels:labels dataSets:dataSets animated:animated
curved:YES];
}
- (instancetype)initWithLabels:(NSArray *)labels
dataSets:(NSArray *)dataSets
animated:(BOOL)animated
curved:(BOOL)curved
{
self = [super init];
if (self) {
_labels = labels.mutableCopy;
_dataSets = dataSets.mutableCopy;
_animated = animated;
_curveLines = curved;
}
return self;
}
@end
================================================
FILE: TWRCharts/UIColor+HexString.h
================================================
//
// UIColor+HexString.h
// ChartJS
//
// Created by Michelangelo Chasseur on 23/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIColor (HexString)
- (NSString *)hexString;
@end
================================================
FILE: TWRCharts/UIColor+HexString.m
================================================
//
// UIColor+HexString.m
// ChartJS
//
// Created by Michelangelo Chasseur on 23/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "UIColor+HexString.h"
@implementation UIColor (HexString)
- (NSString *)hexString {
const CGFloat *components = CGColorGetComponents(self.CGColor);
CGFloat r = components[0];
CGFloat g = components[1];
CGFloat b = components[2];
NSString *hexString=[NSString stringWithFormat:@"#%02X%02X%02X", (int)(r * 255), (int)(g * 255), (int)(b * 255)];
return hexString;
}
@end
================================================
FILE: TWRCharts/index.html
================================================
<!doctype html>
<html>
<head>
<title></title>
<meta name = "viewport" content = "initial-scale = 1, user-scalable = no">
<style>
</style>
</head>
<body style="background-color: transparent;">
<canvas></canvas>
<a id="callback" href="callback:whatever"></a>
<script src="ChartNew.min.js"></script>
</body>
</html>
================================================
FILE: TWRCharts.podspec
================================================
Pod::Spec.new do |s|
s.name = "TWRCharts"
s.version = "0.3"
s.summary = "An Obj-C wrapper for ChartJS. Easily build animated charts by leveraging the power of native code."
s.homepage = "https://github.com/chasseurmic/TWRCharts"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "Michelangelo Chasseur" => "chasseurmic@gmail.com" }
s.social_media_url = "http://twitter.com/chasseurmic"
s.source = {
:git => "https://github.com/chasseurmic/TWRCharts.git",
:tag => "0.2"
}
s.resource = ['TWRCharts/*.js', 'TWRCharts/*.html']
s.platform = :ios, '6.0'
s.source_files = 'TWRCharts/*.{h,m}'
s.requires_arc = true
end
================================================
FILE: TWRChartsDemo/ChartJS/Base.lproj/Main.storyboard
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13C1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="ARQ-HH-fGh">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="TWRViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="mPm-5C-unx">
<rect key="frame" x="20" y="520" width="280" height="29"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<segments>
<segment title="Line"/>
<segment title="Bar"/>
<segment title="Pie"/>
</segments>
</segmentedControl>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="mPm-5C-unx" secondAttribute="trailing" constant="20" id="Qsz-L0-xJq"/>
<constraint firstItem="2fi-mo-0CV" firstAttribute="top" secondItem="mPm-5C-unx" secondAttribute="bottom" constant="20" id="jJg-xP-aeF"/>
<constraint firstItem="mPm-5C-unx" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leading" constant="20" id="sLF-m3-u13"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="k7L-FF-T70"/>
<connections>
<outlet property="segmentedControl" destination="mPm-5C-unx" id="Zmd-jw-6vh"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="677" y="43"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="U1c-bM-jEO">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="ARQ-HH-fGh" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="zpN-fl-rFc">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="vXZ-lx-hvc" kind="relationship" relationship="rootViewController" id="xOZ-i7-Eqw"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="TJm-Mu-uVz" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="206" y="43"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>
================================================
FILE: TWRChartsDemo/ChartJS/ChartJS-Info.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>re.touchwa.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
================================================
FILE: TWRChartsDemo/ChartJS/ChartJS-Prefix.pch
================================================
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
#import <Availability.h>
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
================================================
FILE: TWRChartsDemo/ChartJS/Images.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: TWRChartsDemo/ChartJS/Images.xcassets/LaunchImage.launchimage/Contents.json
================================================
{
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"subtype" : "retina4",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: TWRChartsDemo/ChartJS/TWRAppDelegate.h
================================================
//
// TWRAppDelegate.h
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface TWRAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRAppDelegate.m
================================================
//
// TWRAppDelegate.m
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRAppDelegate.h"
@implementation TWRAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// 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.
// 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.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// 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.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// 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.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRBarChart.h
================================================
//
// TWRBarChart.h
// ChartJS
//
// Created by Michelangelo Chasseur on 22/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <Foundation/Foundation.h>
@class TWRDataSet;
@interface TWRBarChart : NSObject
@property (copy, nonatomic) NSMutableArray *labels;
@property (copy, nonatomic) NSMutableArray *dataSets;
@property (assign, nonatomic) BOOL animated;
/**
* Initializing the Bar Chart object
*
* @param labels an NSArray of labels (NSString) to go along with the data
* @param dataSets an NSArray of TWRDataSet objects containing the data to be plotted
* @param animated a BOOL defining whether the chart should be animated or not
*
* @return an instance of TWRBarChart
*/
- (instancetype)initWithLabels:(NSArray *)labels
dataSets:(NSArray *)dataSets
animated:(BOOL)animated;
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRBarChart.m
================================================
//
// TWRBarChart.m
// ChartJS
//
// Created by Michelangelo Chasseur on 22/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRBarChart.h"
@implementation TWRBarChart
- (instancetype)initWithLabels:(NSArray *)labels
dataSets:(NSArray *)dataSets
animated:(BOOL)animated {
self = [super init];
if (self) {
_labels = labels.mutableCopy;
_dataSets = dataSets.mutableCopy;
_animated = animated;
}
return self;
}
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRChart.h
================================================
//
// TWRChart.h
// ChartJS
//
// Created by Michelangelo Chasseur on 23/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#ifndef ChartJS_TWRChart_h
#define ChartJS_TWRChart_h
#import "TWRChartView.h"
#import "TWRLineChart.h"
#import "TWRBarChart.h"
#import "TWRCircularChart.h"
#import "TWRDataSet.h"
#endif
================================================
FILE: TWRChartsDemo/ChartJS/TWRChartBuilder.h
================================================
//
// TWRChartBuilder.h
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TWRChartBuilder : NSObject
+ (NSString *)buildChartWithElement:(id)element;
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRChartBuilder.m
================================================
//
// TWRChartBuilder.m
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRChartBuilder.h"
#import "TWRLineChart.h"
#import "TWRBarChart.h"
#import "TWRCircularChart.h"
#import "TWRDataSet.h"
#import "TWRDataSet+Strings.h"
#import "UIColor+HexString.h"
@interface TWRChartBuilder ()
+ (NSString *)buildLineChartStringForElement:(TWRLineChart *)element;
+ (NSString *)buildBarChartStringForElement:(TWRBarChart *)element;
+ (NSString *)buildCircularChartStringForElement:(TWRCircularChart *)element;
@end
@implementation TWRChartBuilder
+ (NSString *)buildChartWithElement:(id)element {
__block NSString *retString;
if ([element isKindOfClass:[TWRLineChart class]]) {
retString = [self buildLineChartStringForElement:element];
} else if ([element isKindOfClass:[TWRBarChart class]]) {
retString = [self buildBarChartStringForElement:element];
} else if ([element isKindOfClass:[TWRCircularChart class]]) {
retString = [self buildCircularChartStringForElement:element];
}
return retString;
}
#pragma mark - Private API
+ (NSString *)buildLineChartStringForElement:(TWRLineChart *)element {
__block NSString *retString;
retString = @"var context = document.getElementById(\"canvas\").getContext(\"2d\"); var lineChartData = { labels:[";
TWRLineChart *lineChart = (TWRLineChart *)element;
[lineChart.labels enumerateObjectsUsingBlock:^(NSString *label, NSUInteger idx, BOOL *stop) {
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"\"%@\"", label]];
if (idx != lineChart.labels.count - 1) {
retString = [retString stringByAppendingString:@","];
} else {
// close the array
retString = [retString stringByAppendingString:@"], datasets:["];
}
}];
[lineChart.dataSets enumerateObjectsUsingBlock:^(TWRDataSet *dataset, NSUInteger idx, BOOL *stop) {
NSString *fillColorString = [dataset fillColorString];
NSString *strokeColorString = [dataset strokeColorString];
NSString *pointColorString = [dataset pointColorString];
NSString *pointStrokeColorString = [dataset pointStrokeColorString];
NSString *dataString = [dataset dataString];
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"{fillColor:%@,strokeColor:%@,pointColor:%@,pointStrokeColor:%@,data:%@}", fillColorString, strokeColorString, pointColorString, pointStrokeColorString, dataString]];
if (idx != lineChart.dataSets.count - 1) {
retString = [retString stringByAppendingString:@","];
} else {
retString = [retString stringByAppendingString:@"]};"];
}
}];
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"var options = {animation:%@};", lineChart.animated ? @"true" : @"false"]];
retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Line(lineChartData,options);"];
return retString;
}
+ (NSString *)buildBarChartStringForElement:(TWRBarChart *)element {
__block NSString *retString;
retString = @"var context = document.getElementById(\"canvas\").getContext(\"2d\"); var barChartData = { labels:[";
TWRBarChart *barChart = (TWRBarChart *)element;
[barChart.labels enumerateObjectsUsingBlock:^(NSString *label, NSUInteger idx, BOOL *stop) {
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"\"%@\"", label]];
if (idx != barChart.labels.count - 1) {
retString = [retString stringByAppendingString:@","];
} else {
// close the array
retString = [retString stringByAppendingString:@"], datasets:["];
}
}];
[barChart.dataSets enumerateObjectsUsingBlock:^(TWRDataSet *dataset, NSUInteger idx, BOOL *stop) {
NSString *fillColorString = [dataset fillColorString];
NSString *strokeColorString = [dataset strokeColorString];
NSString *pointColorString = [dataset pointColorString];
NSString *pointStrokeColorString = [dataset pointStrokeColorString];
NSString *dataString = [dataset dataString];
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"{fillColor:%@,strokeColor:%@,pointColor:%@,pointStrokeColor:%@,data:%@}", fillColorString, strokeColorString, pointColorString, pointStrokeColorString, dataString]];
if (idx != barChart.dataSets.count - 1) {
retString = [retString stringByAppendingString:@","];
} else {
retString = [retString stringByAppendingString:@"]};"];
}
}];
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"var options = {animation:%@};", barChart.animated ? @"true" : @"false"]];
retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Bar(barChartData,options);"];
return retString;
}
+ (NSString *)buildCircularChartStringForElement:(TWRCircularChart *)element {
__block NSString *retString;
retString = @"var context = document.getElementById(\"canvas\").getContext(\"2d\"); var pieChartData = [";
TWRCircularChart *pieChart = (TWRCircularChart *)element;
[pieChart.values enumerateObjectsUsingBlock:^(NSNumber *number, NSUInteger idx, BOOL *stop) {
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"{value:%@, color:\"%@\"}",number, [(UIColor *)pieChart.colors[idx] hexString]]];
if (idx != pieChart.values.count - 1) {
retString = [retString stringByAppendingString:@","];
} else {
retString = [retString stringByAppendingString:@"];"];
}
}];
retString = [retString stringByAppendingString:@"function onFinish(){document.getElementById('callback').click();};"];
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"var options = {animation:%@, onAnimationComplete:%@};", pieChart.animated ? @"true" : @"false", @"onFinish"]];
// Doughnut or Pie
if (pieChart.type == TWRCircularChartTypePie) {
retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Pie(pieChartData, options);"];
} else if (pieChart.type == TWRCircularChartTypeDoughnut) {
retString = [retString stringByAppendingString:@"var myLine = new Chart(context).Doughnut(pieChartData,options);"];
}
return retString;
}
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRChartView.h
================================================
//
// TWRChartView.h
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
typedef void(^TWRAnimationCompletionBlock)(BOOL finished);
#import <UIKit/UIKit.h>
@class TWRBarChart;
@class TWRLineChart;
@class TWRCircularChart;
@interface TWRChartView : UIWebView
@property (copy, nonatomic) NSString *chartJsFilePath;
/**
* Loading a Bar chart
*
* @param barChart the TWRBarChart object that needs to be drawn by the view
*/
- (void)loadBarChart:(TWRBarChart *)barChart;
/**
* Loading a Bar chart
*
* @param barChart the TWRBarChart object that needs to be drawn by the view
* @param block the completion block that gets called once the animation has completed
*/
- (void)loadBarChart:(TWRBarChart *)barChart withCompletionHandler:(TWRAnimationCompletionBlock)block;
/**
* Loading a Line chart
*
* @param lineChart the TWRLineChart object that needs to be drawn by the view
*/
- (void)loadLineChart:(TWRLineChart *)lineChart;
/**
* Loading a Line chart
*
* @param lineChart the TWRLineChart object that needs to be drawn by the view
* @param block the completion block that gets called once the animation has completed
*/
- (void)loadLineChart:(TWRLineChart *)lineChart withCompletionHandler:(TWRAnimationCompletionBlock)block;
/**
* Loading a Circular chart
*
* @param circularChart the TWRCircularChart object that needs to be drawn by the view
*/
- (void)loadCircularChart:(TWRCircularChart *)circularChart;
/**
* Loading a Circular chart
*
* @param circularChart the TWRCircularChart object that needs to be drawn by the view
* @param block the completion block that gets called once the animation has completed
*/
- (void)loadCircularChart:(TWRCircularChart *)circularChart withCompletionHandler:(TWRAnimationCompletionBlock)block;
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRChartView.m
================================================
//
// TWRChartView.m
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRChartView.h"
#import "TWRLineChart.h"
#import "TWRBarChart.h"
#import "TWRChartBuilder.h"
#import "TWRCircularChart.h"
@interface TWRChartView () <UIWebViewDelegate>
@property (copy, nonatomic) NSString *htmlFilePath;
@property (copy, nonatomic) NSString *jsFileString;
@property (copy, nonatomic) TWRAnimationCompletionBlock block;
@end
@implementation TWRChartView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self commonInit];
}
return self;
}
- (void)commonInit {
// Setting self as the delegate
self.delegate = self;
// Let the view be transparent
self.opaque = NO;
// HTML index file
NSString *htmlFilePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
_htmlFilePath = htmlFilePath;
self.userInteractionEnabled = NO;
}
- (void)didMoveToSuperview {
// Init request
NSError *error;
// Load Javascript and store it in local ivar
_jsFileString = [NSString stringWithContentsOfFile:_chartJsFilePath encoding:NSUTF8StringEncoding error:&error];
[self loadIndex];
// [self loadRequest:request];
}
- (void)loadBarChart:(TWRBarChart *)barChart {
if ([barChart isKindOfClass:[TWRBarChart class]] ) {
_jsFileString = [TWRChartBuilder buildChartWithElement:barChart];
[self stringByEvaluatingJavaScriptFromString:_jsFileString];
[self loadIndex];
} else {
NSException *exception = [NSException exceptionWithName:@"TWRChartInvalicChartElement"
reason:@"The element object provided to the chart view is not a valid bar chart."
userInfo:nil];
[exception raise];
}
}
- (void)loadBarChart:(TWRBarChart *)barChart withCompletionHandler:(TWRAnimationCompletionBlock)block {
_block = block;
[self loadBarChart:barChart];
}
- (void)loadLineChart:(TWRLineChart *)lineChart {
if ([lineChart isKindOfClass:[TWRLineChart class]]) {
_jsFileString = [TWRChartBuilder buildChartWithElement:lineChart];
[self stringByEvaluatingJavaScriptFromString:_jsFileString];
[self loadIndex];
} else {
NSException *exception = [NSException exceptionWithName:@"TWRChartInvalicChartElement"
reason:@"The element object provided to the chart view is not a valid line chart."
userInfo:nil];
[exception raise];
}
}
- (void)loadLineChart:(TWRLineChart *)lineChart withCompletionHandler:(TWRAnimationCompletionBlock)block {
_block = block;
[self loadLineChart:lineChart];
}
- (void)loadCircularChart:(TWRCircularChart *)circularChart {
if ([circularChart isKindOfClass:[TWRCircularChart class]]) {
_jsFileString = [TWRChartBuilder buildChartWithElement:circularChart];
[self stringByEvaluatingJavaScriptFromString:_jsFileString];
[self loadIndex];
} else {
NSException *exception = [NSException exceptionWithName:@"TWRChartInvalicChartElement"
reason:@"The element object provided to the chart view is not a valid circular chart."
userInfo:nil];
[exception raise];
}
}
- (void)loadCircularChart:(TWRCircularChart *)circularChart withCompletionHandler:(TWRAnimationCompletionBlock)block {
_block = block;
[self loadCircularChart:circularChart];
}
#pragma mark - Private API
- (void)loadIndex {
NSError *error;
// Load index.html
NSString *htmlString = [NSString stringWithContentsOfFile:_htmlFilePath encoding:NSUTF8StringEncoding error:&error];
// Set canvas size according to frame dimensions. Leave space for labels at the bottom.
NSString *canvasString = [NSString stringWithFormat:@"<canvas id=\"canvas\" height=\"%d\" width=\"%d\"></canvas>", (int)CGRectGetHeight(self.frame)-20, (int)CGRectGetWidth(self.frame) - 10];
htmlString = [htmlString stringByReplacingOccurrencesOfString:@"<canvas></canvas>" withString:canvasString];
// Load it!
[self loadHTMLString:htmlString baseURL:[[NSBundle mainBundle] bundleURL]];
}
#pragma mark - Web View Delegate methods
-(void)webViewDidFinishLoad:(UIWebView *)webView {
[self stringByEvaluatingJavaScriptFromString:_jsFileString];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
// Listen for Javasrcipt callback when chart ends animation
if ( [[[request URL] scheme] isEqualToString:@"callback"] ) {
if (_block) {
_block(YES);
}
return NO;
}
return YES;
}
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRCircularChart.h
================================================
//
// TWRPieChart.h
// ChartJS
//
// Created by Michelangelo Chasseur on 22/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
typedef NS_ENUM(NSUInteger, TWRCircularChartType) {
TWRCircularChartTypePie = 0,
TWRCircularChartTypeDoughnut
};
#import <Foundation/Foundation.h>
@interface TWRCircularChart : NSObject
@property (copy, nonatomic) NSMutableArray *values;
@property (copy, nonatomic) NSMutableArray *colors;
@property (assign, nonatomic) BOOL animated;
@property (assign, nonatomic) TWRCircularChartType type;
/**
* Initializing the Circular Chart object
*
* @param values an array of NSNumber objects that represent the data to be plotted
* @param colors an array of UIColor objects to go along with the previously provided data
* @param type the type of the circular chart to be instantiated, either a Pie chart or a Doughnut chart
* @param animated a BOOL defining whether the chart should be animated or not
*
* @return an instance of TWRCircularChart
*/
- (instancetype)initWithValues:(NSArray *)values
colors:(NSArray *)colors
type:(TWRCircularChartType)type
animated:(BOOL)animated;
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRCircularChart.m
================================================
//
// TWRPieChart.m
// ChartJS
//
// Created by Michelangelo Chasseur on 22/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRCircularChart.h"
@implementation TWRCircularChart
- (instancetype)initWithValues:(NSArray *)values
colors:(NSArray *)colors
type:(TWRCircularChartType)type
animated:(BOOL)animated {
self = [super init];
if (self) {
_values = values.mutableCopy;
_colors = colors.mutableCopy;
_type = type;
_animated = animated;
}
return self;
}
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRDataSet+Strings.h
================================================
//
// TWRDataSet+Strings.h
// ChartJS
//
// Created by Michelangelo Chasseur on 22/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRDataSet.h"
@interface TWRDataSet (Strings)
- (NSString *)fillColorString;
- (NSString *)strokeColorString;
- (NSString *)pointColorString;
- (NSString *)pointStrokeColorString;
- (NSString *)dataString;
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRDataSet+Strings.m
================================================
//
// TWRDataSet+Strings.m
// ChartJS
//
// Created by Michelangelo Chasseur on 22/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRDataSet+Strings.h"
@implementation TWRDataSet (Strings)
- (NSString *)fillColorString {
CGFloat red;
CGFloat green;
CGFloat blue;
CGFloat alpha;
BOOL valid = [self.fillColor getRed:&red green:&green blue:&blue alpha:&alpha];
NSString *retString;
if (valid) {
retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha];
}
return retString;
}
- (NSString *)strokeColorString {
CGFloat red;
CGFloat green;
CGFloat blue;
CGFloat alpha;
BOOL valid = [self.strokeColor getRed:&red green:&green blue:&blue alpha:&alpha];
NSString *retString;
if (valid) {
retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha];
}
return retString;
}
- (NSString *)pointColorString {
CGFloat red;
CGFloat green;
CGFloat blue;
CGFloat alpha;
BOOL valid = [self.pointColor getRed:&red green:&green blue:&blue alpha:&alpha];
NSString *retString;
if (valid) {
retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha];
}
return retString;
}
- (NSString *)pointStrokeColorString {
CGFloat red;
CGFloat green;
CGFloat blue;
CGFloat alpha;
BOOL valid = [self.pointStrokeColor getRed:&red green:&green blue:&blue alpha:&alpha];
NSString *retString;
if (valid) {
retString = [NSString stringWithFormat:@"\"rgba(%d,%d,%d,%f)\"",(int)(red * 255),(int)(green * 255),(int)(blue * 255),alpha];
}
return retString;
}
- (NSString *)dataString {
__block NSString *retString = @"[";
[self.dataPoints enumerateObjectsUsingBlock:^(NSNumber *number, NSUInteger idx, BOOL *stop) {
retString = [retString stringByAppendingString:[NSString stringWithFormat:@"%@", number]];
if (idx != self.dataPoints.count - 1) {
retString = [retString stringByAppendingString:@","];
} else {
retString = [retString stringByAppendingString:@"]"];
}
}];
return retString;
}
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRDataSet.h
================================================
//
// TWRDataSet.h
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TWRDataSet : NSObject
@property (strong, nonatomic) UIColor *fillColor;
@property (strong, nonatomic) UIColor *strokeColor;
@property (strong, nonatomic) UIColor *pointColor;
@property (strong, nonatomic) UIColor *pointStrokeColor;
@property (copy, nonatomic) NSMutableArray *dataPoints;
/**
* Initializing the Data Set (Line charts only)
*
* @param dataPoints an array of NSNumber objects representing the data to be plotted
* @param fillColor an array of UIColor objects to go along with the provided data that represent the fill color of the bar / line
* @param strokeColor an array of UIColor objects to go along with the provided data that represent the stroke color of the bar / line
* @param pointColor an array of UIColor objects to go along with the provided data that represent the fill color of line points
* @param pointStrokeColor an array of UIColor objects to go along with the provided data that represent the stroke color of line points
*
* @return an instance of TWRDataSet
*/
- (instancetype)initWithDataPoints:(NSArray *)dataPoints
fillColor:(UIColor *)fillColor
strokeColor:(UIColor *)strokeColor
pointColor:(UIColor *)pointColor
pointStrokeColor:(UIColor *)pointStrokeColor;
/**
* Initializing the Data Set (Line and Bar charts)
*
* @param dataPoints an array of NSNumber objects representing the data to be plotted
* @param fillColor an array of UIColor objects to go along with the provided data that represent the fill color of the bar / line
* @param strokeColor an array of UIColor objects to go along with the provided data that represent the stroke color of the bar / line
*
* @return an instance of TWRDataSet
*/
- (instancetype)initWithDataPoints:(NSArray *)dataPoints
fillColor:(UIColor *)fillColor
strokeColor:(UIColor *)strokeColor;
/**
* Initializing the Data Set (Line and Bar charts)
*
* @param dataPoints an array of NSNumber objects representing the data to be plotted
*
* @return an instance of TWRDataSet
*/
- (instancetype)initWithDataPoints:(NSArray *)dataPoints;
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRDataSet.m
================================================
//
// TWRDataSet.m
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRDataSet.h"
@implementation TWRDataSet
- (instancetype)initWithDataPoints:(NSArray *)dataPoints {
// Default color: light gray
UIColor *fillColor = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:220/255.0f alpha:0.5];
UIColor *strokeColor = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:220/255.0f alpha:1.0];
UIColor *pointColor = [UIColor colorWithRed:220/255.0f green:220/255.0f blue:220/255.0f alpha:1.0];
UIColor *pointStrokeColor = [UIColor whiteColor];
self = [self initWithDataPoints:dataPoints fillColor:fillColor strokeColor:strokeColor pointColor:pointColor pointStrokeColor:pointStrokeColor];
return self;
}
- (instancetype)initWithDataPoints:(NSArray *)dataPoints
fillColor:(UIColor *)fillColor
strokeColor:(UIColor *)strokeColor {
UIColor *pointColor = strokeColor;
UIColor *pointStrokeColor = strokeColor;
self = [self initWithDataPoints:dataPoints fillColor:fillColor strokeColor:strokeColor pointColor:pointColor pointStrokeColor:pointStrokeColor];
return self;
}
- (instancetype)initWithDataPoints:(NSArray *)dataPoints
fillColor:(UIColor *)fillColor
strokeColor:(UIColor *)strokeColor
pointColor:(UIColor *)pointColor
pointStrokeColor:(UIColor *)pointStrokeColor {
self = [super init];
if (self) {
_dataPoints = dataPoints.mutableCopy;
_fillColor = fillColor;
_strokeColor = strokeColor;
_pointColor = pointColor;
_pointStrokeColor = pointStrokeColor;
}
return self;
}
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRLineChart.h
================================================
//
// TWRLineChart.h
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <Foundation/Foundation.h>
@class TWRDataSet;
@interface TWRLineChart : NSObject
@property (copy, nonatomic) NSMutableArray *labels;
@property (copy, nonatomic) NSMutableArray *dataSets;
@property (assign, nonatomic) BOOL animated;
@property(nonatomic) BOOL curveLines;
- (instancetype)initWithLabels:(NSArray *)labels dataSets:(NSArray *)dataSets animated:(BOOL)animated;
/**
* Initializing the Line Chart object
*
* @param labels an NSArray of labels (NSString) to go along with the data
* @param dataSets an NSArray of TWRDataSet objects containing the data to be plotted
* @param animated a BOOL defining whether the chart should be animated or not
*
* @return an instance of TWRLineChart
*/
- (instancetype)initWithLabels:(NSArray *)labels
dataSets:(NSArray *)dataSets
animated:(BOOL)animated
curved:(BOOL)curved;
/**
* Initializing the Line Chart object
*
* @param labels an NSArray of labels (NSString) to go along with the data
* @param dataSets an NSArray of TWRDataSet objects containing the data to be plotted
* @param animated a BOOL defining whether the chart should be animated or not
* @param curved a BOOL defining whether the chart should be curved or not
*
* @return an instance of TWRLineChart
*/
- (instancetype)initWithLabels:(NSArray *)labels
dataSets:(NSArray *)dataSets
animated:(BOOL)animated
curved:(BOOL)curved;
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRLineChart.m
================================================
//
// TWRLineChart.m
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRLineChart.h"
@interface TWRLineChart ()
@end
@implementation TWRLineChart
- (instancetype)initWithLabels:(NSArray *)labels
dataSets:(NSArray *)dataSets
animated:(BOOL)animated {
self = [super init];
if (self) {
_labels = labels.mutableCopy;
_dataSets = dataSets.mutableCopy;
_animated = animated;
}
return self;
}
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRViewController.h
================================================
//
// TWRViewController.h
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface TWRViewController : UIViewController
@end
================================================
FILE: TWRChartsDemo/ChartJS/TWRViewController.m
================================================
//
// TWRViewController.m
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "TWRViewController.h"
#import "TWRChart.h"
@interface TWRViewController ()
@property(strong, nonatomic) TWRChartView *chartView;
@property(weak, nonatomic) IBOutlet UISegmentedControl *segmentedControl;
- (void)switchChart:(UISegmentedControl *)sender;
@end
@implementation TWRViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Charts";
// Segmented Control
[_segmentedControl addTarget:self action:@selector(switchChart:) forControlEvents:UIControlEventValueChanged];
// Chart View
_chartView = [[TWRChartView alloc] initWithFrame:CGRectMake(0, 64, 320, 300)];
_chartView.backgroundColor = [UIColor clearColor];
// User interaction is disabled by default. You can enable it again if you want
// _chartView.userInteractionEnabled = YES;
// Load chart by using a ChartJS javascript file
NSString *jsFilePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"js"];
[_chartView setChartJsFilePath:jsFilePath];
// Add the chart view to the controller's view
[self.view addSubview:_chartView];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/**
* Loads a bar chart using native code
*/
- (void)loadBarChart {
// Build chart data
TWRDataSet *dataSet1 = [[TWRDataSet alloc] initWithDataPoints:@[@10, @15, @5, @15, @5]
fillColor:[[UIColor orangeColor] colorWithAlphaComponent:0.5]
strokeColor:[UIColor orangeColor]];
TWRDataSet *dataSet2 = [[TWRDataSet alloc] initWithDataPoints:@[@5, @10, @5, @15, @10]
fillColor:[[UIColor redColor] colorWithAlphaComponent:0.5]
strokeColor:[UIColor redColor]];
NSArray *labels = @[@"A", @"B", @"C", @"D", @"E"];
TWRBarChart *bar = [[TWRBarChart alloc] initWithLabels:labels
dataSets:@[dataSet1, dataSet2]
animated:YES];
// Load data
[_chartView loadBarChart:bar];
}
/**
* Loads a line chart using native code
*/
- (void)loadLineChart {
// Build chart data
TWRDataSet *dataSet1 = [[TWRDataSet alloc] initWithDataPoints:@[@10, @15, @5, @15, @5]];
TWRDataSet *dataSet2 = [[TWRDataSet alloc] initWithDataPoints:@[@5, @10, @5, @15, @10]];
NSArray *labels = @[@"A", @"B", @"C", @"D", @"E"];
TWRLineChart *line = [[TWRLineChart alloc] initWithLabels:labels
dataSets:@[dataSet1, dataSet2]
animated:NO];
// Load data
[_chartView loadLineChart:line];
}
/**
* Loads a pie / doughnut chart using native code
*/
- (void)loadPieChart {
// Values
NSArray *values = @[@20, @30, @15, @5];
// Colors
UIColor *color1 = [UIColor colorWithHue:0.5 saturation:0.6 brightness:0.6 alpha:1.0];
UIColor *color2 = [UIColor colorWithHue:0.6 saturation:0.6 brightness:0.6 alpha:1.0];
UIColor *color3 = [UIColor colorWithHue:0.7 saturation:0.6 brightness:0.6 alpha:1.0];
UIColor *color4 = [UIColor colorWithHue:0.8 saturation:0.6 brightness:0.6 alpha:1.0];
NSArray *colors = @[color1, color2, color3, color4];
// Doughnut Chart
TWRCircularChart *pieChart = [[TWRCircularChart alloc] initWithValues:values
colors:colors
type:TWRCircularChartTypeDoughnut
animated:YES];
// You can even leverage callbacks when chart animation ends!
[_chartView loadCircularChart:pieChart withCompletionHandler:^(BOOL finished) {
if (finished) {
NSLog(@"Animation finished!!!");
}
}];
}
#pragma mark - UISegmentedController switch methods
- (void)switchChart:(UISegmentedControl *)sender {
switch (sender.selectedSegmentIndex) {
//Line
case 0: {
[self loadLineChart];
}
break;
//Bar
case 1: {
[self loadBarChart];
}
break;
//Pie
case 2: {
[self loadPieChart];
}
break;
default:
break;
}
}
@end
================================================
FILE: TWRChartsDemo/ChartJS/UIColor+HexString.h
================================================
//
// UIColor+HexString.h
// ChartJS
//
// Created by Michelangelo Chasseur on 23/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIColor (HexString)
- (NSString *)hexString;
@end
================================================
FILE: TWRChartsDemo/ChartJS/UIColor+HexString.m
================================================
//
// UIColor+HexString.m
// ChartJS
//
// Created by Michelangelo Chasseur on 23/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import "UIColor+HexString.h"
@implementation UIColor (HexString)
- (NSString *)hexString {
const CGFloat *components = CGColorGetComponents(self.CGColor);
CGFloat r = components[0];
CGFloat g = components[1];
CGFloat b = components[2];
NSString *hexString=[NSString stringWithFormat:@"#%02X%02X%02X", (int)(r * 255), (int)(g * 255), (int)(b * 255)];
return hexString;
}
@end
================================================
FILE: TWRChartsDemo/ChartJS/en.lproj/InfoPlist.strings
================================================
/* Localized versions of Info.plist keys */
================================================
FILE: TWRChartsDemo/ChartJS/index.js
================================================
var context = document.getElementById("canvas").getContext("2d");
var polarData = [
{
value : 30,
color: "#D97041"
},
{
value : 90,
color: "#C7604C"
},
{
value : 24,
color: "#21323D"
},
{
value : 58,
color: "#9D9B7F"
},
{
value : 82,
color: "#7D4F6D"
},
{
value : 8,
color: "#584A5E"
}
]
var polarArea = new Chart(context).PolarArea(polarData);
================================================
FILE: TWRChartsDemo/ChartJS/main.m
================================================
//
// main.m
// ChartJS
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TWRAppDelegate.h"
int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([TWRAppDelegate class]));
}
}
================================================
FILE: TWRChartsDemo/ChartJS.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
156FFB4E1905956F00DF7D3F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 156FFB4D1905956F00DF7D3F /* Foundation.framework */; };
156FFB501905956F00DF7D3F /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 156FFB4F1905956F00DF7D3F /* CoreGraphics.framework */; };
156FFB521905956F00DF7D3F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 156FFB511905956F00DF7D3F /* UIKit.framework */; };
156FFB581905956F00DF7D3F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 156FFB561905956F00DF7D3F /* InfoPlist.strings */; };
156FFB5A1905956F00DF7D3F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 156FFB591905956F00DF7D3F /* main.m */; };
156FFB5E1905956F00DF7D3F /* TWRAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 156FFB5D1905956F00DF7D3F /* TWRAppDelegate.m */; };
156FFB611905956F00DF7D3F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 156FFB5F1905956F00DF7D3F /* Main.storyboard */; };
156FFB641905956F00DF7D3F /* TWRViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 156FFB631905956F00DF7D3F /* TWRViewController.m */; };
156FFB661905956F00DF7D3F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 156FFB651905956F00DF7D3F /* Images.xcassets */; };
156FFB6D1905957000DF7D3F /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 156FFB6C1905957000DF7D3F /* XCTest.framework */; };
156FFB6E1905957000DF7D3F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 156FFB4D1905956F00DF7D3F /* Foundation.framework */; };
156FFB6F1905957000DF7D3F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 156FFB511905956F00DF7D3F /* UIKit.framework */; };
156FFB771905957000DF7D3F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 156FFB751905957000DF7D3F /* InfoPlist.strings */; };
156FFB791905957000DF7D3F /* ChartJSTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 156FFB781905957000DF7D3F /* ChartJSTests.m */; };
1588B7BA1905B41A00ED1D1B /* index.js in Resources */ = {isa = PBXBuildFile; fileRef = 1588B7B81905B40B00ED1D1B /* index.js */; };
159E868E191C02FE002CCE9A /* ChartNew.min.js in Resources */ = {isa = PBXBuildFile; fileRef = 159E868C191C02FE002CCE9A /* ChartNew.min.js */; };
159E868F191C02FE002CCE9A /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 159E868D191C02FE002CCE9A /* index.html */; };
15D1CB03190D6BB4004F64BE /* TWRBarChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAF1190D6BB4004F64BE /* TWRBarChart.m */; };
15D1CB04190D6BB4004F64BE /* TWRChartBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAF4190D6BB4004F64BE /* TWRChartBuilder.m */; };
15D1CB05190D6BB4004F64BE /* TWRChartView.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAF6190D6BB4004F64BE /* TWRChartView.m */; };
15D1CB06190D6BB4004F64BE /* TWRCircularChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAF8190D6BB4004F64BE /* TWRCircularChart.m */; };
15D1CB07190D6BB4004F64BE /* TWRDataSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAFA190D6BB4004F64BE /* TWRDataSet.m */; };
15D1CB08190D6BB4004F64BE /* TWRDataSet+Strings.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAFC190D6BB4004F64BE /* TWRDataSet+Strings.m */; };
15D1CB09190D6BB4004F64BE /* TWRLineChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CAFE190D6BB4004F64BE /* TWRLineChart.m */; };
15D1CB0A190D6BB4004F64BE /* UIColor+HexString.m in Sources */ = {isa = PBXBuildFile; fileRef = 15D1CB00190D6BB4004F64BE /* UIColor+HexString.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
156FFB701905957000DF7D3F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 156FFB421905956F00DF7D3F /* Project object */;
proxyType = 1;
remoteGlobalIDString = 156FFB491905956F00DF7D3F;
remoteInfo = ChartJS;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
156FFB4A1905956F00DF7D3F /* ChartJS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChartJS.app; sourceTree = BUILT_PRODUCTS_DIR; };
156FFB4D1905956F00DF7D3F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
156FFB4F1905956F00DF7D3F /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
156FFB511905956F00DF7D3F /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
156FFB551905956F00DF7D3F /* ChartJS-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ChartJS-Info.plist"; sourceTree = "<group>"; };
156FFB571905956F00DF7D3F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
156FFB591905956F00DF7D3F /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
156FFB5B1905956F00DF7D3F /* ChartJS-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ChartJS-Prefix.pch"; sourceTree = "<group>"; };
156FFB5C1905956F00DF7D3F /* TWRAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TWRAppDelegate.h; sourceTree = "<group>"; };
156FFB5D1905956F00DF7D3F /* TWRAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TWRAppDelegate.m; sourceTree = "<group>"; };
156FFB601905956F00DF7D3F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
156FFB621905956F00DF7D3F /* TWRViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TWRViewController.h; sourceTree = "<group>"; };
156FFB631905956F00DF7D3F /* TWRViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TWRViewController.m; sourceTree = "<group>"; };
156FFB651905956F00DF7D3F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
156FFB6B1905957000DF7D3F /* ChartJSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ChartJSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
156FFB6C1905957000DF7D3F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
156FFB741905957000DF7D3F /* ChartJSTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ChartJSTests-Info.plist"; sourceTree = "<group>"; };
156FFB761905957000DF7D3F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
156FFB781905957000DF7D3F /* ChartJSTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ChartJSTests.m; sourceTree = "<group>"; };
1588B7B81905B40B00ED1D1B /* index.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = index.js; sourceTree = "<group>"; };
159E868C191C02FE002CCE9A /* ChartNew.min.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = ChartNew.min.js; path = ../../TWRCharts/ChartNew.min.js; sourceTree = "<group>"; };
159E868D191C02FE002CCE9A /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = index.html; path = ../../TWRCharts/index.html; sourceTree = "<group>"; };
15D1CAF0190D6BB4004F64BE /* TWRBarChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRBarChart.h; path = ../../TWRCharts/TWRBarChart.h; sourceTree = "<group>"; };
15D1CAF1190D6BB4004F64BE /* TWRBarChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TWRBarChart.m; path = ../../TWRCharts/TWRBarChart.m; sourceTree = "<group>"; };
15D1CAF2190D6BB4004F64BE /* TWRChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRChart.h; path = ../../TWRCharts/TWRChart.h; sourceTree = "<group>"; };
15D1CAF3190D6BB4004F64BE /* TWRChartBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRChartBuilder.h; path = ../../TWRCharts/TWRChartBuilder.h; sourceTree = "<group>"; };
15D1CAF4190D6BB4004F64BE /* TWRChartBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TWRChartBuilder.m; path = ../../TWRCharts/TWRChartBuilder.m; sourceTree = "<group>"; };
15D1CAF5190D6BB4004F64BE /* TWRChartView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRChartView.h; path = ../../TWRCharts/TWRChartView.h; sourceTree = "<group>"; };
15D1CAF6190D6BB4004F64BE /* TWRChartView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TWRChartView.m; path = ../../TWRCharts/TWRChartView.m; sourceTree = "<group>"; };
15D1CAF7190D6BB4004F64BE /* TWRCircularChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRCircularChart.h; path = ../../TWRCharts/TWRCircularChart.h; sourceTree = "<group>"; };
15D1CAF8190D6BB4004F64BE /* TWRCircularChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TWRCircularChart.m; path = ../../TWRCharts/TWRCircularChart.m; sourceTree = "<group>"; };
15D1CAF9190D6BB4004F64BE /* TWRDataSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRDataSet.h; path = ../../TWRCharts/TWRDataSet.h; sourceTree = "<group>"; };
15D1CAFA190D6BB4004F64BE /* TWRDataSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TWRDataSet.m; path = ../../TWRCharts/TWRDataSet.m; sourceTree = "<group>"; };
15D1CAFB190D6BB4004F64BE /* TWRDataSet+Strings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "TWRDataSet+Strings.h"; path = "../../TWRCharts/TWRDataSet+Strings.h"; sourceTree = "<group>"; };
15D1CAFC190D6BB4004F64BE /* TWRDataSet+Strings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "TWRDataSet+Strings.m"; path = "../../TWRCharts/TWRDataSet+Strings.m"; sourceTree = "<group>"; };
15D1CAFD190D6BB4004F64BE /* TWRLineChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TWRLineChart.h; path = ../../TWRCharts/TWRLineChart.h; sourceTree = "<group>"; };
15D1CAFE190D6BB4004F64BE /* TWRLineChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TWRLineChart.m; path = ../../TWRCharts/TWRLineChart.m; sourceTree = "<group>"; };
15D1CAFF190D6BB4004F64BE /* UIColor+HexString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIColor+HexString.h"; path = "../../TWRCharts/UIColor+HexString.h"; sourceTree = "<group>"; };
15D1CB00190D6BB4004F64BE /* UIColor+HexString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIColor+HexString.m"; path = "../../TWRCharts/UIColor+HexString.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
156FFB471905956F00DF7D3F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
156FFB501905956F00DF7D3F /* CoreGraphics.framework in Frameworks */,
156FFB521905956F00DF7D3F /* UIKit.framework in Frameworks */,
156FFB4E1905956F00DF7D3F /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
156FFB681905957000DF7D3F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
156FFB6D1905957000DF7D3F /* XCTest.framework in Frameworks */,
156FFB6F1905957000DF7D3F /* UIKit.framework in Frameworks */,
156FFB6E1905957000DF7D3F /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
156FFB411905956F00DF7D3F = {
isa = PBXGroup;
children = (
156FFB531905956F00DF7D3F /* ChartJS */,
156FFB721905957000DF7D3F /* ChartJSTests */,
156FFB4C1905956F00DF7D3F /* Frameworks */,
156FFB4B1905956F00DF7D3F /* Products */,
);
sourceTree = "<group>";
};
156FFB4B1905956F00DF7D3F /* Products */ = {
isa = PBXGroup;
children = (
156FFB4A1905956F00DF7D3F /* ChartJS.app */,
156FFB6B1905957000DF7D3F /* ChartJSTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
156FFB4C1905956F00DF7D3F /* Frameworks */ = {
isa = PBXGroup;
children = (
156FFB4D1905956F00DF7D3F /* Foundation.framework */,
156FFB4F1905956F00DF7D3F /* CoreGraphics.framework */,
156FFB511905956F00DF7D3F /* UIKit.framework */,
156FFB6C1905957000DF7D3F /* XCTest.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
156FFB531905956F00DF7D3F /* ChartJS */ = {
isa = PBXGroup;
children = (
156FFB5C1905956F00DF7D3F /* TWRAppDelegate.h */,
156FFB5D1905956F00DF7D3F /* TWRAppDelegate.m */,
156FFB5F1905956F00DF7D3F /* Main.storyboard */,
156FFB621905956F00DF7D3F /* TWRViewController.h */,
156FFB631905956F00DF7D3F /* TWRViewController.m */,
157CF6201905C67100442DFA /* Charts */,
156FFB651905956F00DF7D3F /* Images.xcassets */,
156FFB541905956F00DF7D3F /* Supporting Files */,
);
path = ChartJS;
sourceTree = "<group>";
};
156FFB541905956F00DF7D3F /* Supporting Files */ = {
isa = PBXGroup;
children = (
1588B7B81905B40B00ED1D1B /* index.js */,
156FFB551905956F00DF7D3F /* ChartJS-Info.plist */,
156FFB561905956F00DF7D3F /* InfoPlist.strings */,
156FFB591905956F00DF7D3F /* main.m */,
156FFB5B1905956F00DF7D3F /* ChartJS-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
156FFB721905957000DF7D3F /* ChartJSTests */ = {
isa = PBXGroup;
children = (
156FFB781905957000DF7D3F /* ChartJSTests.m */,
156FFB731905957000DF7D3F /* Supporting Files */,
);
path = ChartJSTests;
sourceTree = "<group>";
};
156FFB731905957000DF7D3F /* Supporting Files */ = {
isa = PBXGroup;
children = (
156FFB741905957000DF7D3F /* ChartJSTests-Info.plist */,
156FFB751905957000DF7D3F /* InfoPlist.strings */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
157CF6201905C67100442DFA /* Charts */ = {
isa = PBXGroup;
children = (
159E868C191C02FE002CCE9A /* ChartNew.min.js */,
159E868D191C02FE002CCE9A /* index.html */,
15D1CAF0190D6BB4004F64BE /* TWRBarChart.h */,
15D1CAF1190D6BB4004F64BE /* TWRBarChart.m */,
15D1CAF2190D6BB4004F64BE /* TWRChart.h */,
15D1CAF3190D6BB4004F64BE /* TWRChartBuilder.h */,
15D1CAF4190D6BB4004F64BE /* TWRChartBuilder.m */,
15D1CAF5190D6BB4004F64BE /* TWRChartView.h */,
15D1CAF6190D6BB4004F64BE /* TWRChartView.m */,
15D1CAF7190D6BB4004F64BE /* TWRCircularChart.h */,
15D1CAF8190D6BB4004F64BE /* TWRCircularChart.m */,
15D1CAF9190D6BB4004F64BE /* TWRDataSet.h */,
15D1CAFA190D6BB4004F64BE /* TWRDataSet.m */,
15D1CAFB190D6BB4004F64BE /* TWRDataSet+Strings.h */,
15D1CAFC190D6BB4004F64BE /* TWRDataSet+Strings.m */,
15D1CAFD190D6BB4004F64BE /* TWRLineChart.h */,
15D1CAFE190D6BB4004F64BE /* TWRLineChart.m */,
15D1CAFF190D6BB4004F64BE /* UIColor+HexString.h */,
15D1CB00190D6BB4004F64BE /* UIColor+HexString.m */,
);
name = Charts;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
156FFB491905956F00DF7D3F /* ChartJS */ = {
isa = PBXNativeTarget;
buildConfigurationList = 156FFB7C1905957000DF7D3F /* Build configuration list for PBXNativeTarget "ChartJS" */;
buildPhases = (
156FFB461905956F00DF7D3F /* Sources */,
156FFB471905956F00DF7D3F /* Frameworks */,
156FFB481905956F00DF7D3F /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = ChartJS;
productName = ChartJS;
productReference = 156FFB4A1905956F00DF7D3F /* ChartJS.app */;
productType = "com.apple.product-type.application";
};
156FFB6A1905957000DF7D3F /* ChartJSTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 156FFB7F1905957000DF7D3F /* Build configuration list for PBXNativeTarget "ChartJSTests" */;
buildPhases = (
156FFB671905957000DF7D3F /* Sources */,
156FFB681905957000DF7D3F /* Frameworks */,
156FFB691905957000DF7D3F /* Resources */,
);
buildRules = (
);
dependencies = (
156FFB711905957000DF7D3F /* PBXTargetDependency */,
);
name = ChartJSTests;
productName = ChartJSTests;
productReference = 156FFB6B1905957000DF7D3F /* ChartJSTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
156FFB421905956F00DF7D3F /* Project object */ = {
isa = PBXProject;
attributes = {
CLASSPREFIX = TWR;
LastUpgradeCheck = 0510;
ORGANIZATIONNAME = Touchware;
TargetAttributes = {
156FFB6A1905957000DF7D3F = {
TestTargetID = 156FFB491905956F00DF7D3F;
};
};
};
buildConfigurationList = 156FFB451905956F00DF7D3F /* Build configuration list for PBXProject "ChartJS" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 156FFB411905956F00DF7D3F;
productRefGroup = 156FFB4B1905956F00DF7D3F /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
156FFB491905956F00DF7D3F /* ChartJS */,
156FFB6A1905957000DF7D3F /* ChartJSTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
156FFB481905956F00DF7D3F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
159E868F191C02FE002CCE9A /* index.html in Resources */,
159E868E191C02FE002CCE9A /* ChartNew.min.js in Resources */,
1588B7BA1905B41A00ED1D1B /* index.js in Resources */,
156FFB661905956F00DF7D3F /* Images.xcassets in Resources */,
156FFB581905956F00DF7D3F /* InfoPlist.strings in Resources */,
156FFB611905956F00DF7D3F /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
156FFB691905957000DF7D3F /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
156FFB771905957000DF7D3F /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
156FFB461905956F00DF7D3F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
15D1CB09190D6BB4004F64BE /* TWRLineChart.m in Sources */,
156FFB641905956F00DF7D3F /* TWRViewController.m in Sources */,
15D1CB06190D6BB4004F64BE /* TWRCircularChart.m in Sources */,
15D1CB03190D6BB4004F64BE /* TWRBarChart.m in Sources */,
15D1CB05190D6BB4004F64BE /* TWRChartView.m in Sources */,
15D1CB04190D6BB4004F64BE /* TWRChartBuilder.m in Sources */,
15D1CB07190D6BB4004F64BE /* TWRDataSet.m in Sources */,
15D1CB08190D6BB4004F64BE /* TWRDataSet+Strings.m in Sources */,
156FFB5E1905956F00DF7D3F /* TWRAppDelegate.m in Sources */,
156FFB5A1905956F00DF7D3F /* main.m in Sources */,
15D1CB0A190D6BB4004F64BE /* UIColor+HexString.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
156FFB671905957000DF7D3F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
156FFB791905957000DF7D3F /* ChartJSTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
156FFB711905957000DF7D3F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 156FFB491905956F00DF7D3F /* ChartJS */;
targetProxy = 156FFB701905957000DF7D3F /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
156FFB561905956F00DF7D3F /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
156FFB571905956F00DF7D3F /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
156FFB5F1905956F00DF7D3F /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
156FFB601905956F00DF7D3F /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
156FFB751905957000DF7D3F /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
156FFB761905957000DF7D3F /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
156FFB7A1905957000DF7D3F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
156FFB7B1905957000DF7D3F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
156FFB7D1905957000DF7D3F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ChartJS/ChartJS-Prefix.pch";
INFOPLIST_FILE = "ChartJS/ChartJS-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
156FFB7E1905957000DF7D3F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ChartJS/ChartJS-Prefix.pch";
INFOPLIST_FILE = "ChartJS/ChartJS-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Release;
};
156FFB801905957000DF7D3F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/ChartJS.app/ChartJS";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ChartJS/ChartJS-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = "ChartJSTests/ChartJSTests-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = xctest;
};
name = Debug;
};
156FFB811905957000DF7D3F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/ChartJS.app/ChartJS";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ChartJS/ChartJS-Prefix.pch";
INFOPLIST_FILE = "ChartJSTests/ChartJSTests-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = xctest;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
156FFB451905956F00DF7D3F /* Build configuration list for PBXProject "ChartJS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
156FFB7A1905957000DF7D3F /* Debug */,
156FFB7B1905957000DF7D3F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
156FFB7C1905957000DF7D3F /* Build configuration list for PBXNativeTarget "ChartJS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
156FFB7D1905957000DF7D3F /* Debug */,
156FFB7E1905957000DF7D3F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
156FFB7F1905957000DF7D3F /* Build configuration list for PBXNativeTarget "ChartJSTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
156FFB801905957000DF7D3F /* Debug */,
156FFB811905957000DF7D3F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 156FFB421905956F00DF7D3F /* Project object */;
}
================================================
FILE: TWRChartsDemo/ChartJS.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:ChartJS.xcodeproj">
</FileRef>
</Workspace>
================================================
FILE: TWRChartsDemo/ChartJSTests/ChartJSTests-Info.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>re.touchwa.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
================================================
FILE: TWRChartsDemo/ChartJSTests/ChartJSTests.m
================================================
//
// ChartJSTests.m
// ChartJSTests
//
// Created by Michelangelo Chasseur on 21/04/14.
// Copyright (c) 2014 Touchware. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface ChartJSTests : XCTestCase
@end
@implementation ChartJSTests
- (void)setUp
{
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample
{
XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
}
@end
================================================
FILE: TWRChartsDemo/ChartJSTests/en.lproj/InfoPlist.strings
================================================
/* Localized versions of Info.plist keys */
gitextract_1j08ohm7/
├── .gitignore
├── LICENSE
├── README.md
├── TWRCharts/
│ ├── 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
├── TWRCharts.podspec
└── TWRChartsDemo/
├── 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
├── ChartJS.xcodeproj/
│ ├── project.pbxproj
│ └── project.xcworkspace/
│ └── contents.xcworkspacedata
└── ChartJSTests/
├── ChartJSTests-Info.plist
├── ChartJSTests.m
└── en.lproj/
└── InfoPlist.strings
Condensed preview — 56 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (118K chars).
[
{
"path": ".gitignore",
"chars": 214,
"preview": "# Xcode\n#\nbuild/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!defau"
},
{
"path": "LICENSE",
"chars": 1065,
"preview": "Copyright (c) 2014 Michelangelo Chasseur.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy "
},
{
"path": "README.md",
"chars": 7158,
"preview": "TWRCharts\n=================\n\n## TWRCharts\n\nAn Obj-C wrapper for ChartJS. Easily build animated charts by leveraging the "
},
{
"path": "TWRCharts/TWRBarChart.h",
"chars": 875,
"preview": "//\n// TWRBarChart.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 22/04/14.\n// Copyright (c) 2014 Touchware. "
},
{
"path": "TWRCharts/TWRBarChart.m",
"chars": 529,
"preview": "//\n// TWRBarChart.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 22/04/14.\n// Copyright (c) 2014 Touchware. "
},
{
"path": "TWRCharts/TWRChart.h",
"chars": 331,
"preview": "//\n// TWRChart.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 23/04/14.\n// Copyright (c) 2014 Touchware. All"
},
{
"path": "TWRCharts/TWRChartBuilder.h",
"chars": 278,
"preview": "//\n// TWRChartBuilder.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchwa"
},
{
"path": "TWRCharts/TWRChartBuilder.m",
"chars": 6603,
"preview": "//\n// TWRChartBuilder.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchwa"
},
{
"path": "TWRCharts/TWRChartView.h",
"chars": 1877,
"preview": "//\n// TWRChartView.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware."
},
{
"path": "TWRCharts/TWRChartView.m",
"chars": 5318,
"preview": "//\n// TWRChartView.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware."
},
{
"path": "TWRCharts/TWRCircularChart.h",
"chars": 1230,
"preview": "//\n// TWRPieChart.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 22/04/14.\n// Copyright (c) 2014 Touchware. "
},
{
"path": "TWRCharts/TWRCircularChart.m",
"chars": 613,
"preview": "//\n// TWRPieChart.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 22/04/14.\n// Copyright (c) 2014 Touchware. "
},
{
"path": "TWRCharts/TWRDataSet+Strings.h",
"chars": 375,
"preview": "//\n// TWRDataSet+Strings.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 22/04/14.\n// Copyright (c) 2014 Touc"
},
{
"path": "TWRCharts/TWRDataSet+Strings.m",
"chars": 2336,
"preview": "//\n// TWRDataSet+Strings.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 22/04/14.\n// Copyright (c) 2014 Touc"
},
{
"path": "TWRCharts/TWRDataSet.h",
"chars": 2411,
"preview": "//\n// TWRDataSet.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware. A"
},
{
"path": "TWRCharts/TWRDataSet.m",
"chars": 1814,
"preview": "//\n// TWRDataSet.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware. A"
},
{
"path": "TWRCharts/TWRLineChart.h",
"chars": 1523,
"preview": "//\n// TWRLineChart.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware."
},
{
"path": "TWRCharts/TWRLineChart.m",
"chars": 898,
"preview": "//\n// TWRLineChart.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware."
},
{
"path": "TWRCharts/UIColor+HexString.h",
"chars": 239,
"preview": "//\n// UIColor+HexString.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 23/04/14.\n// Copyright (c) 2014 Touch"
},
{
"path": "TWRCharts/UIColor+HexString.m",
"chars": 554,
"preview": "//\n// UIColor+HexString.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 23/04/14.\n// Copyright (c) 2014 Touch"
},
{
"path": "TWRCharts/index.html",
"chars": 343,
"preview": "<!doctype html>\n<html>\n\t<head>\n\t\t<title></title>\n\t\t<meta name = \"viewport\" content = \"initial-scale = 1, user-scalable ="
},
{
"path": "TWRCharts.podspec",
"chars": 705,
"preview": "Pod::Spec.new do |s|\n\n s.name = \"TWRCharts\"\n s.version = \"0.3\"\n s.summary = \"An Obj-C wrapper for C"
},
{
"path": "TWRChartsDemo/ChartJS/Base.lproj/Main.storyboard",
"chars": 4569,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard"
},
{
"path": "TWRChartsDemo/ChartJS/ChartJS-Info.plist",
"chars": 1223,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "TWRChartsDemo/ChartJS/ChartJS-Prefix.pch",
"chars": 344,
"preview": "//\n// Prefix header\n//\n// The contents of this file are implicitly included at the beginning of every source file.\n//\n"
},
{
"path": "TWRChartsDemo/ChartJS/Images.xcassets/AppIcon.appiconset/Contents.json",
"chars": 333,
"preview": "{\n \"images\" : [\n {\n \"idiom\" : \"iphone\",\n \"size\" : \"29x29\",\n \"scale\" : \"2x\"\n },\n {\n \"idiom\""
},
{
"path": "TWRChartsDemo/ChartJS/Images.xcassets/LaunchImage.launchimage/Contents.json",
"chars": 442,
"preview": "{\n \"images\" : [\n {\n \"orientation\" : \"portrait\",\n \"idiom\" : \"iphone\",\n \"extent\" : \"full-screen\",\n "
},
{
"path": "TWRChartsDemo/ChartJS/TWRAppDelegate.h",
"chars": 292,
"preview": "//\n// TWRAppDelegate.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchwar"
},
{
"path": "TWRChartsDemo/ChartJS/TWRAppDelegate.m",
"chars": 2025,
"preview": "//\n// TWRAppDelegate.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchwar"
},
{
"path": "TWRChartsDemo/ChartJS/TWRBarChart.h",
"chars": 875,
"preview": "//\n// TWRBarChart.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 22/04/14.\n// Copyright (c) 2014 Touchware. "
},
{
"path": "TWRChartsDemo/ChartJS/TWRBarChart.m",
"chars": 529,
"preview": "//\n// TWRBarChart.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 22/04/14.\n// Copyright (c) 2014 Touchware. "
},
{
"path": "TWRChartsDemo/ChartJS/TWRChart.h",
"chars": 331,
"preview": "//\n// TWRChart.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 23/04/14.\n// Copyright (c) 2014 Touchware. All"
},
{
"path": "TWRChartsDemo/ChartJS/TWRChartBuilder.h",
"chars": 278,
"preview": "//\n// TWRChartBuilder.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchwa"
},
{
"path": "TWRChartsDemo/ChartJS/TWRChartBuilder.m",
"chars": 6543,
"preview": "//\n// TWRChartBuilder.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchwa"
},
{
"path": "TWRChartsDemo/ChartJS/TWRChartView.h",
"chars": 1877,
"preview": "//\n// TWRChartView.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware."
},
{
"path": "TWRChartsDemo/ChartJS/TWRChartView.m",
"chars": 5047,
"preview": "//\n// TWRChartView.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware."
},
{
"path": "TWRChartsDemo/ChartJS/TWRCircularChart.h",
"chars": 1230,
"preview": "//\n// TWRPieChart.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 22/04/14.\n// Copyright (c) 2014 Touchware. "
},
{
"path": "TWRChartsDemo/ChartJS/TWRCircularChart.m",
"chars": 613,
"preview": "//\n// TWRPieChart.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 22/04/14.\n// Copyright (c) 2014 Touchware. "
},
{
"path": "TWRChartsDemo/ChartJS/TWRDataSet+Strings.h",
"chars": 375,
"preview": "//\n// TWRDataSet+Strings.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 22/04/14.\n// Copyright (c) 2014 Touc"
},
{
"path": "TWRChartsDemo/ChartJS/TWRDataSet+Strings.m",
"chars": 2336,
"preview": "//\n// TWRDataSet+Strings.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 22/04/14.\n// Copyright (c) 2014 Touc"
},
{
"path": "TWRChartsDemo/ChartJS/TWRDataSet.h",
"chars": 2411,
"preview": "//\n// TWRDataSet.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware. A"
},
{
"path": "TWRChartsDemo/ChartJS/TWRDataSet.m",
"chars": 1814,
"preview": "//\n// TWRDataSet.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware. A"
},
{
"path": "TWRChartsDemo/ChartJS/TWRLineChart.h",
"chars": 1671,
"preview": "//\n// TWRLineChart.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware."
},
{
"path": "TWRChartsDemo/ChartJS/TWRLineChart.m",
"chars": 566,
"preview": "//\n// TWRLineChart.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware."
},
{
"path": "TWRChartsDemo/ChartJS/TWRViewController.h",
"chars": 230,
"preview": "//\n// TWRViewController.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touch"
},
{
"path": "TWRChartsDemo/ChartJS/TWRViewController.m",
"chars": 4673,
"preview": "//\n// TWRViewController.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touch"
},
{
"path": "TWRChartsDemo/ChartJS/UIColor+HexString.h",
"chars": 239,
"preview": "//\n// UIColor+HexString.h\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 23/04/14.\n// Copyright (c) 2014 Touch"
},
{
"path": "TWRChartsDemo/ChartJS/UIColor+HexString.m",
"chars": 554,
"preview": "//\n// UIColor+HexString.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 23/04/14.\n// Copyright (c) 2014 Touch"
},
{
"path": "TWRChartsDemo/ChartJS/en.lproj/InfoPlist.strings",
"chars": 45,
"preview": "/* Localized versions of Info.plist keys */\n\n"
},
{
"path": "TWRChartsDemo/ChartJS/index.js",
"chars": 490,
"preview": "var context = document.getElementById(\"canvas\").getContext(\"2d\");\n\nvar polarData = [\n {\n value : 30,\n c"
},
{
"path": "TWRChartsDemo/ChartJS/main.m",
"chars": 352,
"preview": "//\n// main.m\n// ChartJS\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touchware. All rig"
},
{
"path": "TWRChartsDemo/ChartJS.xcodeproj/project.pbxproj",
"chars": 27576,
"preview": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section *"
},
{
"path": "TWRChartsDemo/ChartJS.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
"chars": 152,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n version = \"1.0\">\n <FileRef\n location = \"self:ChartJS.xcodepr"
},
{
"path": "TWRChartsDemo/ChartJSTests/ChartJSTests-Info.plist",
"chars": 690,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "TWRChartsDemo/ChartJSTests/ChartJSTests.m",
"chars": 645,
"preview": "//\n// ChartJSTests.m\n// ChartJSTests\n//\n// Created by Michelangelo Chasseur on 21/04/14.\n// Copyright (c) 2014 Touch"
},
{
"path": "TWRChartsDemo/ChartJSTests/en.lproj/InfoPlist.strings",
"chars": 45,
"preview": "/* Localized versions of Info.plist keys */\n\n"
}
]
About this extraction
This page contains the full source code of the chasseurmic/TWRCharts GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 56 files (106.2 KB), approximately 31.3k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.