├── .DS_Store ├── WQPChartDemo ├── .DS_Store ├── ViewController.h ├── UIBezierPath+curved.h ├── AppDelegate.h ├── main.m ├── WQPChartLine.h ├── WQPChartBar.h ├── WQPChartAll.h ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── WQPChart.h ├── Info.plist ├── Base.lproj │ ├── Main.storyboard │ └── LaunchScreen.storyboard ├── ViewController.m ├── AppDelegate.m ├── UIBezierPath+curved.m ├── WQPChart.m ├── WQPChartBar.m ├── WQPChartLine.m └── WQPChartAll.m ├── WQPChartDemoTests ├── .DS_Store ├── Info.plist └── WQPChartDemoTests.m ├── WQPChartDemo.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── yunmai1.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── xcuserdata │ └── yunmai1.xcuserdatad │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── WQPChartDemo.xcscheme └── project.pbxproj ├── WQPChartDemoUITests ├── Info.plist └── WQPChartDemoUITests.m ├── README.md ├── .gitignore └── LICENSE /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dwarfWQP/WQPChartView/HEAD/.DS_Store -------------------------------------------------------------------------------- /WQPChartDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dwarfWQP/WQPChartView/HEAD/WQPChartDemo/.DS_Store -------------------------------------------------------------------------------- /WQPChartDemoTests/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dwarfWQP/WQPChartView/HEAD/WQPChartDemoTests/.DS_Store -------------------------------------------------------------------------------- /WQPChartDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WQPChartDemo.xcodeproj/project.xcworkspace/xcuserdata/yunmai1.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dwarfWQP/WQPChartView/HEAD/WQPChartDemo.xcodeproj/project.xcworkspace/xcuserdata/yunmai1.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /WQPChartDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // WQPChartDemo 4 | // 5 | // Created by yunmai1 on 16/5/30. 6 | // Copyright © 2016年 wqp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /WQPChartDemo/UIBezierPath+curved.h: -------------------------------------------------------------------------------- 1 | // 2 | // WChart.m 3 | // WChartView 4 | // 5 | // Created by wangsen on 15/12/24. 6 | // Copyright © 2015年 wangsen. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIBezierPath (curved) 12 | 13 | - (UIBezierPath*)smoothedPathWithGranularity:(NSInteger)granularity; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /WQPChartDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // WQPChartDemo 4 | // 5 | // Created by yunmai1 on 16/5/30. 6 | // Copyright © 2016年 wqp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /WQPChartDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // WQPChartDemo 4 | // 5 | // Created by yunmai1 on 16/5/30. 6 | // Copyright © 2016年 wqp. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WQPChartDemo/WQPChartLine.h: -------------------------------------------------------------------------------- 1 | // 2 | // WQPChartLine.h 3 | // 仿QQ侧滑栏 4 | // 5 | // Created by yunmai1 on 16/5/27. 6 | // Copyright © 2016年 wqp. All rights reserved. 7 | // 8 | 9 | #import 10 | static const CGFloat chartLineStartX = 50.f; 11 | static const CGFloat chartLineAxisSpanX = 50.f; 12 | static const CGFloat chartLineAxisSpanY = 50.f; 13 | @interface WQPChartLine : UIView 14 | @property (nonatomic, strong) NSArray * xValues; 15 | @property (nonatomic, strong) NSArray * yValues; 16 | @property (nonatomic, assign) CGFloat yMax; 17 | @property (nonatomic, assign) BOOL curve; 18 | 19 | - (void)startDrawLine; 20 | @end 21 | -------------------------------------------------------------------------------- /WQPChartDemo/WQPChartBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // WQPChartBar.h 3 | // 仿QQ侧滑栏 4 | // 5 | // Created by yunmai1 on 16/5/27. 6 | // Copyright © 2016年 wqp. All rights reserved. 7 | // 8 | 9 | #import 10 | static const CGFloat chartBarStartX = 50.f; 11 | static const CGFloat chartBarAxisSpanX = 50.f; 12 | static const CGFloat chartBarAxisSpanY = 50.f; 13 | @interface WQPChartBar : UIView 14 | @property (nonatomic, strong) NSArray * xValues; 15 | @property (nonatomic, strong) NSArray * yValues; 16 | 17 | @property (nonatomic, assign) CGFloat yMax; 18 | 19 | /** 20 | * @author WQP, 16-05-27 16:12 21 | * 22 | * 开始绘制图表 23 | */ 24 | - (void)startDrawBar; 25 | @end 26 | -------------------------------------------------------------------------------- /WQPChartDemo/WQPChartAll.h: -------------------------------------------------------------------------------- 1 | // 2 | // WQPChartAll.h 3 | // SNChartView 4 | // 5 | // Created by yunmai1 on 16/5/25. 6 | // Copyright © 2016年 wangsen. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | static const CGFloat chartAllStartX = 50.f;//起始位置 12 | static const CGFloat chartAllAxisSpanX = 50.f;//X轴跨度 13 | static const CGFloat chartAllAxisSpanY = 50.f;//Y轴跨度 14 | @interface WQPChartAll : UIView 15 | 16 | @property (nonatomic, strong) NSArray * xValues; 17 | @property (nonatomic, strong) NSArray * yValues; 18 | @property (nonatomic, assign) CGFloat yMax; 19 | @property (nonatomic, assign) BOOL curve;//曲线的判断标记 20 | 21 | - (void)startDrawBarAndLines; 22 | @end 23 | -------------------------------------------------------------------------------- /WQPChartDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /WQPChartDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /WQPChartDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /WQPChartDemo.xcodeproj/xcuserdata/yunmai1.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | WQPChartDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 7E7F5FA61CFBF270000A8FEE 16 | 17 | primary 18 | 19 | 20 | 7E7F5FBF1CFBF270000A8FEE 21 | 22 | primary 23 | 24 | 25 | 7E7F5FCA1CFBF270000A8FEE 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WQPChartView (建议线条采用直线) 2 | 这是基于SNChartView,自己进一步进行整合并且完善的quartz2D,即柱状折线图,希望大家支持. 3 | ======= 4 | #The premise 5 | 因为个人的项目需求是柱状和折线结合的图,所以就在SNChartView的基础上自己再封装了一个WQPChartAll类来满足需求. 6 | 7 | ##WQPChart 8 | 提供接口方法,也就是初始化化图形,选择Chartstyle,给Datasource赋值即可. 9 | - (NSMutableArray *)chatConfigYValue:(WQPChart *)chart;//Y轴的坐标赋值 10 | - (NSMutableArray *)chatConfigXValue:(WQPChart *)chart;//X轴的坐标赋值 11 | 12 | ##WQPChartAll 13 | 这个类提供了柱状折线为一体的功能.另外还附加了本人写的button,label,毕竟一张图,不可能就空空的放在那里.写的不会很复杂,小伙伴们可以根据 14 | 自己的需求进行增加. 15 | 16 | ##WQPChartBar 17 | 这个类只提供柱状图. 18 | 19 | ##WQPChartLine 20 | 这个类只提供折线图. 21 | 22 | ##Running effect 23 | ###WQPChartBar run effect 24 | ![](http://img0.ph.126.net/HMA-G1Wh-qX4DtDjBGoY5w==/6631705482442625997.jpeg) 25 | ###WQPChartAll run effect 26 | ![](http://img2.ph.126.net/kqoxFr6Ez1QeSSns6c84ZQ==/3757690939188040769.jpeg) 27 | ###WQPChartLine run effect 28 | ![](http://img0.ph.126.net/HMA-G1Wh-qX4DtDjBGoY5w==/6631705482442625997.jpeg) 29 | 30 | ##Thanks 31 | 在此感谢大家的支持. 32 | -------------------------------------------------------------------------------- /WQPChartDemo/WQPChart.h: -------------------------------------------------------------------------------- 1 | // 2 | // WQPChart.h 3 | // SNChartView 4 | // 5 | // Created by yunmai1 on 16/5/25. 6 | // Copyright © 2016年 wangsen. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class WQPChart; 12 | 13 | typedef NS_ENUM(NSInteger, WQPChartStyle){ 14 | WQPChartStyleAll = 0, 15 | WQPChartStyleline = 1, 16 | WQPChartStyleBar 17 | 18 | }; 19 | @protocol WQPChartDataSource 20 | 21 | @required 22 | 23 | //configuration y-axis 24 | - (NSMutableArray *)chatConfigYValue:(WQPChart *)chart; 25 | //configuration x-axis 26 | - (NSMutableArray *)chatConfigXValue:(WQPChart *)chart; 27 | 28 | @end 29 | 30 | @interface WQPChart : UIView 31 | /** 32 | * @author wqp, 16-05-25 17:20:30 33 | * 34 | * line 是否曲线 35 | */ 36 | @property (nonatomic, assign) BOOL curve; 37 | 38 | - (instancetype)initWithFrame:(CGRect)frame withDataSource:(id)dataSource andChatStyle:(WQPChartStyle)chartStyle; 39 | 40 | - (void)showInView:(UIView *)view; 41 | 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /WQPChartDemoTests/WQPChartDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WQPChartDemoTests.m 3 | // WQPChartDemoTests 4 | // 5 | // Created by yunmai1 on 16/5/30. 6 | // Copyright © 2016年 wqp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WQPChartDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WQPChartDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /WQPChartDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /WQPChartDemoUITests/WQPChartDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WQPChartDemoUITests.m 3 | // WQPChartDemoUITests 4 | // 5 | // Created by yunmai1 on 16/5/30. 6 | // Copyright © 2016年 wqp. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WQPChartDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WQPChartDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /WQPChartDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /WQPChartDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /WQPChartDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // WQPChartDemo 4 | // 5 | // Created by yunmai1 on 16/5/30. 6 | // Copyright © 2016年 wqp. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "WQPChart.h" 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | self.view.backgroundColor = [UIColor whiteColor]; 21 | //单个柱状图 22 | // WQPChart *chart = [[WQPChart alloc] initWithFrame:CGRectMake(0, 50, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 100) withDataSource:self andChatStyle:WQPChartStyleBar]; 23 | //单个折线图 24 | // WQPChart *chart = [[WQPChart alloc] initWithFrame:CGRectMake(0, 50, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 100) withDataSource:self andChatStyle:WQPChartStyleline]; 25 | //柱状折线图 26 | WQPChart *chart = [[WQPChart alloc] initWithFrame:CGRectMake(0, 50, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 100) withDataSource:self andChatStyle:WQPChartStyleAll]; 27 | chart.curve = YES; 28 | [chart showInView:self.view]; 29 | } 30 | 31 | - (NSMutableArray *)chatConfigYValue:(WQPChart *)chart { 32 | NSMutableArray *chartArray = [NSMutableArray arrayWithArray:@[@"2.1",@"3.4",@"1.7",@"2.5",@"1.5",@"2.8",@"3.0",@"2.8",@"2.3",@"1.0",@"3.6",@"1.7"]]; 33 | return chartArray; 34 | // return @[@"100",@"50",@"70",@"30",@"50",@"14",@"5",@"14",@"5",@"14"]; 35 | } 36 | 37 | - (NSMutableArray *)chatConfigXValue:(WQPChart *)chart { 38 | NSMutableArray *axisArr = [NSMutableArray arrayWithArray:@[@"10月",@"11月",@"12月",@"1月",@"2月",@"3月",@"4月",@"5月",@"6月",@"7月",@"8月",@"9月"]]; 39 | return axisArr; 40 | } 41 | 42 | - (void)didReceiveMemoryWarning { 43 | [super didReceiveMemoryWarning]; 44 | // Dispose of any resources that can be recreated. 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /WQPChartDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // WQPChartDemo 4 | // 5 | // Created by yunmai1 on 16/5/30. 6 | // Copyright © 2016年 wqp. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /WQPChartDemo/UIBezierPath+curved.m: -------------------------------------------------------------------------------- 1 | // 2 | // WChart.m 3 | // WChartView 4 | // 5 | // Created by wangsen on 15/12/24. 6 | // Copyright © 2015年 wangsen. All rights reserved. 7 | // 8 | 9 | #import "UIBezierPath+curved.h" 10 | 11 | // Based on code from Erica Sadun 12 | void getPointsFromBezier(void *info, const CGPathElement *element); 13 | NSArray *pointsFromBezierPath(UIBezierPath *bpath); 14 | 15 | static const CGFloat kChartLineMaxY = 300.f; //由线性图部分决定y值最大为300.f 16 | 17 | #define VALUE(_INDEX_) [NSValue valueWithCGPoint:points[_INDEX_]] 18 | #define POINT(_INDEX_) [(NSValue *)[points objectAtIndex:_INDEX_] CGPointValue] 19 | 20 | @implementation UIBezierPath (curved) 21 | 22 | // Get points from Bezier Curve 23 | void getPointsFromBezier(void *info, const CGPathElement *element) 24 | { 25 | NSMutableArray *bezierPoints = (__bridge NSMutableArray *)info; 26 | // Retrieve the path element type and its points 27 | CGPathElementType type = element->type; 28 | CGPoint *points = element->points; 29 | 30 | // Add the points if they're available (per type) 31 | if (type != kCGPathElementCloseSubpath) 32 | { 33 | [bezierPoints addObject:VALUE(0)]; 34 | if ((type != kCGPathElementAddLineToPoint) && 35 | (type != kCGPathElementMoveToPoint)) 36 | [bezierPoints addObject:VALUE(1)]; 37 | } 38 | if (type == kCGPathElementAddCurveToPoint) 39 | [bezierPoints addObject:VALUE(2)]; 40 | } 41 | 42 | NSArray *pointsFromBezierPath(UIBezierPath *bpath) 43 | { 44 | NSMutableArray *points = [NSMutableArray array]; 45 | CGPathApply(bpath.CGPath, (__bridge void *)points, getPointsFromBezier); 46 | return points; 47 | } 48 | 49 | - (UIBezierPath*)smoothedPathWithGranularity:(NSInteger)granularity; 50 | { 51 | NSMutableArray *points = [pointsFromBezierPath(self) mutableCopy]; 52 | if (points.count < 4) return [self copy]; 53 | 54 | // Add control points to make the math make sense 55 | [points insertObject:[points objectAtIndex:0] atIndex:0]; 56 | [points addObject:[points lastObject]]; 57 | 58 | UIBezierPath *smoothedPath = [self copy]; 59 | [smoothedPath removeAllPoints]; 60 | [smoothedPath moveToPoint:POINT(0)]; 61 | for (NSUInteger index = 1; index < points.count - 2; index++) 62 | { 63 | CGPoint p0 = POINT(index - 1); 64 | CGPoint p1 = POINT(index); 65 | CGPoint p2 = POINT(index + 1); 66 | CGPoint p3 = POINT(index + 2); 67 | // now add n points starting at p1 + dx/dy up until p2 using Catmull-Rom splines 68 | for (int i = 1; i < granularity; i++) 69 | { 70 | float t = (float) i * (1.0f / (float) granularity); 71 | float tt = t * t; 72 | float ttt = tt * t; 73 | 74 | CGPoint pi; // intermediate point 75 | pi.x = 0.5 * (2*p1.x+(p2.x-p0.x)*t + (2*p0.x-5*p1.x+4*p2.x-p3.x)*tt + (3*p1.x-p0.x-3*p2.x+p3.x)*ttt); 76 | pi.y = 0.5 * (2*p1.y+(p2.y-p0.y)*t + (2*p0.y-5*p1.y+4*p2.y-p3.y)*tt + (3*p1.y-p0.y-3*p2.y+p3.y)*ttt); 77 | if (pi.y > kChartLineMaxY) { 78 | pi.y = kChartLineMaxY; 79 | } 80 | [smoothedPath addLineToPoint:pi]; 81 | } 82 | 83 | // Now add p2 84 | [smoothedPath addLineToPoint:p2]; 85 | } 86 | 87 | // finish by adding the last point 88 | [smoothedPath addLineToPoint:POINT(points.count - 1)]; 89 | 90 | return smoothedPath; 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /WQPChartDemo.xcodeproj/xcuserdata/yunmai1.xcuserdatad/xcschemes/WQPChartDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /WQPChartDemo/WQPChart.m: -------------------------------------------------------------------------------- 1 | // 2 | // WQPChart.m 3 | // SNChartView 4 | // 5 | // Created by yunmai1 on 16/5/25. 6 | // Copyright © 2016年 wangsen. All rights reserved. 7 | // 8 | 9 | #import "WQPChart.h" 10 | #import "WQPChartAll.h" 11 | #import "WQPChartLine.h" 12 | #import "WQPChartBar.h" 13 | @interface WQPChart () 14 | @property (nonatomic, strong) UIView *MyView;//also set ScrollerView 15 | @property (nonatomic, assign) WQPChartStyle *chartStyle;//chart style 16 | @property (nonatomic, weak) iddataSource;//datasource 17 | @property (nonatomic, strong) WQPChartAll *chartAll; 18 | @property (nonatomic, strong) WQPChartLine *chartLine; 19 | @property (nonatomic, strong) WQPChartBar *chartBar; 20 | @property (nonatomic, strong) UIScrollView *ScrollView;//to line 21 | @end 22 | @implementation WQPChart 23 | 24 | - (instancetype)initWithFrame:(CGRect)frame withDataSource:(id)dataSource andChatStyle:(WQPChartStyle)chartStyle{ 25 | self = [super initWithFrame:frame]; 26 | if (self) { 27 | self.backgroundColor = [UIColor whiteColor]; 28 | self.dataSource = dataSource; 29 | self.chartStyle = (WQPChartStyle *)chartStyle; 30 | self.curve = NO; 31 | } 32 | return self; 33 | } 34 | 35 | - (void)startDraw{ 36 | if (_chartStyle == WQPChartStyleAll) { 37 | 38 | self.MyView.frame = self.bounds; 39 | self.chartAll = [[WQPChartAll alloc] initWithFrame:self.bounds]; 40 | [self.MyView addSubview:self.chartAll]; 41 | 42 | NSMutableArray * yArray = [NSMutableArray arrayWithArray:[self.dataSource chatConfigYValue:self]]; 43 | NSArray * xArray = [self.dataSource chatConfigXValue:self]; 44 | NSInteger count = xArray.count - yArray.count; 45 | if (count > 0) { 46 | 47 | for (NSInteger i = 0; i < count; i++) { 48 | [yArray addObject:@(0).stringValue]; 49 | 50 | } 51 | } 52 | 53 | //sort an array 54 | // NSArray * sourtArray = [yArray sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) { 55 | // 56 | // return [obj2 floatValue] > [obj1 floatValue]; 57 | // }]; 58 | 59 | self.chartAll.yMax = 5.1; 60 | self.chartAll.curve = self.curve; 61 | [self.chartAll setXValues:xArray]; 62 | [self.chartAll setYValues:yArray]; 63 | 64 | [self.chartAll startDrawBarAndLines]; 65 | 66 | CGRect frame = self.chartAll.frame; 67 | frame.size.width = xArray.count * chartAllAxisSpanX; 68 | self.chartAll.frame = frame; 69 | 70 | }else if(_chartStyle == (WQPChartStyle *)WQPChartStyleline){ 71 | 72 | self.ScrollView.frame = self.bounds; 73 | self.chartLine = [[WQPChartLine alloc] initWithFrame:self.bounds]; 74 | [self.ScrollView addSubview:self.chartLine]; 75 | 76 | NSMutableArray * yArray = [NSMutableArray arrayWithArray:[self.dataSource chatConfigYValue:self]]; 77 | NSArray * xArray = [self.dataSource chatConfigXValue:self]; 78 | NSInteger count = xArray.count - yArray.count; 79 | if (count > 0) { 80 | for (NSInteger i = 0; i < count; i++) { 81 | [yArray addObject:@(0).stringValue]; 82 | 83 | } 84 | } 85 | self.chartLine.yMax = 4.1; 86 | self.chartLine.curve = self.curve; 87 | [self.chartLine setXValues:xArray]; 88 | [self.chartLine setYValues:yArray]; 89 | [self.chartLine startDrawLine]; 90 | 91 | self.ScrollView.contentSize = CGSizeMake(chartLineAxisSpanX * xArray.count + chartLineStartX, 0); 92 | CGRect frame = self.chartLine.frame; 93 | frame.size.width = xArray.count * chartAllAxisSpanX; 94 | self.chartLine.frame = frame; 95 | 96 | } else { 97 | self.MyView.frame = self.bounds; 98 | self.chartBar = [[WQPChartBar alloc] initWithFrame:self.bounds]; 99 | [self.MyView addSubview:self.chartBar]; 100 | 101 | NSMutableArray * yArray = [NSMutableArray arrayWithArray:[self.dataSource chatConfigYValue:self]]; 102 | NSArray * xArray = [self.dataSource chatConfigXValue:self]; 103 | NSInteger count = xArray.count - yArray.count; 104 | if (count > 0) { 105 | 106 | for (NSInteger i = 0; i < count; i++) { 107 | [yArray addObject:@(0).stringValue]; 108 | 109 | } 110 | } 111 | 112 | self.chartBar.yMax = 5.1; 113 | [self.chartBar setXValues:xArray]; 114 | [self.chartBar setYValues:yArray]; 115 | [self.chartBar startDrawBar]; 116 | 117 | CGRect frame = self.chartBar.frame; 118 | frame.size.width = xArray.count * chartAllAxisSpanX; 119 | self.chartBar.frame = frame; 120 | } 121 | 122 | } 123 | 124 | - (void)showInView:(UIView *)view{ 125 | [self startDraw]; 126 | [view addSubview:self]; 127 | } 128 | 129 | - (UIView *)MyView { 130 | if (!_MyView) { 131 | _MyView = [[UIScrollView alloc] init]; 132 | [self addSubview:_MyView]; 133 | } 134 | return _MyView; 135 | } 136 | 137 | - (UIScrollView *)ScrollView { 138 | if (!_ScrollView) { 139 | _ScrollView = [[UIScrollView alloc] init]; 140 | [self addSubview:_ScrollView]; 141 | } 142 | return _ScrollView; 143 | } 144 | @end 145 | -------------------------------------------------------------------------------- /WQPChartDemo/WQPChartBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // WQPChartBar.m 3 | // 仿QQ侧滑栏 4 | // 5 | // Created by yunmai1 on 16/5/27. 6 | // Copyright © 2016年 wqp. All rights reserved. 7 | // 8 | 9 | #import "WQPChartBar.h" 10 | #import "UIBezierPath+curved.h" 11 | #define kBtnTag 1000 12 | #define kBarLineColor [UIColor colorWithRed:1.000f green:0.769f blue:0.000f alpha:1.00f] 13 | #define kCirCleColor [UIColor colorWithRed:0.859f green:0.871f blue:0.882f alpha:1.00f] 14 | #define kHVLineColor [UIColor colorWithRed:0.918f green:0.929f blue:0.949f alpha:1.00f] 15 | #define kBulldesFont [UIFont systemFontOfSize:10] 16 | 17 | static const NSInteger kYEqualPaths = 3;//y轴为3等份 18 | static const CGFloat kTopSpace = 50.f;//距离顶部y值 19 | static const CGFloat kBarWidth = 25.f;//柱状的宽度 20 | @interface WQPChartBar () 21 | @property (nonatomic, strong) CAShapeLayer * shapeLayer; 22 | @property (nonatomic, strong) NSMutableArray * pointXArray; 23 | @property (nonatomic, strong) NSMutableArray * pointYArray; 24 | @property (nonatomic, strong) NSMutableArray * points; 25 | 26 | @end 27 | 28 | @implementation WQPChartBar 29 | - (instancetype)initWithFrame:(CGRect)frame { 30 | self = [super initWithFrame:frame]; 31 | if (self) { 32 | self.backgroundColor = [UIColor whiteColor]; 33 | } 34 | return self; 35 | } 36 | 37 | - (NSMutableArray *)pointYArray { 38 | if (!_pointYArray) { 39 | _pointYArray = [NSMutableArray array]; 40 | } 41 | return _pointYArray; 42 | } 43 | 44 | - (NSMutableArray *)points { 45 | if (!_points) { 46 | _points = [NSMutableArray array]; 47 | } 48 | return _points; 49 | } 50 | 51 | - (NSMutableArray *)pointXArray { 52 | if (!_pointXArray) { 53 | _pointXArray = [NSMutableArray array]; 54 | } 55 | return _pointXArray; 56 | } 57 | 58 | - (void)setYMax:(CGFloat)yMax { 59 | _yMax = yMax; 60 | } 61 | 62 | - (void)setYValues:(NSArray *)yValues { 63 | _yValues = yValues; 64 | [self drawHorizontal]; 65 | } 66 | 67 | - (void)setXValues:(NSArray *)xValues { 68 | _xValues = xValues; 69 | // [self drawVertical]; 70 | } 71 | //x轴 72 | - (void)drawHorizontal{ 73 | UIBezierPath * path = [UIBezierPath bezierPath]; 74 | CAShapeLayer * shapeLayer = [CAShapeLayer layer]; 75 | for (NSInteger i = 0; i <= kYEqualPaths; i++) { 76 | [path moveToPoint:CGPointMake(30, chartBarAxisSpanY * i + kTopSpace)]; 77 | [path addLineToPoint:CGPointMake(chartBarStartX + (_xValues.count) * 50,chartBarAxisSpanY * i + kTopSpace)]; 78 | [path closePath]; 79 | shapeLayer.path = path.CGPath; 80 | shapeLayer.strokeColor = [UIColor lightGrayColor].CGColor; 81 | shapeLayer.fillColor = [[UIColor whiteColor] CGColor]; 82 | shapeLayer.lineWidth = 0.5f; 83 | [self.layer addSublayer:shapeLayer]; 84 | } 85 | } 86 | - (void)startDrawBar{ 87 | //设置X轴 88 | for(NSInteger i = 0; i < _xValues.count; i++){ 89 | [self.pointXArray addObject:@(chartBarStartX + chartBarAxisSpanX * i)]; 90 | } 91 | // //设置Y轴 92 | for(NSInteger i = 0; i < _yValues.count; i++){ 93 | [self.pointYArray addObject:@(chartBarAxisSpanY * kYEqualPaths - [_yValues[i] floatValue]/_yMax * chartBarAxisSpanY * kYEqualPaths + kTopSpace)]; 94 | } 95 | for (NSInteger i = 0; i < self.pointXArray.count; i++) { 96 | CGPoint point = CGPointMake([self.pointXArray[i] floatValue], [self.pointYArray[i] floatValue]); 97 | // NSValue * value = [NSValue valueWithBytes:&point objCType:@encode(CGPoint)]; 98 | NSValue * value = [NSValue valueWithCGPoint:point]; 99 | [self.points addObject:value]; 100 | } 101 | //画柱状 102 | _shapeLayer = [CAShapeLayer layer]; 103 | _shapeLayer.lineCap = kCALineCapButt;//线端点样式 104 | // _shapeLayer.lineJoin = kCALineJoinMiter;//线的连接点样式 105 | _shapeLayer.lineWidth = kBarWidth; 106 | _shapeLayer.fillColor = [UIColor clearColor].CGColor; 107 | _shapeLayer.strokeEnd = 0.f; 108 | _shapeLayer.strokeColor = kBarLineColor.CGColor; 109 | [self.layer addSublayer:_shapeLayer]; 110 | UIBezierPath * bezierBarLine = [UIBezierPath bezierPath]; 111 | for (NSInteger i = 0; i < self.points.count; i++) { 112 | CGPoint point = [self.points[i] CGPointValue]; 113 | 114 | [bezierBarLine moveToPoint:CGPointMake(point.x/1.55+kBarWidth/5, kTopSpace + kYEqualPaths * chartBarAxisSpanY)];//位置 115 | [bezierBarLine addLineToPoint:CGPointMake(point.x/1.55+kBarWidth/5, point.y)]; 116 | // [self addBatTitle:CGPointMake(point.x + kBarWidth/2 + 10, point.y) andIndex:i];//加柱状label 117 | [self addXLabel:point andIndex:i]; 118 | } 119 | [self addYLabel]; 120 | _shapeLayer.path = bezierBarLine.CGPath; 121 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; 122 | pathAnimation.duration = self.points.count * 0.5f; 123 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 124 | pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; 125 | pathAnimation.toValue = [NSNumber numberWithFloat:1.f]; 126 | pathAnimation.autoreverses = NO; 127 | [_shapeLayer addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; 128 | _shapeLayer.strokeEnd = 1.f; 129 | 130 | } 131 | //标记x轴label 以及标签 132 | - (void)addXLabel:(CGPoint)point andIndex:(NSInteger)index { 133 | UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, chartBarAxisSpanX, 20)]; 134 | label.center = CGPointMake(point.x/1.55+kBarWidth/5, chartBarAxisSpanY * kYEqualPaths + kTopSpace + 20); 135 | label.textColor = [UIColor lightGrayColor]; 136 | label.font = [UIFont systemFontOfSize:10.f]; 137 | label.textAlignment = NSTextAlignmentCenter; 138 | label.text = _xValues[index]; 139 | [self addSubview:label]; 140 | } 141 | 142 | - (void)addYLabel { 143 | for (NSInteger i = 0; i <= kYEqualPaths; i++) { 144 | UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(-20, chartBarAxisSpanY * i + kTopSpace, chartBarStartX - 5, 10)]; 145 | label.textColor = [UIColor lightGrayColor]; 146 | label.font = [UIFont systemFontOfSize:10.f]; 147 | label.textAlignment = NSTextAlignmentRight; 148 | [self addSubview:label]; 149 | if (i == kYEqualPaths) { 150 | label.text = @"0"; 151 | } else { 152 | NSLog(@"%f",_yMax); 153 | label.text = [NSString stringWithFormat:@"%.2f",_yMax - _yMax/3.f * i]; 154 | } 155 | } 156 | } 157 | 158 | 159 | /* 160 | // Only override drawRect: if you perform custom drawing. 161 | // An empty implementation adversely affects performance during animation. 162 | - (void)drawRect:(CGRect)rect { 163 | // Drawing code 164 | } 165 | */ 166 | 167 | @end 168 | -------------------------------------------------------------------------------- /WQPChartDemo/WQPChartLine.m: -------------------------------------------------------------------------------- 1 | // 2 | // WQPChartLine.m 3 | // 仿QQ侧滑栏 4 | // 5 | // Created by yunmai1 on 16/5/27. 6 | // Copyright © 2016年 wqp. All rights reserved. 7 | // 8 | 9 | #import "WQPChartLine.h" 10 | #import "UIBezierPath+curved.h" 11 | 12 | #define kBtnTag 1000 13 | 14 | static const NSInteger kYEqualPaths = 5;//y轴为4等份 15 | static const CGFloat kTopSpace = 50.f;//距离顶部y值 16 | 17 | @interface WQPChartLine () 18 | 19 | @property (nonatomic, strong) CAShapeLayer * shapeLineLayer; 20 | @property (nonatomic, strong) CAShapeLayer * shapeHeightLineLayer; 21 | @property (nonatomic, strong) CAShapeLayer * shapeTallestLineLayer; 22 | @property (nonatomic, strong) NSMutableArray * pointXArray; 23 | @property (nonatomic, strong) NSMutableArray * pointYArray; 24 | @property (nonatomic, strong) NSMutableArray * points; 25 | 26 | @end 27 | 28 | @implementation WQPChartLine 29 | - (instancetype)initWithFrame:(CGRect)frame { 30 | self = [super initWithFrame:frame]; 31 | if (self) { 32 | self.backgroundColor = [UIColor whiteColor]; 33 | self.curve = NO; 34 | } 35 | return self; 36 | } 37 | 38 | - (NSMutableArray *)pointYArray { 39 | if (!_pointYArray) { 40 | _pointYArray = [NSMutableArray array]; 41 | } 42 | return _pointYArray; 43 | } 44 | 45 | - (NSMutableArray *)points { 46 | if (!_points) { 47 | _points = [NSMutableArray array]; 48 | } 49 | return _points; 50 | } 51 | 52 | - (NSMutableArray *)pointXArray { 53 | if (!_pointXArray) { 54 | _pointXArray = [NSMutableArray array]; 55 | } 56 | return _pointXArray; 57 | } 58 | 59 | - (void)setYMax:(CGFloat)yMax { 60 | _yMax = yMax; 61 | } 62 | 63 | - (void)setCurve:(BOOL)curve { 64 | _curve = curve; 65 | } 66 | 67 | - (void)setYValues:(NSArray *)yValues { 68 | _yValues = yValues; 69 | [self drawHorizontal]; 70 | } 71 | 72 | - (void)setXValues:(NSArray *)xValues { 73 | _xValues = xValues; 74 | } 75 | 76 | - (void)drawHorizontal { 77 | UIBezierPath * path = [UIBezierPath bezierPath]; 78 | CAShapeLayer * shapeLayer = [CAShapeLayer layer]; 79 | for (NSInteger i = 0; i <= kYEqualPaths; i++) { 80 | 81 | [path moveToPoint:CGPointMake(30, chartLineAxisSpanY * i + kTopSpace)]; 82 | [path addLineToPoint:CGPointMake(chartLineStartX + (_xValues.count - 1) * 50, chartLineAxisSpanY * i + kTopSpace)]; 83 | [path closePath]; 84 | shapeLayer.path = path.CGPath; 85 | shapeLayer.strokeColor = [UIColor lightGrayColor].CGColor; 86 | shapeLayer.fillColor = [[UIColor whiteColor] CGColor]; 87 | shapeLayer.lineWidth = 0.3f; 88 | [self.layer addSublayer:shapeLayer]; 89 | } 90 | } 91 | 92 | - (void)startDrawLine { 93 | 94 | for(NSInteger i = 0; i < _xValues.count; i++){ 95 | [self.pointXArray addObject:@(chartLineStartX + chartLineAxisSpanX * i)]; 96 | } 97 | 98 | for(NSInteger i = 0; i < _yValues.count; i++){ 99 | [self.pointYArray addObject:@(chartLineAxisSpanY * kYEqualPaths - [_yValues[i] floatValue]/_yMax * chartLineAxisSpanY * kYEqualPaths + kTopSpace)]; 100 | } 101 | for (NSInteger i = 0; i < self.pointXArray.count; i++) { 102 | CGPoint point = CGPointMake([self.pointXArray[i] floatValue], [self.pointYArray[i] floatValue]); 103 | NSValue * value = [NSValue valueWithCGPoint:point]; 104 | [self.points addObject:value]; 105 | } 106 | //line one 107 | [self loadline:0 WithShapeLayer:_shapeLineLayer]; 108 | //line two 109 | [self loadline:-20 WithShapeLayer:_shapeHeightLineLayer]; 110 | //line three 111 | [self loadline:-70 WithShapeLayer:_shapeTallestLineLayer]; 112 | } 113 | //x-axis 114 | - (void)addXLabel:(CGPoint)point andIndex:(NSInteger)index { 115 | UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, chartLineAxisSpanX, 20)]; 116 | label.center = CGPointMake(point.x, chartLineAxisSpanY * kYEqualPaths + kTopSpace + 20); 117 | label.textColor = [UIColor lightGrayColor]; 118 | label.font = [UIFont systemFontOfSize:10.f]; 119 | label.textAlignment = NSTextAlignmentCenter; 120 | label.text = _xValues[index]; 121 | [self addSubview:label]; 122 | } 123 | 124 | //draw circle 125 | - (void)addCircle:(CGPoint)point andIndex:(NSInteger)index andStatus:(NSInteger)status{ 126 | 127 | UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom]; 128 | btn.frame = CGRectMake(0, 0, 10, 10); 129 | btn.center = point; 130 | [self addSubview:btn]; 131 | btn.tag = index + kBtnTag; 132 | if (status == 0) { 133 | btn.backgroundColor = [UIColor greenColor]; 134 | }else if(status == 1){ 135 | btn.backgroundColor = [UIColor redColor]; 136 | }else{ 137 | btn.backgroundColor = [UIColor blueColor]; 138 | } 139 | btn.layer.borderWidth = 3.f; 140 | btn.layer.borderColor = [UIColor colorWithRed:0.780f green:0.780f blue:0.804f alpha:0.5f].CGColor; 141 | btn.layer.cornerRadius = 7.5f; 142 | btn.layer.masksToBounds = YES; 143 | btn.enabled = NO; 144 | } 145 | 146 | - (void)loadline:(NSInteger)lineY WithShapeLayer:(CAShapeLayer *)ShapeLayer{ 147 | ShapeLayer = [CAShapeLayer layer]; 148 | ShapeLayer.lineCap = kCALineCapRound; 149 | ShapeLayer.lineJoin = kCALineJoinRound; 150 | ShapeLayer.lineWidth = 2.f; 151 | ShapeLayer.fillColor = [UIColor clearColor].CGColor; 152 | ShapeLayer.strokeEnd = 0.f; 153 | [self.layer addSublayer:ShapeLayer]; 154 | 155 | UIBezierPath * bezierLine = [UIBezierPath bezierPath]; 156 | for (NSInteger i = 0; i < self.points.count; i++) { 157 | CGPoint point = [self.points[i] CGPointValue]; 158 | if (i == 0) { 159 | [bezierLine moveToPoint:CGPointMake(point.x, point.y+lineY)]; 160 | } else { 161 | [bezierLine addLineToPoint:CGPointMake(point.x, point.y+lineY)]; 162 | } 163 | if (lineY == 0) { 164 | [self addCircle:CGPointMake(point.x, point.y+lineY) andIndex:i andStatus:0]; 165 | ShapeLayer.strokeColor = [UIColor greenColor].CGColor; 166 | } 167 | else if(lineY == -20){ 168 | [self addCircle:CGPointMake(point.x, point.y+lineY) andIndex:i andStatus:1]; 169 | ShapeLayer.strokeColor = [UIColor redColor].CGColor; 170 | 171 | }else{ 172 | [self addCircle:CGPointMake(point.x, point.y+lineY) andIndex:i andStatus:2]; 173 | ShapeLayer.strokeColor = [UIColor blueColor].CGColor; 174 | 175 | } 176 | [self addXLabel:point andIndex:i]; 177 | } 178 | [self addYLabel]; 179 | if (self.curve) { 180 | // bezierLine =[bezierLine smoothedPathWithGranularity:20];//设置曲线 181 | } 182 | ShapeLayer.path = bezierLine.CGPath; 183 | 184 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; 185 | pathAnimation.duration = self.points.count * 0.5f; 186 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 187 | pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; 188 | pathAnimation.toValue = [NSNumber numberWithFloat:1.f]; 189 | pathAnimation.autoreverses = NO; 190 | [ShapeLayer addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; 191 | ShapeLayer.strokeEnd = 1.f; 192 | 193 | } 194 | 195 | - (void)addYLabel { 196 | for (NSInteger i = 0; i <= kYEqualPaths; i++) { 197 | UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(-20, chartLineAxisSpanY * i + kTopSpace, chartLineStartX - 5, 10)]; 198 | label.textColor = [UIColor lightGrayColor]; 199 | label.font = [UIFont systemFontOfSize:10.f]; 200 | label.textAlignment = NSTextAlignmentRight; 201 | [self addSubview:label]; 202 | if (i == kYEqualPaths) { 203 | label.text = @"0"; 204 | } else { 205 | label.text = [NSString stringWithFormat:@"%.1f万",_yMax - _yMax/4.f * i]; 206 | } 207 | } 208 | } 209 | 210 | 211 | @end 212 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /WQPChartDemo/WQPChartAll.m: -------------------------------------------------------------------------------- 1 | // 2 | // WQPChartAll.m 3 | // SNChartView 4 | // 5 | // Created by yunmai1 on 16/5/25. 6 | // Copyright © 2016年 wangsen. All rights reserved. 7 | // 8 | 9 | #import "WQPChartAll.h" 10 | #import "UIBezierPath+curved.h" 11 | 12 | #define kBtnTag 1000 //should set big value 13 | 14 | static const NSInteger kYEqualPaths = 3;//y-axis is three equal 15 | static const CGFloat kTopSpace = 50.f;//distance at the top of the y value 16 | static const CGFloat kBarWidth = 25.f;//columnar width 17 | 18 | @interface WQPChartAll () 19 | @property (nonatomic, strong) CAShapeLayer * shapeBarLayer;//columnar 20 | @property (nonatomic, strong) CAShapeLayer * shapeLineLayer;//broken line 21 | @property (nonatomic, strong) CAShapeLayer * shapeHeightLineLayer; 22 | @property (nonatomic, strong) NSMutableArray * pointXArray; 23 | @property (nonatomic, strong) NSMutableArray * pointYArray; 24 | @property (nonatomic, strong) NSMutableArray * points; 25 | @property (nonatomic, strong) NSMutableArray *buttonArr; 26 | 27 | @end 28 | @implementation WQPChartAll 29 | 30 | //init 31 | - (instancetype)initWithFrame:(CGRect)frame{ 32 | self = [super initWithFrame:frame]; 33 | if(self){ 34 | self.backgroundColor = [UIColor whiteColor]; 35 | self.curve = NO; 36 | } 37 | return self; 38 | } 39 | 40 | //set methods 41 | - (void)setYMax:(CGFloat)yMax { 42 | _yMax = yMax; 43 | } 44 | 45 | - (void)setCurve:(BOOL)curve { 46 | _curve = curve; 47 | } 48 | 49 | - (void)setYValues:(NSArray *)yValues { 50 | _yValues = yValues; 51 | [self drawHorizontal]; 52 | } 53 | 54 | - (void)setXValues:(NSArray *)xValues { 55 | _xValues = xValues; 56 | } 57 | 58 | //drawHorizontal 59 | - (void)drawHorizontal{ 60 | UIBezierPath * path = [UIBezierPath bezierPath]; 61 | CAShapeLayer * shapeLayer = [CAShapeLayer layer]; 62 | 63 | for (NSInteger i = 0; i <= kYEqualPaths; i++) { 64 | [path moveToPoint:CGPointMake(30, chartAllAxisSpanY * i + kTopSpace)]; 65 | [path addLineToPoint:CGPointMake(_xValues.count * 50, chartAllAxisSpanY * i + kTopSpace)]; 66 | [path closePath]; 67 | shapeLayer.path = path.CGPath; 68 | shapeLayer.strokeColor = [UIColor lightGrayColor].CGColor; 69 | shapeLayer.fillColor = [[UIColor whiteColor] CGColor]; 70 | shapeLayer.lineWidth = 0.5f; 71 | [self.layer addSublayer:shapeLayer]; 72 | } 73 | 74 | } 75 | 76 | - (void)startDrawBarAndLines{ 77 | //set x-axis 78 | for(NSInteger i = 0; i < _xValues.count; i++){ 79 | [self.pointXArray addObject:@(chartAllStartX + chartAllAxisSpanX * i)]; 80 | } 81 | //set y-axis 82 | for(NSInteger i = 0; i < _yValues.count; i++){ 83 | [self.pointYArray addObject:@(chartAllAxisSpanY * kYEqualPaths - [_yValues[i] floatValue]/_yMax * chartAllAxisSpanY * kYEqualPaths + kTopSpace)]; 84 | } 85 | for (NSInteger i = 0; i < self.pointXArray.count; i++) { 86 | CGPoint point = CGPointMake([self.pointXArray[i] floatValue], [self.pointYArray[i] floatValue]); 87 | // NSValue * value = [NSValue valueWithBytes:&point objCType:@encode(CGPoint)]; 88 | NSValue * value = [NSValue valueWithCGPoint:point]; 89 | [self.points addObject:value]; 90 | } 91 | //draw columnar 92 | _shapeBarLayer = [CAShapeLayer layer]; 93 | _shapeBarLayer.lineCap = kCALineCapButt;//Line endpoint style 94 | _shapeBarLayer.lineWidth = kBarWidth; 95 | _shapeBarLayer.fillColor = [UIColor clearColor].CGColor; 96 | _shapeBarLayer.strokeEnd = 0.f; 97 | _shapeBarLayer.strokeColor = [UIColor blueColor].CGColor; 98 | [self.layer addSublayer:_shapeBarLayer]; 99 | UIBezierPath * bezierBarLine = [UIBezierPath bezierPath]; 100 | for (NSInteger i = 0; i < self.points.count; i++) { 101 | CGPoint point = [self.points[i] CGPointValue]; 102 | 103 | [bezierBarLine moveToPoint:CGPointMake(point.x/1.55+kBarWidth/5, kTopSpace + kYEqualPaths * chartAllAxisSpanY)];//postion 104 | [bezierBarLine addLineToPoint:CGPointMake(point.x/1.55+kBarWidth/5, point.y)]; 105 | // [self addBatTitle:CGPointMake(point.x + kBarWidth/2 + 10, point.y) andIndex:i];//add columnar label 106 | [self addXLabel:point andIndex:i]; 107 | } 108 | _shapeBarLayer.path = bezierBarLine.CGPath; 109 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; 110 | pathAnimation.duration = self.points.count * 0.5f; 111 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 112 | pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; 113 | pathAnimation.toValue = [NSNumber numberWithFloat:1.f]; 114 | pathAnimation.autoreverses = NO; 115 | [_shapeBarLayer addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; 116 | _shapeBarLayer.strokeEnd = 1.f; 117 | //add button 118 | [self CreateButton]; 119 | //line one 120 | [self loadline:0 WithShapeLayer:_shapeLineLayer]; 121 | //line two 122 | [self loadline:-10 WithShapeLayer:_shapeHeightLineLayer]; 123 | //add label 124 | [self CreateLabel]; 125 | 126 | } 127 | 128 | #pragma mark - multiple lines 129 | - (void)loadline:(NSInteger)lineY WithShapeLayer:(CAShapeLayer *)ShapeLayer{ 130 | ShapeLayer = [CAShapeLayer layer]; 131 | ShapeLayer.lineCap = kCALineCapRound; 132 | ShapeLayer.lineJoin = kCALineJoinRound; 133 | ShapeLayer.lineWidth = 2.f; 134 | ShapeLayer.fillColor = [UIColor clearColor].CGColor; 135 | ShapeLayer.strokeEnd = 0.f; 136 | [self.layer addSublayer:ShapeLayer]; 137 | //draw content of chart 138 | UIBezierPath * bezierLine = [UIBezierPath bezierPath]; 139 | for (NSInteger i = 0; i < self.points.count; i++) { 140 | CGPoint point = [self.points[i] CGPointValue]; 141 | if (i == 0) { 142 | //point 143 | [bezierLine moveToPoint:CGPointMake(point.x/1.55+kBarWidth/5, point.y+lineY)]; 144 | 145 | } else { 146 | //attachment 147 | [bezierLine addLineToPoint:CGPointMake(point.x/1.55+kBarWidth/5, point.y+lineY)]; 148 | } 149 | //There are two types of round 150 | if (lineY == 0) { 151 | [self addCircle:CGPointMake(point.x/1.55+kBarWidth/5, point.y+lineY) andIndex:i andStatus:0]; 152 | ShapeLayer.strokeColor = [UIColor redColor].CGColor; 153 | } 154 | else{ 155 | [self addCircle:CGPointMake(point.x/1.55+kBarWidth/5, point.y+lineY) andIndex:i andStatus:1]; 156 | ShapeLayer.strokeColor = [UIColor orangeColor].CGColor; 157 | } 158 | } 159 | [self addYLabel]; 160 | 161 | //sets the curve 162 | if (self.curve) { 163 | bezierLine =[bezierLine smoothedPathWithGranularity:20]; 164 | } 165 | //Graphics trajectory 166 | ShapeLayer.path = bezierLine.CGPath; 167 | //shape animation PS:In the last period of time,animation from fromValue to toValue 168 | //you can reference http://blog.sina.com.cn/s/blog_51a995b70102vdfe.html 169 | CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; 170 | pathAnimation.duration = self.points.count * 0.5f;//runtime 171 | pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 172 | pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];//keyPath start value 173 | pathAnimation.toValue = [NSNumber numberWithFloat:1.f];//keyPath end value 174 | pathAnimation.autoreverses = NO; 175 | [ShapeLayer addAnimation:pathAnimation forKey:@"strokeEndAnimation"]; 176 | ShapeLayer.strokeEnd = 1.f; 177 | } 178 | #pragma mark - divide y-axis 179 | - (void)addYLabel { 180 | for (NSInteger i = 0; i <= kYEqualPaths; i++) { 181 | UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(-20, chartAllAxisSpanY * i + kTopSpace, chartAllStartX - 5, 10)]; 182 | label.textColor = [UIColor lightGrayColor]; 183 | label.font = [UIFont systemFontOfSize:10.f]; 184 | label.textAlignment = NSTextAlignmentRight; 185 | [self addSubview:label]; 186 | if (i == kYEqualPaths) { 187 | label.text = @"0"; 188 | } else { 189 | label.text = [NSString stringWithFormat:@"%.1f万",_yMax - _yMax/3.f * i]; 190 | } 191 | } 192 | } 193 | 194 | #pragma mark - draw circle 195 | - (void)addCircle:(CGPoint)point andIndex:(NSInteger)index andStatus:(NSInteger)status{ 196 | 197 | UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom]; 198 | btn.frame = CGRectMake(0, 0, 10, 10); 199 | btn.center = point; 200 | [self addSubview:btn]; 201 | btn.tag = index + kBtnTag; 202 | if (status == 0) { 203 | btn.backgroundColor = [UIColor redColor]; 204 | }else{ 205 | btn.backgroundColor = [UIColor orangeColor]; 206 | } 207 | //button style 208 | btn.layer.borderWidth = 3.f; 209 | btn.layer.borderColor = [UIColor colorWithRed:0.780f green:0.780f blue:0.804f alpha:0.5f].CGColor; 210 | btn.layer.cornerRadius = 7.5f; 211 | btn.layer.masksToBounds = YES; 212 | btn.enabled = NO; 213 | } 214 | 215 | #pragma mark - the x-axis for the assignment 216 | - (void)addXLabel:(CGPoint)point andIndex:(NSInteger)index { 217 | UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, chartAllAxisSpanX, 20)]; 218 | label.center = CGPointMake(point.x/1.55+kBarWidth/5, chartAllAxisSpanY * kYEqualPaths + kTopSpace + 20); 219 | label.textColor = [UIColor lightGrayColor]; 220 | label.font = [UIFont systemFontOfSize:10.f]; 221 | label.textAlignment = NSTextAlignmentCenter; 222 | label.text = _xValues[index]; 223 | [self addSubview:label]; 224 | } 225 | 226 | #pragma mark - create label PS:chart labels 227 | - (void)CreateLabel{ 228 | //圆点1 229 | UILabel * cirlabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; 230 | cirlabel.center = CGPointMake(25, chartAllAxisSpanY * kYEqualPaths + kTopSpace + 50); 231 | cirlabel.backgroundColor = [UIColor orangeColor]; 232 | cirlabel.layer.masksToBounds = YES; 233 | cirlabel.layer.cornerRadius = 6.f; 234 | [self addSubview:cirlabel]; 235 | 236 | UILabel * marklabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 20)]; 237 | marklabel.center = CGPointMake(75, chartAllAxisSpanY * kYEqualPaths + kTopSpace + 50); 238 | marklabel.text = @"参考均价"; 239 | marklabel.textColor = [UIColor blackColor]; 240 | [self addSubview:marklabel]; 241 | //圆点2 242 | UILabel * cirlabel2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; 243 | cirlabel2.center = CGPointMake(CGRectGetMaxX(marklabel.frame)+10, chartAllAxisSpanY * kYEqualPaths + kTopSpace + 50); 244 | cirlabel2.backgroundColor = [UIColor redColor]; 245 | cirlabel2.layer.masksToBounds = YES; 246 | cirlabel2.layer.cornerRadius = 6.f; 247 | [self addSubview:cirlabel2]; 248 | 249 | UILabel * marklabel2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 20)]; 250 | marklabel2.center = CGPointMake(CGRectGetMaxX(cirlabel2.frame)+45, chartAllAxisSpanY * kYEqualPaths + kTopSpace + 50); 251 | marklabel2.text = @"挂牌均价"; 252 | marklabel2.textColor = [UIColor blackColor]; 253 | [self addSubview:marklabel2]; 254 | 255 | //圆点3 256 | UILabel * cirlabel3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; 257 | cirlabel3.center = CGPointMake(CGRectGetMaxX(marklabel2.frame)+10, chartAllAxisSpanY * kYEqualPaths + kTopSpace + 50); 258 | cirlabel3.backgroundColor = [UIColor blueColor]; 259 | cirlabel3.layer.masksToBounds = YES; 260 | cirlabel3.layer.cornerRadius = 6.f; 261 | [self addSubview:cirlabel3]; 262 | 263 | UILabel * marklabel3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 20)]; 264 | marklabel3.center = CGPointMake(CGRectGetMaxX(cirlabel3.frame)+45, chartAllAxisSpanY * kYEqualPaths + kTopSpace + 50); 265 | marklabel3.text = @"成交量/套"; 266 | marklabel3.textColor = [UIColor blackColor]; 267 | [self addSubview:marklabel3]; 268 | } 269 | 270 | #pragma mark - create chart button 271 | - (void)CreateButton{ 272 | NSMutableArray *title = [NSMutableArray arrayWithObjects:@"全部",@"一居",@"两居",@"三居",nil]; 273 | _buttonArr = [NSMutableArray array]; 274 | for (int i = 0; i < 4; i++) { 275 | UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 65, 25)]; 276 | button.center = CGPointMake(60 + 100 * i, kTopSpace - 25);//顶部button 277 | button.tag = i + 100; 278 | button.layer.cornerRadius = 5.0f; 279 | button.layer.borderColor = [UIColor whiteColor].CGColor; 280 | button.layer.borderWidth = 1.f; 281 | [button setTitle:[title objectAtIndex:i] forState:UIControlStateNormal]; 282 | [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 283 | button.titleLabel.backgroundColor = [UIColor clearColor]; 284 | if (button.tag == 100) { 285 | button.backgroundColor = [UIColor orangeColor]; 286 | } 287 | else{ 288 | button.backgroundColor = [UIColor whiteColor]; 289 | } 290 | [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside]; 291 | button.layer.masksToBounds = YES; 292 | [self addSubview:button]; 293 | [_buttonArr addObject:button]; 294 | } 295 | 296 | } 297 | //click on the button to change button background 298 | - (void)buttonClick:(UIButton *)btn{ 299 | 300 | for (UIButton *button in _buttonArr){ 301 | 302 | if (button.tag == btn.tag) { 303 | 304 | button.backgroundColor =[UIColor orangeColor]; 305 | 306 | } else { 307 | 308 | button.backgroundColor =[UIColor whiteColor]; 309 | 310 | } 311 | 312 | } 313 | 314 | } 315 | 316 | #pragma mark - histogram title PS:numbers 317 | - (void)addBatTitle:(CGPoint)point andIndex:(NSInteger)index { 318 | UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kBarWidth, 10)]; 319 | label.center = CGPointMake(point.x, point.y - 10.f); 320 | label.font = [UIFont systemFontOfSize:10.f]; 321 | label.text = _yValues[index]; 322 | label.textAlignment = NSTextAlignmentCenter; 323 | label.textColor = [UIColor blueColor];//这个改柱状label的颜色 324 | [self addSubview:label]; 325 | } 326 | #pragma mark - lazy load 327 | - (NSMutableArray *)pointYArray { 328 | if (!_pointYArray) { 329 | _pointYArray = [NSMutableArray array]; 330 | } 331 | return _pointYArray; 332 | } 333 | 334 | - (NSMutableArray *)points { 335 | if (!_points) { 336 | _points = [NSMutableArray array]; 337 | } 338 | return _points; 339 | } 340 | 341 | - (NSMutableArray *)pointXArray { 342 | if (!_pointXArray) { 343 | _pointXArray = [NSMutableArray array]; 344 | } 345 | return _pointXArray; 346 | } 347 | 348 | @end 349 | -------------------------------------------------------------------------------- /WQPChartDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 7E7F5FAC1CFBF270000A8FEE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7F5FAB1CFBF270000A8FEE /* main.m */; }; 11 | 7E7F5FAF1CFBF270000A8FEE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7F5FAE1CFBF270000A8FEE /* AppDelegate.m */; }; 12 | 7E7F5FB21CFBF270000A8FEE /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7F5FB11CFBF270000A8FEE /* ViewController.m */; }; 13 | 7E7F5FB51CFBF270000A8FEE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E7F5FB31CFBF270000A8FEE /* Main.storyboard */; }; 14 | 7E7F5FB71CFBF270000A8FEE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7E7F5FB61CFBF270000A8FEE /* Assets.xcassets */; }; 15 | 7E7F5FBA1CFBF270000A8FEE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E7F5FB81CFBF270000A8FEE /* LaunchScreen.storyboard */; }; 16 | 7E7F5FC51CFBF270000A8FEE /* WQPChartDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7F5FC41CFBF270000A8FEE /* WQPChartDemoTests.m */; }; 17 | 7E7F5FD01CFBF270000A8FEE /* WQPChartDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7F5FCF1CFBF270000A8FEE /* WQPChartDemoUITests.m */; }; 18 | 7E7F5FE81CFBF2E2000A8FEE /* UIBezierPath+curved.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7F5FDF1CFBF2E2000A8FEE /* UIBezierPath+curved.m */; }; 19 | 7E7F5FE91CFBF2E2000A8FEE /* WQPChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7F5FE11CFBF2E2000A8FEE /* WQPChart.m */; }; 20 | 7E7F5FEA1CFBF2E2000A8FEE /* WQPChartAll.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7F5FE31CFBF2E2000A8FEE /* WQPChartAll.m */; }; 21 | 7E7F5FEB1CFBF2E2000A8FEE /* WQPChartBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7F5FE51CFBF2E2000A8FEE /* WQPChartBar.m */; }; 22 | 7E7F5FEC1CFBF2E2000A8FEE /* WQPChartLine.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7F5FE71CFBF2E2000A8FEE /* WQPChartLine.m */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXContainerItemProxy section */ 26 | 7E7F5FC11CFBF270000A8FEE /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = 7E7F5F9F1CFBF270000A8FEE /* Project object */; 29 | proxyType = 1; 30 | remoteGlobalIDString = 7E7F5FA61CFBF270000A8FEE; 31 | remoteInfo = WQPChartDemo; 32 | }; 33 | 7E7F5FCC1CFBF270000A8FEE /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = 7E7F5F9F1CFBF270000A8FEE /* Project object */; 36 | proxyType = 1; 37 | remoteGlobalIDString = 7E7F5FA61CFBF270000A8FEE; 38 | remoteInfo = WQPChartDemo; 39 | }; 40 | /* End PBXContainerItemProxy section */ 41 | 42 | /* Begin PBXFileReference section */ 43 | 7E7F5FA71CFBF270000A8FEE /* WQPChartDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WQPChartDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 7E7F5FAB1CFBF270000A8FEE /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 45 | 7E7F5FAD1CFBF270000A8FEE /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 46 | 7E7F5FAE1CFBF270000A8FEE /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 47 | 7E7F5FB01CFBF270000A8FEE /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 48 | 7E7F5FB11CFBF270000A8FEE /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 49 | 7E7F5FB41CFBF270000A8FEE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 50 | 7E7F5FB61CFBF270000A8FEE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 51 | 7E7F5FB91CFBF270000A8FEE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 52 | 7E7F5FBB1CFBF270000A8FEE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | 7E7F5FC01CFBF270000A8FEE /* WQPChartDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WQPChartDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 7E7F5FC41CFBF270000A8FEE /* WQPChartDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WQPChartDemoTests.m; sourceTree = ""; }; 55 | 7E7F5FC61CFBF270000A8FEE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | 7E7F5FCB1CFBF270000A8FEE /* WQPChartDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WQPChartDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | 7E7F5FCF1CFBF270000A8FEE /* WQPChartDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WQPChartDemoUITests.m; sourceTree = ""; }; 58 | 7E7F5FD11CFBF270000A8FEE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | 7E7F5FDE1CFBF2E2000A8FEE /* UIBezierPath+curved.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIBezierPath+curved.h"; sourceTree = ""; }; 60 | 7E7F5FDF1CFBF2E2000A8FEE /* UIBezierPath+curved.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIBezierPath+curved.m"; sourceTree = ""; }; 61 | 7E7F5FE01CFBF2E2000A8FEE /* WQPChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WQPChart.h; sourceTree = ""; }; 62 | 7E7F5FE11CFBF2E2000A8FEE /* WQPChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WQPChart.m; sourceTree = ""; }; 63 | 7E7F5FE21CFBF2E2000A8FEE /* WQPChartAll.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WQPChartAll.h; sourceTree = ""; }; 64 | 7E7F5FE31CFBF2E2000A8FEE /* WQPChartAll.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WQPChartAll.m; sourceTree = ""; }; 65 | 7E7F5FE41CFBF2E2000A8FEE /* WQPChartBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WQPChartBar.h; sourceTree = ""; }; 66 | 7E7F5FE51CFBF2E2000A8FEE /* WQPChartBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WQPChartBar.m; sourceTree = ""; }; 67 | 7E7F5FE61CFBF2E2000A8FEE /* WQPChartLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WQPChartLine.h; sourceTree = ""; }; 68 | 7E7F5FE71CFBF2E2000A8FEE /* WQPChartLine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WQPChartLine.m; sourceTree = ""; }; 69 | /* End PBXFileReference section */ 70 | 71 | /* Begin PBXFrameworksBuildPhase section */ 72 | 7E7F5FA41CFBF270000A8FEE /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | 7E7F5FBD1CFBF270000A8FEE /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | ); 84 | runOnlyForDeploymentPostprocessing = 0; 85 | }; 86 | 7E7F5FC81CFBF270000A8FEE /* Frameworks */ = { 87 | isa = PBXFrameworksBuildPhase; 88 | buildActionMask = 2147483647; 89 | files = ( 90 | ); 91 | runOnlyForDeploymentPostprocessing = 0; 92 | }; 93 | /* End PBXFrameworksBuildPhase section */ 94 | 95 | /* Begin PBXGroup section */ 96 | 7E7F5F9E1CFBF270000A8FEE = { 97 | isa = PBXGroup; 98 | children = ( 99 | 7E7F5FA91CFBF270000A8FEE /* WQPChartDemo */, 100 | 7E7F5FC31CFBF270000A8FEE /* WQPChartDemoTests */, 101 | 7E7F5FCE1CFBF270000A8FEE /* WQPChartDemoUITests */, 102 | 7E7F5FA81CFBF270000A8FEE /* Products */, 103 | ); 104 | sourceTree = ""; 105 | }; 106 | 7E7F5FA81CFBF270000A8FEE /* Products */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 7E7F5FA71CFBF270000A8FEE /* WQPChartDemo.app */, 110 | 7E7F5FC01CFBF270000A8FEE /* WQPChartDemoTests.xctest */, 111 | 7E7F5FCB1CFBF270000A8FEE /* WQPChartDemoUITests.xctest */, 112 | ); 113 | name = Products; 114 | sourceTree = ""; 115 | }; 116 | 7E7F5FA91CFBF270000A8FEE /* WQPChartDemo */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 7E7F5FDD1CFBF2BD000A8FEE /* WQPChartView */, 120 | 7E7F5FAD1CFBF270000A8FEE /* AppDelegate.h */, 121 | 7E7F5FAE1CFBF270000A8FEE /* AppDelegate.m */, 122 | 7E7F5FB01CFBF270000A8FEE /* ViewController.h */, 123 | 7E7F5FB11CFBF270000A8FEE /* ViewController.m */, 124 | 7E7F5FB31CFBF270000A8FEE /* Main.storyboard */, 125 | 7E7F5FB61CFBF270000A8FEE /* Assets.xcassets */, 126 | 7E7F5FB81CFBF270000A8FEE /* LaunchScreen.storyboard */, 127 | 7E7F5FBB1CFBF270000A8FEE /* Info.plist */, 128 | 7E7F5FAA1CFBF270000A8FEE /* Supporting Files */, 129 | ); 130 | path = WQPChartDemo; 131 | sourceTree = ""; 132 | }; 133 | 7E7F5FAA1CFBF270000A8FEE /* Supporting Files */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 7E7F5FAB1CFBF270000A8FEE /* main.m */, 137 | ); 138 | name = "Supporting Files"; 139 | sourceTree = ""; 140 | }; 141 | 7E7F5FC31CFBF270000A8FEE /* WQPChartDemoTests */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 7E7F5FC41CFBF270000A8FEE /* WQPChartDemoTests.m */, 145 | 7E7F5FC61CFBF270000A8FEE /* Info.plist */, 146 | ); 147 | path = WQPChartDemoTests; 148 | sourceTree = ""; 149 | }; 150 | 7E7F5FCE1CFBF270000A8FEE /* WQPChartDemoUITests */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 7E7F5FCF1CFBF270000A8FEE /* WQPChartDemoUITests.m */, 154 | 7E7F5FD11CFBF270000A8FEE /* Info.plist */, 155 | ); 156 | path = WQPChartDemoUITests; 157 | sourceTree = ""; 158 | }; 159 | 7E7F5FDD1CFBF2BD000A8FEE /* WQPChartView */ = { 160 | isa = PBXGroup; 161 | children = ( 162 | 7E7F5FDE1CFBF2E2000A8FEE /* UIBezierPath+curved.h */, 163 | 7E7F5FDF1CFBF2E2000A8FEE /* UIBezierPath+curved.m */, 164 | 7E7F5FE01CFBF2E2000A8FEE /* WQPChart.h */, 165 | 7E7F5FE11CFBF2E2000A8FEE /* WQPChart.m */, 166 | 7E7F5FE21CFBF2E2000A8FEE /* WQPChartAll.h */, 167 | 7E7F5FE31CFBF2E2000A8FEE /* WQPChartAll.m */, 168 | 7E7F5FE41CFBF2E2000A8FEE /* WQPChartBar.h */, 169 | 7E7F5FE51CFBF2E2000A8FEE /* WQPChartBar.m */, 170 | 7E7F5FE61CFBF2E2000A8FEE /* WQPChartLine.h */, 171 | 7E7F5FE71CFBF2E2000A8FEE /* WQPChartLine.m */, 172 | ); 173 | name = WQPChartView; 174 | sourceTree = ""; 175 | }; 176 | /* End PBXGroup section */ 177 | 178 | /* Begin PBXNativeTarget section */ 179 | 7E7F5FA61CFBF270000A8FEE /* WQPChartDemo */ = { 180 | isa = PBXNativeTarget; 181 | buildConfigurationList = 7E7F5FD41CFBF270000A8FEE /* Build configuration list for PBXNativeTarget "WQPChartDemo" */; 182 | buildPhases = ( 183 | 7E7F5FA31CFBF270000A8FEE /* Sources */, 184 | 7E7F5FA41CFBF270000A8FEE /* Frameworks */, 185 | 7E7F5FA51CFBF270000A8FEE /* Resources */, 186 | ); 187 | buildRules = ( 188 | ); 189 | dependencies = ( 190 | ); 191 | name = WQPChartDemo; 192 | productName = WQPChartDemo; 193 | productReference = 7E7F5FA71CFBF270000A8FEE /* WQPChartDemo.app */; 194 | productType = "com.apple.product-type.application"; 195 | }; 196 | 7E7F5FBF1CFBF270000A8FEE /* WQPChartDemoTests */ = { 197 | isa = PBXNativeTarget; 198 | buildConfigurationList = 7E7F5FD71CFBF270000A8FEE /* Build configuration list for PBXNativeTarget "WQPChartDemoTests" */; 199 | buildPhases = ( 200 | 7E7F5FBC1CFBF270000A8FEE /* Sources */, 201 | 7E7F5FBD1CFBF270000A8FEE /* Frameworks */, 202 | 7E7F5FBE1CFBF270000A8FEE /* Resources */, 203 | ); 204 | buildRules = ( 205 | ); 206 | dependencies = ( 207 | 7E7F5FC21CFBF270000A8FEE /* PBXTargetDependency */, 208 | ); 209 | name = WQPChartDemoTests; 210 | productName = WQPChartDemoTests; 211 | productReference = 7E7F5FC01CFBF270000A8FEE /* WQPChartDemoTests.xctest */; 212 | productType = "com.apple.product-type.bundle.unit-test"; 213 | }; 214 | 7E7F5FCA1CFBF270000A8FEE /* WQPChartDemoUITests */ = { 215 | isa = PBXNativeTarget; 216 | buildConfigurationList = 7E7F5FDA1CFBF270000A8FEE /* Build configuration list for PBXNativeTarget "WQPChartDemoUITests" */; 217 | buildPhases = ( 218 | 7E7F5FC71CFBF270000A8FEE /* Sources */, 219 | 7E7F5FC81CFBF270000A8FEE /* Frameworks */, 220 | 7E7F5FC91CFBF270000A8FEE /* Resources */, 221 | ); 222 | buildRules = ( 223 | ); 224 | dependencies = ( 225 | 7E7F5FCD1CFBF270000A8FEE /* PBXTargetDependency */, 226 | ); 227 | name = WQPChartDemoUITests; 228 | productName = WQPChartDemoUITests; 229 | productReference = 7E7F5FCB1CFBF270000A8FEE /* WQPChartDemoUITests.xctest */; 230 | productType = "com.apple.product-type.bundle.ui-testing"; 231 | }; 232 | /* End PBXNativeTarget section */ 233 | 234 | /* Begin PBXProject section */ 235 | 7E7F5F9F1CFBF270000A8FEE /* Project object */ = { 236 | isa = PBXProject; 237 | attributes = { 238 | LastUpgradeCheck = 0720; 239 | ORGANIZATIONNAME = wqp; 240 | TargetAttributes = { 241 | 7E7F5FA61CFBF270000A8FEE = { 242 | CreatedOnToolsVersion = 7.2.1; 243 | }; 244 | 7E7F5FBF1CFBF270000A8FEE = { 245 | CreatedOnToolsVersion = 7.2.1; 246 | TestTargetID = 7E7F5FA61CFBF270000A8FEE; 247 | }; 248 | 7E7F5FCA1CFBF270000A8FEE = { 249 | CreatedOnToolsVersion = 7.2.1; 250 | TestTargetID = 7E7F5FA61CFBF270000A8FEE; 251 | }; 252 | }; 253 | }; 254 | buildConfigurationList = 7E7F5FA21CFBF270000A8FEE /* Build configuration list for PBXProject "WQPChartDemo" */; 255 | compatibilityVersion = "Xcode 3.2"; 256 | developmentRegion = English; 257 | hasScannedForEncodings = 0; 258 | knownRegions = ( 259 | en, 260 | Base, 261 | ); 262 | mainGroup = 7E7F5F9E1CFBF270000A8FEE; 263 | productRefGroup = 7E7F5FA81CFBF270000A8FEE /* Products */; 264 | projectDirPath = ""; 265 | projectRoot = ""; 266 | targets = ( 267 | 7E7F5FA61CFBF270000A8FEE /* WQPChartDemo */, 268 | 7E7F5FBF1CFBF270000A8FEE /* WQPChartDemoTests */, 269 | 7E7F5FCA1CFBF270000A8FEE /* WQPChartDemoUITests */, 270 | ); 271 | }; 272 | /* End PBXProject section */ 273 | 274 | /* Begin PBXResourcesBuildPhase section */ 275 | 7E7F5FA51CFBF270000A8FEE /* Resources */ = { 276 | isa = PBXResourcesBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | 7E7F5FBA1CFBF270000A8FEE /* LaunchScreen.storyboard in Resources */, 280 | 7E7F5FB71CFBF270000A8FEE /* Assets.xcassets in Resources */, 281 | 7E7F5FB51CFBF270000A8FEE /* Main.storyboard in Resources */, 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | }; 285 | 7E7F5FBE1CFBF270000A8FEE /* Resources */ = { 286 | isa = PBXResourcesBuildPhase; 287 | buildActionMask = 2147483647; 288 | files = ( 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | 7E7F5FC91CFBF270000A8FEE /* Resources */ = { 293 | isa = PBXResourcesBuildPhase; 294 | buildActionMask = 2147483647; 295 | files = ( 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | /* End PBXResourcesBuildPhase section */ 300 | 301 | /* Begin PBXSourcesBuildPhase section */ 302 | 7E7F5FA31CFBF270000A8FEE /* Sources */ = { 303 | isa = PBXSourcesBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | 7E7F5FE91CFBF2E2000A8FEE /* WQPChart.m in Sources */, 307 | 7E7F5FE81CFBF2E2000A8FEE /* UIBezierPath+curved.m in Sources */, 308 | 7E7F5FB21CFBF270000A8FEE /* ViewController.m in Sources */, 309 | 7E7F5FEC1CFBF2E2000A8FEE /* WQPChartLine.m in Sources */, 310 | 7E7F5FAF1CFBF270000A8FEE /* AppDelegate.m in Sources */, 311 | 7E7F5FAC1CFBF270000A8FEE /* main.m in Sources */, 312 | 7E7F5FEB1CFBF2E2000A8FEE /* WQPChartBar.m in Sources */, 313 | 7E7F5FEA1CFBF2E2000A8FEE /* WQPChartAll.m in Sources */, 314 | ); 315 | runOnlyForDeploymentPostprocessing = 0; 316 | }; 317 | 7E7F5FBC1CFBF270000A8FEE /* Sources */ = { 318 | isa = PBXSourcesBuildPhase; 319 | buildActionMask = 2147483647; 320 | files = ( 321 | 7E7F5FC51CFBF270000A8FEE /* WQPChartDemoTests.m in Sources */, 322 | ); 323 | runOnlyForDeploymentPostprocessing = 0; 324 | }; 325 | 7E7F5FC71CFBF270000A8FEE /* Sources */ = { 326 | isa = PBXSourcesBuildPhase; 327 | buildActionMask = 2147483647; 328 | files = ( 329 | 7E7F5FD01CFBF270000A8FEE /* WQPChartDemoUITests.m in Sources */, 330 | ); 331 | runOnlyForDeploymentPostprocessing = 0; 332 | }; 333 | /* End PBXSourcesBuildPhase section */ 334 | 335 | /* Begin PBXTargetDependency section */ 336 | 7E7F5FC21CFBF270000A8FEE /* PBXTargetDependency */ = { 337 | isa = PBXTargetDependency; 338 | target = 7E7F5FA61CFBF270000A8FEE /* WQPChartDemo */; 339 | targetProxy = 7E7F5FC11CFBF270000A8FEE /* PBXContainerItemProxy */; 340 | }; 341 | 7E7F5FCD1CFBF270000A8FEE /* PBXTargetDependency */ = { 342 | isa = PBXTargetDependency; 343 | target = 7E7F5FA61CFBF270000A8FEE /* WQPChartDemo */; 344 | targetProxy = 7E7F5FCC1CFBF270000A8FEE /* PBXContainerItemProxy */; 345 | }; 346 | /* End PBXTargetDependency section */ 347 | 348 | /* Begin PBXVariantGroup section */ 349 | 7E7F5FB31CFBF270000A8FEE /* Main.storyboard */ = { 350 | isa = PBXVariantGroup; 351 | children = ( 352 | 7E7F5FB41CFBF270000A8FEE /* Base */, 353 | ); 354 | name = Main.storyboard; 355 | sourceTree = ""; 356 | }; 357 | 7E7F5FB81CFBF270000A8FEE /* LaunchScreen.storyboard */ = { 358 | isa = PBXVariantGroup; 359 | children = ( 360 | 7E7F5FB91CFBF270000A8FEE /* Base */, 361 | ); 362 | name = LaunchScreen.storyboard; 363 | sourceTree = ""; 364 | }; 365 | /* End PBXVariantGroup section */ 366 | 367 | /* Begin XCBuildConfiguration section */ 368 | 7E7F5FD21CFBF270000A8FEE /* Debug */ = { 369 | isa = XCBuildConfiguration; 370 | buildSettings = { 371 | ALWAYS_SEARCH_USER_PATHS = NO; 372 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 373 | CLANG_CXX_LIBRARY = "libc++"; 374 | CLANG_ENABLE_MODULES = YES; 375 | CLANG_ENABLE_OBJC_ARC = YES; 376 | CLANG_WARN_BOOL_CONVERSION = YES; 377 | CLANG_WARN_CONSTANT_CONVERSION = YES; 378 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 379 | CLANG_WARN_EMPTY_BODY = YES; 380 | CLANG_WARN_ENUM_CONVERSION = YES; 381 | CLANG_WARN_INT_CONVERSION = YES; 382 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 383 | CLANG_WARN_UNREACHABLE_CODE = YES; 384 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 385 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 386 | COPY_PHASE_STRIP = NO; 387 | DEBUG_INFORMATION_FORMAT = dwarf; 388 | ENABLE_STRICT_OBJC_MSGSEND = YES; 389 | ENABLE_TESTABILITY = YES; 390 | GCC_C_LANGUAGE_STANDARD = gnu99; 391 | GCC_DYNAMIC_NO_PIC = NO; 392 | GCC_NO_COMMON_BLOCKS = YES; 393 | GCC_OPTIMIZATION_LEVEL = 0; 394 | GCC_PREPROCESSOR_DEFINITIONS = ( 395 | "DEBUG=1", 396 | "$(inherited)", 397 | ); 398 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 399 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 400 | GCC_WARN_UNDECLARED_SELECTOR = YES; 401 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 402 | GCC_WARN_UNUSED_FUNCTION = YES; 403 | GCC_WARN_UNUSED_VARIABLE = YES; 404 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 405 | MTL_ENABLE_DEBUG_INFO = YES; 406 | ONLY_ACTIVE_ARCH = YES; 407 | SDKROOT = iphoneos; 408 | }; 409 | name = Debug; 410 | }; 411 | 7E7F5FD31CFBF270000A8FEE /* Release */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | ALWAYS_SEARCH_USER_PATHS = NO; 415 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 416 | CLANG_CXX_LIBRARY = "libc++"; 417 | CLANG_ENABLE_MODULES = YES; 418 | CLANG_ENABLE_OBJC_ARC = YES; 419 | CLANG_WARN_BOOL_CONVERSION = YES; 420 | CLANG_WARN_CONSTANT_CONVERSION = YES; 421 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 422 | CLANG_WARN_EMPTY_BODY = YES; 423 | CLANG_WARN_ENUM_CONVERSION = YES; 424 | CLANG_WARN_INT_CONVERSION = YES; 425 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 426 | CLANG_WARN_UNREACHABLE_CODE = YES; 427 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 428 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 429 | COPY_PHASE_STRIP = NO; 430 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 431 | ENABLE_NS_ASSERTIONS = NO; 432 | ENABLE_STRICT_OBJC_MSGSEND = YES; 433 | GCC_C_LANGUAGE_STANDARD = gnu99; 434 | GCC_NO_COMMON_BLOCKS = YES; 435 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 436 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 437 | GCC_WARN_UNDECLARED_SELECTOR = YES; 438 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 439 | GCC_WARN_UNUSED_FUNCTION = YES; 440 | GCC_WARN_UNUSED_VARIABLE = YES; 441 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 442 | MTL_ENABLE_DEBUG_INFO = NO; 443 | SDKROOT = iphoneos; 444 | VALIDATE_PRODUCT = YES; 445 | }; 446 | name = Release; 447 | }; 448 | 7E7F5FD51CFBF270000A8FEE /* Debug */ = { 449 | isa = XCBuildConfiguration; 450 | buildSettings = { 451 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 452 | INFOPLIST_FILE = WQPChartDemo/Info.plist; 453 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 454 | PRODUCT_BUNDLE_IDENTIFIER = wqp.com.WQPChartDemo; 455 | PRODUCT_NAME = "$(TARGET_NAME)"; 456 | }; 457 | name = Debug; 458 | }; 459 | 7E7F5FD61CFBF270000A8FEE /* Release */ = { 460 | isa = XCBuildConfiguration; 461 | buildSettings = { 462 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 463 | INFOPLIST_FILE = WQPChartDemo/Info.plist; 464 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 465 | PRODUCT_BUNDLE_IDENTIFIER = wqp.com.WQPChartDemo; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | }; 468 | name = Release; 469 | }; 470 | 7E7F5FD81CFBF270000A8FEE /* Debug */ = { 471 | isa = XCBuildConfiguration; 472 | buildSettings = { 473 | BUNDLE_LOADER = "$(TEST_HOST)"; 474 | INFOPLIST_FILE = WQPChartDemoTests/Info.plist; 475 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 476 | PRODUCT_BUNDLE_IDENTIFIER = wqp.com.WQPChartDemoTests; 477 | PRODUCT_NAME = "$(TARGET_NAME)"; 478 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WQPChartDemo.app/WQPChartDemo"; 479 | }; 480 | name = Debug; 481 | }; 482 | 7E7F5FD91CFBF270000A8FEE /* Release */ = { 483 | isa = XCBuildConfiguration; 484 | buildSettings = { 485 | BUNDLE_LOADER = "$(TEST_HOST)"; 486 | INFOPLIST_FILE = WQPChartDemoTests/Info.plist; 487 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 488 | PRODUCT_BUNDLE_IDENTIFIER = wqp.com.WQPChartDemoTests; 489 | PRODUCT_NAME = "$(TARGET_NAME)"; 490 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WQPChartDemo.app/WQPChartDemo"; 491 | }; 492 | name = Release; 493 | }; 494 | 7E7F5FDB1CFBF270000A8FEE /* Debug */ = { 495 | isa = XCBuildConfiguration; 496 | buildSettings = { 497 | INFOPLIST_FILE = WQPChartDemoUITests/Info.plist; 498 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 499 | PRODUCT_BUNDLE_IDENTIFIER = wqp.com.WQPChartDemoUITests; 500 | PRODUCT_NAME = "$(TARGET_NAME)"; 501 | TEST_TARGET_NAME = WQPChartDemo; 502 | USES_XCTRUNNER = YES; 503 | }; 504 | name = Debug; 505 | }; 506 | 7E7F5FDC1CFBF270000A8FEE /* Release */ = { 507 | isa = XCBuildConfiguration; 508 | buildSettings = { 509 | INFOPLIST_FILE = WQPChartDemoUITests/Info.plist; 510 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 511 | PRODUCT_BUNDLE_IDENTIFIER = wqp.com.WQPChartDemoUITests; 512 | PRODUCT_NAME = "$(TARGET_NAME)"; 513 | TEST_TARGET_NAME = WQPChartDemo; 514 | USES_XCTRUNNER = YES; 515 | }; 516 | name = Release; 517 | }; 518 | /* End XCBuildConfiguration section */ 519 | 520 | /* Begin XCConfigurationList section */ 521 | 7E7F5FA21CFBF270000A8FEE /* Build configuration list for PBXProject "WQPChartDemo" */ = { 522 | isa = XCConfigurationList; 523 | buildConfigurations = ( 524 | 7E7F5FD21CFBF270000A8FEE /* Debug */, 525 | 7E7F5FD31CFBF270000A8FEE /* Release */, 526 | ); 527 | defaultConfigurationIsVisible = 0; 528 | defaultConfigurationName = Release; 529 | }; 530 | 7E7F5FD41CFBF270000A8FEE /* Build configuration list for PBXNativeTarget "WQPChartDemo" */ = { 531 | isa = XCConfigurationList; 532 | buildConfigurations = ( 533 | 7E7F5FD51CFBF270000A8FEE /* Debug */, 534 | 7E7F5FD61CFBF270000A8FEE /* Release */, 535 | ); 536 | defaultConfigurationIsVisible = 0; 537 | }; 538 | 7E7F5FD71CFBF270000A8FEE /* Build configuration list for PBXNativeTarget "WQPChartDemoTests" */ = { 539 | isa = XCConfigurationList; 540 | buildConfigurations = ( 541 | 7E7F5FD81CFBF270000A8FEE /* Debug */, 542 | 7E7F5FD91CFBF270000A8FEE /* Release */, 543 | ); 544 | defaultConfigurationIsVisible = 0; 545 | }; 546 | 7E7F5FDA1CFBF270000A8FEE /* Build configuration list for PBXNativeTarget "WQPChartDemoUITests" */ = { 547 | isa = XCConfigurationList; 548 | buildConfigurations = ( 549 | 7E7F5FDB1CFBF270000A8FEE /* Debug */, 550 | 7E7F5FDC1CFBF270000A8FEE /* Release */, 551 | ); 552 | defaultConfigurationIsVisible = 0; 553 | }; 554 | /* End XCConfigurationList section */ 555 | }; 556 | rootObject = 7E7F5F9F1CFBF270000A8FEE /* Project object */; 557 | } 558 | --------------------------------------------------------------------------------