├── chartTest
├── chartTest
│ ├── Assets.xcassets
│ │ ├── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── ViewController.h
│ ├── charView
│ │ ├── YJYTouchScroll.h
│ │ ├── YJYTouchCollectionView.h
│ │ ├── YJYLinesCell.h
│ │ ├── YJYLinesCell.m
│ │ ├── LinesSelectCell.h
│ │ ├── YJYTouchScroll.m
│ │ ├── YJYTouchCollectionView.m
│ │ ├── LHYLinesPaoPaoView.h
│ │ ├── LinesSelectCell.m
│ │ ├── YJYLinesCell.xib
│ │ ├── LHYChartView.h
│ │ ├── LHYLinesPaoPaoView.m
│ │ └── LHYChartView.m
│ ├── AppDelegate.h
│ ├── main.m
│ ├── Info.plist
│ ├── Base.lproj
│ │ ├── Main.storyboard
│ │ └── LaunchScreen.storyboard
│ ├── AppDelegate.m
│ ├── category
│ │ ├── NSString
│ │ │ ├── NSString+Extension.h
│ │ │ └── NSString+Extension.m
│ │ └── UIColor
│ │ │ ├── UIColor+expanded.h
│ │ │ └── UIColor+expanded.m
│ └── ViewController.m
├── chartTest.xcodeproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── lihaiyang.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ ├── xcuserdata
│ │ └── lihaiyang.xcuserdatad
│ │ │ ├── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ │ └── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ └── project.pbxproj
├── chartTestTests
│ ├── Info.plist
│ └── chartTestTests.m
└── chartTestUITests
│ ├── Info.plist
│ └── chartTestUITests.m
├── README.md
├── chartTest.podspec
└── LICENSE
/chartTest/chartTest/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/chartTest/chartTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/chartTest/chartTest.xcodeproj/project.xcworkspace/xcuserdata/lihaiyang.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lihaiyang123/LHYChartView/HEAD/chartTest/chartTest.xcodeproj/project.xcworkspace/xcuserdata/lihaiyang.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/chartTest/chartTest/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // chartTest
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/YJYTouchScroll.h:
--------------------------------------------------------------------------------
1 | //
2 | // YJYTouchScroll.h
3 | // YJYConsultant
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface YJYTouchScroll : UIScrollView
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/YJYTouchCollectionView.h:
--------------------------------------------------------------------------------
1 | //
2 | // YJYTouchCollectionView.h
3 | // YJYConsultant
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface YJYTouchCollectionView : UICollectionView
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/YJYLinesCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // YJYLinesCell.h
3 | // YJYLinesView
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface YJYLinesCell : UICollectionViewCell
12 | @property (weak, nonatomic) IBOutlet UILabel *titleLB;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/chartTest/chartTest/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // chartTest
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. 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 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/YJYLinesCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // YJYLinesCell.m
3 | // YJYLinesView
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import "YJYLinesCell.h"
10 |
11 | @implementation YJYLinesCell
12 |
13 | - (void)awakeFromNib {
14 | [super awakeFromNib];
15 | // Initialization code
16 | }
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/chartTest/chartTest/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // chartTest
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. 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 |
--------------------------------------------------------------------------------
/chartTest/chartTest.xcodeproj/xcuserdata/lihaiyang.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | chartTest.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 | chartTest.xcscheme_^#shared#^_
13 |
14 | orderHint
15 | 0
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LHYChartView
2 |
3 | [](https://badge.fury.io/gh/lihaiyang123%2FLHYChartView)
4 | 如果有不明白的,或者说需要帮助的,可加我QQ285470267 WX:lihaiyang730325 加的时候请备注是git上看到的。因为陌生人我基本都不会同意的。
5 | 以下是我项目里使用到的部分截图。
6 |
7 | 
8 |
9 |
10 | 
11 |
12 |
13 | 
14 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/LinesSelectCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // LinesSelectCell.h
3 | // LRSChartView
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface LinesSelectCell : UITableViewCell
12 | @property(nonatomic ,assign)CGFloat leftWidth;
13 |
14 | @property(nonatomic ,assign)CGFloat rightWith;
15 |
16 | -(void)showTitle:(NSString *)title andTitleColor:(UIColor *)titleColor andTitleFont:(UIFont *)titleFont andDescTile:(NSString *)descTitle andDescTileColor:(UIColor *)descTileColor andDescTitleFont:(UIFont *)DescTitleFont;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/chartTest.podspec:
--------------------------------------------------------------------------------
1 | @version = "0.1.3"
2 |
3 | Pod::Spec.new do |s|
4 | s.name = "chartTest"
5 | s.version = @version
6 | s.summary = "一款多种特效的折线图"
7 | s.description = "一款多种特效的折线图哟"
8 | s.homepage = "https://github.com/lihaiyang123/LHYChartView"
9 | s.license = { :type => "MIT", :file => "LICENSE" }
10 | s.author = { "lihaiyang123" => "lihaiyang730325@qq.com" }
11 | s.ios.deployment_target = '8.0'
12 | s.source = { :git => "https://github.com/lihaiyang123/LHYChartView.git", :tag => "v#{s.version}" }
13 | s.source_files = 'chartTest/chartTest/charView/*'
14 | s.requires_arc = true
15 | s.framework = "UIKit"
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/YJYTouchScroll.m:
--------------------------------------------------------------------------------
1 | //
2 | // YJYTouchScroll.m
3 | // YJYConsultant
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import "YJYTouchScroll.h"
10 |
11 | @implementation YJYTouchScroll
12 |
13 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
14 | [[self nextResponder] touchesBegan:touches withEvent:event];
15 | [super touchesBegan:touches withEvent:event];
16 | }
17 |
18 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
19 | [[self nextResponder] touchesEnded:touches withEvent:event];
20 | [super touchesEnded:touches withEvent:event];
21 |
22 | }
23 | @end
24 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/YJYTouchCollectionView.m:
--------------------------------------------------------------------------------
1 | //
2 | // YJYTouchCollectionView.m
3 | // YJYConsultant
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import "YJYTouchCollectionView.h"
10 |
11 | @implementation YJYTouchCollectionView
12 |
13 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
14 | [[self nextResponder] touchesBegan:touches withEvent:event];
15 | [super touchesBegan:touches withEvent:event];
16 | }
17 |
18 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
19 | [[self nextResponder] touchesEnded:touches withEvent:event];
20 | [super touchesEnded:touches withEvent:event];
21 |
22 | }
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/chartTest/chartTestTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chartTest/chartTestUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chartTest/chartTestTests/chartTestTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // chartTestTests.m
3 | // chartTestTests
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface chartTestTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation chartTestTests
16 |
17 | - (void)setUp {
18 | // Put setup code here. This method is called before the invocation of each test method in the class.
19 | }
20 |
21 | - (void)tearDown {
22 | // Put teardown code here. This method is called after the invocation of each test method in the class.
23 | }
24 |
25 | - (void)testExample {
26 | // This is an example of a functional test case.
27 | // Use XCTAssert and related functions to verify your tests produce the correct results.
28 | }
29 |
30 | - (void)testPerformanceExample {
31 | // This is an example of a performance test case.
32 | [self measureBlock:^{
33 | // Put the code you want to measure the time of here.
34 | }];
35 | }
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 lihaiyang123
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/LHYLinesPaoPaoView.h:
--------------------------------------------------------------------------------
1 | //
2 | // YJYLinesPaoPaoView.h
3 | // YJYLinesView
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "UIColor+expanded.h"
11 | typedef NS_ENUM(NSInteger,Direction){
12 | directionTop, //顶部
13 | directionBottom, //底部
14 | };
15 | @interface LHYLinesPaoPaoView : UIView
16 |
17 | @property (nonatomic,strong) UIImage *backgroudImage;
18 |
19 | @property (nonatomic,assign) CGFloat margin;
20 |
21 | @property (nonatomic,assign) CGFloat pointX;
22 |
23 | @property (nonatomic,assign) CGFloat chartContentWidth;
24 | //左侧是否靠边 默认为NO不靠边
25 | @property (nonatomic,assign) BOOL beyondLeft;
26 | //右侧是否靠边 默认为NO不靠边
27 | @property (nonatomic,assign) BOOL beyondRight;
28 |
29 | - (void)show:(NSArray *)dataArr and:(NSString *)title andTitleColor:(UIColor *)titleColor colorArr:(NSArray *)color;
30 |
31 | +(CGSize)getWidthAndHeight:(NSArray *)dataArray;
32 | //画边框并填充颜色
33 | -(void)drawBoxWithDirection:(Direction)direction;
34 |
35 | + (float)measureSinglelineStringWidth:(NSString*)str andFont:(UIFont*)wordFont;
36 | @end
37 |
--------------------------------------------------------------------------------
/chartTest/chartTest.xcodeproj/xcuserdata/lihaiyang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
18 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/chartTest/chartTestUITests/chartTestUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // chartTestUITests.m
3 | // chartTestUITests
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface chartTestUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation chartTestUITests
16 |
17 | - (void)setUp {
18 | // Put setup code here. This method is called before the invocation of each test method in the class.
19 |
20 | // In UI tests it is usually best to stop immediately when a failure occurs.
21 | self.continueAfterFailure = NO;
22 |
23 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
24 | [[[XCUIApplication alloc] init] launch];
25 |
26 | // 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.
27 | }
28 |
29 | - (void)tearDown {
30 | // Put teardown code here. This method is called after the invocation of each test method in the class.
31 | }
32 |
33 | - (void)testExample {
34 | // Use recording to get started writing UI tests.
35 | // Use XCTAssert and related functions to verify your tests produce the correct results.
36 | }
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/chartTest/chartTest/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/chartTest/chartTest/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 |
--------------------------------------------------------------------------------
/chartTest/chartTest/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 |
--------------------------------------------------------------------------------
/chartTest/chartTest/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/chartTest/chartTest/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // chartTest
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. 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 |
24 | - (void)applicationWillResignActive:(UIApplication *)application {
25 | // 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.
26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
27 | }
28 |
29 |
30 | - (void)applicationDidEnterBackground:(UIApplication *)application {
31 | // 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.
32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33 | }
34 |
35 |
36 | - (void)applicationWillEnterForeground:(UIApplication *)application {
37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
38 | }
39 |
40 |
41 | - (void)applicationDidBecomeActive:(UIApplication *)application {
42 | // 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.
43 | }
44 |
45 |
46 | - (void)applicationWillTerminate:(UIApplication *)application {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/LinesSelectCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // LinesSelectCell.m
3 | // LRSChartView
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import "LinesSelectCell.h"
10 |
11 | @interface LinesSelectCell ()
12 | //←lab
13 | @property (nonatomic ,strong) UILabel * titlesLab;
14 | //→lab
15 | @property (nonatomic ,strong) UILabel * descsLab;
16 | @end
17 |
18 | @implementation LinesSelectCell
19 |
20 | - (void)awakeFromNib {
21 | [super awakeFromNib];
22 | // Initialization code
23 | }
24 |
25 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
26 | [super setSelected:selected animated:animated];
27 | // Configure the view for the selected state
28 | }
29 | -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
30 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
31 | self.backgroundColor = [UIColor clearColor];
32 | _titlesLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 0, 17)];
33 | [self addSubview:_titlesLab];
34 | _descsLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 0, 17)];
35 | [self addSubview:_descsLab];
36 | }
37 | return self;
38 | }
39 |
40 | -(void)setLeftWidth:(CGFloat)leftWidth{
41 | _leftWidth = leftWidth;
42 | if (leftWidth < 50) {
43 | leftWidth = 50;
44 | }
45 | [_titlesLab setFrame:CGRectMake(10, 0, leftWidth, 17)];
46 | }
47 |
48 | -(void)setRightWith:(CGFloat)rightWith{
49 | _rightWith = rightWith;
50 | if (rightWith < 50 && rightWith != 0) {
51 | rightWith = 50;
52 | }
53 | [_descsLab setFrame:CGRectMake(CGRectGetMaxX(_titlesLab.frame) + 10, 0, rightWith, 17)];
54 | }
55 |
56 | -(void)showTitle:(NSString *)title andTitleColor:(UIColor *)titleColor andTitleFont:(UIFont *)titleFont andDescTile:(NSString *)descTitle andDescTileColor:(UIColor *)descTileColor andDescTitleFont:(UIFont *)DescTitleFont{
57 | _titlesLab.text = title;
58 | _titlesLab.textColor = titleColor;
59 | _titlesLab.font = titleFont;
60 | if (descTitle) _descsLab.text = descTitle;
61 | if (descTileColor) _descsLab.textColor = descTileColor;
62 | if (DescTitleFont) _descsLab.font = DescTitleFont;
63 |
64 | }
65 | @end
66 |
--------------------------------------------------------------------------------
/chartTest/chartTest/category/NSString/NSString+Extension.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+Extension.h
3 | // SCH
4 | //
5 | // Created by SCH_YUH on 2017/1/10.
6 | // Copyright © 2017年 SCH_YUH. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | @interface NSString (Extension)
12 | ///得到现在时间戳的字符串
13 | + (instancetype)getDateUnqueDescription;
14 | #pragma mark - 判断一个字符串是不是空
15 | /**
16 | *函数描述 : 判断一个字符串是不是空
17 | *@returns 为空则返回真
18 | */
19 | - (BOOL)isEmpty;
20 | -(BOOL)isNull;
21 | + (BOOL) isNullOrEmpty:(NSString *)string;
22 |
23 | #pragma mark - 验证号码
24 | #pragma mark -
25 | /**
26 | *函数描述 :验证邮箱是否合法
27 | *返回 :YES=合法邮箱
28 | **/
29 | -(BOOL)verifyEmail;
30 | /**
31 | *函数描述 :验手机号是否合法
32 | *返回 :YES=合法手机号
33 | */
34 | -(BOOL)isPhoneNumber;
35 | /**
36 | 验证座机
37 | */
38 | -(BOOL)isTelephoneNumber;
39 |
40 |
41 | //返回值是该字符串所占一行的width
42 | -(CGFloat)getSingleLineTextSizeWithFont: (UIFont*)font;
43 |
44 |
45 | /**
46 | 拨打电话
47 | */
48 | -(void)call;
49 |
50 | /**
51 | 随机图片名称
52 |
53 | @return 图片名称
54 | */
55 | + (NSString *)pictureNaming;
56 | /**
57 | 获取刻度尺
58 |
59 | @param num 数量
60 | @param unit 单位
61 | @return 返回需要的字符串
62 | */
63 | +(NSString *)roundUpNum:(CGFloat )num unit:(NSString *)unit;
64 |
65 | /**
66 | 获取刻度尺 得到的数字之间将小数点后面一位之后的舍去
67 |
68 | @param num 数量
69 | @param unit 单位
70 | @return 返回需要的字符串
71 | */
72 | +(NSString *)roundUpFloorfNum:(CGFloat )num unit:(NSString *)unit;
73 |
74 | +(NSDictionary *)dic_roundUpNum:(CGFloat )num unit:(NSString *)unit;
75 | +(NSString *)dic_roundUpNum:(NSDictionary *)dic;
76 | +(NSString *)dic_roundUpUnit:(NSDictionary *)dic;
77 |
78 | +(CGSize)getAttributeSizeWithText:(NSString *)text fontSize:(int)fontSize;
79 | +(float)measureSinglelineStringWidth:(NSString*)str andFont:(UIFont*)wordFont;
80 | +(float)measureMultilineStringHeight:(NSString*)str andFont:(UIFont*)wordFont andWidth:(CGFloat)width;
81 |
82 | /**
83 | 格式化金额
84 |
85 | @param str 金额string
86 | @param numberStyle 格式化类型
87 | @return 返回格式化金额
88 | */
89 | + (NSString *)stringChangeMoneyWithStr:(NSString *)str numberStyle:(NSNumberFormatterStyle)numberStyle ;
90 |
91 | + (NSString *)stringChangeMoneyWithDouble:(double)number;
92 |
93 | /**
94 | 替换字符串null 为空串 否则返回本身
95 | */
96 | + (NSString *)replaceNullString:(NSString *)string;
97 |
98 | @end
99 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/YJYLinesCell.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/chartTest/chartTest/category/UIColor/UIColor+expanded.h:
--------------------------------------------------------------------------------
1 |
2 | /****
3 | VOORBEELDEN
4 |
5 | [UIColor colorWithRGBHex:0xff00ff];
6 | [UIColor colorWithHexString:@"0xff00ff"]
7 | *******/
8 |
9 | #import
10 |
11 | #define SUPPORTS_UNDOCUMENTED_API 0
12 |
13 | @interface UIColor (UIColor_Expanded)
14 | @property (nonatomic, readonly) CGColorSpaceModel colorSpaceModel;
15 | @property (nonatomic, readonly) BOOL canProvideRGBComponents;
16 | @property (nonatomic, readonly) CGFloat red; // Only valid if canProvideRGBComponents is YES
17 | @property (nonatomic, readonly) CGFloat green; // Only valid if canProvideRGBComponents is YES
18 | @property (nonatomic, readonly) CGFloat blue; // Only valid if canProvideRGBComponents is YES
19 | @property (nonatomic, readonly) CGFloat white; // Only valid if colorSpaceModel == kCGColorSpaceModelMonochrome
20 | @property (nonatomic, readonly) CGFloat alpha;
21 | @property (nonatomic, readonly) UInt32 rgbHex;
22 |
23 | - (NSString *)colorSpaceString;
24 |
25 | - (NSArray *)arrayFromRGBAComponents;
26 |
27 | - (BOOL)red:(CGFloat *)r green:(CGFloat *)g blue:(CGFloat *)b alpha:(CGFloat *)a;
28 |
29 | - (UIColor *)colorByLuminanceMapping;
30 |
31 | - (UIColor *)colorByMultiplyingByRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
32 | - (UIColor *) colorByAddingRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
33 | - (UIColor *) colorByLighteningToRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
34 | - (UIColor *) colorByDarkeningToRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
35 |
36 | - (UIColor *)colorByMultiplyingBy:(CGFloat)f;
37 | - (UIColor *) colorByAdding:(CGFloat)f;
38 | - (UIColor *) colorByLighteningTo:(CGFloat)f;
39 | - (UIColor *) colorByDarkeningTo:(CGFloat)f;
40 |
41 | - (UIColor *)colorByMultiplyingByColor:(UIColor *)color;
42 | - (UIColor *) colorByAddingColor:(UIColor *)color;
43 | - (UIColor *) colorByLighteningToColor:(UIColor *)color;
44 | - (UIColor *) colorByDarkeningToColor:(UIColor *)color;
45 |
46 | - (NSString *)stringFromColor;
47 | - (NSString *)hexStringFromColor;
48 |
49 | - (BOOL)isDark;
50 |
51 | + (UIColor *)randomColor;
52 | + (UIColor *)colorWithString:(NSString *)stringToConvert;
53 | + (UIColor *)colorWithRGBHex:(UInt32)hex;
54 | + (UIColor *)colorWithHexString:(NSString *)stringToConvert;
55 | + (UIColor *)colorWithHexString:(NSString *)stringToConvert andAlpha:(CGFloat)alpha;
56 |
57 | + (UIColor *)colorWithName:(NSString *)cssColorName;
58 |
59 | @end
60 |
61 | #if SUPPORTS_UNDOCUMENTED_API
62 | // UIColor_Undocumented_Expanded
63 | // Methods which rely on undocumented methods of UIColor
64 | @interface UIColor (UIColor_Undocumented_Expanded)
65 | - (NSString *)fetchStyleString;
66 | - (UIColor *)rgbColor; // Via Poltras
67 | @end
68 | #endif // SUPPORTS_UNDOCUMENTED_API
69 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/LHYChartView.h:
--------------------------------------------------------------------------------
1 | //
2 | // LHYChartView.h
3 | // LHYChartView
4 | //
5 | // Created by lreson on 16/7/21.
6 | // Copyright © 2016年 lreson. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "UIColor+expanded.h"
11 | #import "NSString+Extension.h"
12 | #define NS_ENUM(...) CF_ENUM(__VA_ARGS__)
13 |
14 |
15 | typedef NS_ENUM(NSInteger,LHYChartViewStyle){
16 | LHYChartViewMoreNoClickLine, //多条折现不可以点击 暂时没做
17 | LHYChartViewMoreClickLine, //多条折现可以点击
18 | LHYChartViewLeftRightLine, //左右两种不同数据
19 | };
20 |
21 | typedef NS_ENUM(NSInteger,LHYChartLayerStyle){
22 | LHYChartNone, //没有
23 | LHYChartGradient, //渐变
24 | LHYChartProjection, //投影
25 | };
26 |
27 | typedef NS_ENUM(NSInteger,LHYLineLayerStyle){
28 | LHYLineLayerNone, //没有
29 | LHYLineLayerGradient, //渐变
30 | };
31 |
32 | typedef NS_ENUM(NSInteger,LHYUnitStyle){
33 | LHYUnitGe, //个
34 | LHYUnitThousand, //千
35 | LHYUnitWan, //万
36 | LHYUnitMillion, //亿
37 | LHYUnitMoneyDefault,
38 | LHYUnitMoneyPercentage,//百分比,最大100%
39 | LHYUnitMoneyPercentageDefault,//百分比,有多大显示多大
40 | LHYUnitDefault //默认自适应
41 | };
42 |
43 | @interface LHYChartView : UIView
44 | /** X轴坐标数据 */
45 | @property (nonatomic, strong) NSArray *dataArrOfX;
46 | /** Y轴左边数据 */
47 | @property (nonatomic,strong) NSArray *leftDataArr;
48 | /** Y轴右边数据 没有不用传递 */
49 | @property (nonatomic,strong) NSArray *rightDataArr;
50 | //线条宽度,默认为1
51 | @property (nonatomic, assign) CGFloat lineWidth;
52 | // 计算精度,10,100,1000,默认是1
53 | @property (nonatomic,assign)NSInteger precisionScale;
54 | //折线图样式 默认不可点击
55 | @property (nonatomic,assign)LHYChartViewStyle chartViewStyle;
56 | //点否可以点击弹出泡泡
57 | @property (nonatomic,assign) BOOL isSelect;
58 | //气泡是否根据折线位置可以浮动,默认不可以
59 | @property (nonatomic,assign)BOOL isFloating;
60 | //图层样式 默认没有
61 | @property (nonatomic,assign) LHYChartLayerStyle chartLayerStyle;
62 | //左侧标注折线颜色组可传二进制字符串,可传UIColor
63 | @property (nonatomic, strong) NSArray *leftColorStrArr;
64 | //右侧标注折线颜色组
65 | @property (nonatomic, strong) NSArray *rightColorStrArr;
66 | //X轴坐标字体大小
67 | @property (nonatomic, strong) UIFont *x_Font;
68 | //X轴坐标选中字体大小
69 | @property (nonatomic, strong) UIFont *x_Select_Font;
70 | //X轴坐标选中字体颜色
71 | @property (nonatomic, strong) UIColor *x_Select_Color;
72 | //X轴坐标字体颜色
73 | @property (nonatomic, strong) UIColor *x_Color;
74 | //Y轴坐标字体大小
75 | @property (nonatomic, strong) UIFont *y_Font;
76 | //Y轴坐标字体颜色
77 | @property (nonatomic, strong) UIColor *y_Color;
78 | //折现样式 默认没有
79 | @property (nonatomic, assign) LHYLineLayerStyle lineLayerStyle;
80 | //折现渐变颜色组
81 | @property (nonatomic, strong) NSArray * colors;
82 | //渐变比例 0-1 初始化0.5
83 | @property (nonatomic, assign) CGFloat proportion;
84 | //显示多少行 默认2行
85 | @property (nonatomic,assign)NSInteger row;
86 | //是否显示所有点 默认不显示
87 | @property (nonatomic, assign)BOOL isShow;
88 | //设置泡泡的背景色
89 | @property (nonatomic, strong) UIColor *paopaoBackGroundColor;
90 | //设置标线颜色
91 | @property (nonatomic,strong) UIColor * markColor;
92 | //泡泡的标题颜色
93 | @property (nonatomic,strong) UIColor * paopaoTitleColor;
94 | //泡泡的数据颜色组
95 | @property (nonatomic,strong) NSArray * paopaoDataColors;
96 | //泡泡的显示数据组
97 | @property (nonatomic,strong) NSArray * paopaoDataArray;
98 | //小数点千位还是万位,没有单位。如不设置此参数,默认大于1000以k表示,如1500,显示为1.5k。
99 | @property (nonatomic,assign) LHYUnitStyle unitStyle;
100 | //泡泡标题组,如果不传,将默认不显示titile。
101 | @property (nonatomic, strong) NSArray *paopaoTitleArray;
102 | //是否显示网格
103 | @property (nonatomic,assign) BOOL isGrid;
104 | //x坐标初始显示多少列
105 | @property (nonatomic,assign) NSInteger xRow;
106 | //边框标线颜色
107 | @property (nonatomic,strong) UIColor * borderLineColor;
108 | //中间标线颜色
109 | @property (nonatomic,strong) UIColor * middleLineColor;
110 | //边框三角颜色
111 | @property (nonatomic,strong) UIColor * borderTriangleColor;
112 | //渐变比例组
113 | @property (nonatomic,strong) NSArray * locations;
114 | //是否显示Y坐标轴 默认为YES显示
115 | @property (nonatomic,assign) BOOL isShowYtext;
116 | //是否显示第一个泡泡,默认为NO不显示。
117 | @property (nonatomic,assign) BOOL isShowFirstPaoPao;
118 | //是否显示最后一个泡泡,默认为NO不显示。
119 | @property (nonatomic,assign) BOOL isShowLastPaoPao;
120 |
121 | /**
122 | 指定泡泡在某个点上显示。不能和isShowFirstPaoPao、isShowLastPaoPao共用
123 | */
124 | @property (nonatomic,assign) NSInteger showPaoPaoForIndex;
125 | //选中状态的圆,外圆是否是白色
126 | @property (nonatomic,assign) BOOL isShowCircleOutWhite;
127 | //折线图是否从零点开始画 YES为从1点开始画 NO为从零点开始画 默认为NO
128 | @property (nonatomic,assign) BOOL hiddenZreo;
129 | //最大值
130 | @property (nonatomic,assign) CGFloat max;
131 | //最小值 不传的话,默认从数据中获取最小值,如果数据中最小值大于0,则为0。 传的话,以传入的最小值为准。
132 | @property (nonatomic,strong) NSString *min;
133 | //是否显示Y轴的零位 YES显示 NO不显示
134 | @property (nonatomic,assign) BOOL isShowZero;
135 | /**
136 | Y轴单位
137 | */
138 | @property (nonatomic,strong) NSString * unitName;
139 |
140 | /**
141 | 折线为0的时候,是否向上偏移,默认偏移。不偏移传NO
142 | */
143 | @property (nonatomic,assign) BOOL showChartOffset;
144 |
145 | /**
146 | 折线是否显示为贝塞尔曲线,yes为贝塞尔曲线,no为直线。默认为yes
147 | */
148 | @property (nonatomic,assign) BOOL isShowBezier;
149 |
150 | /**
151 | 泡泡是否跟随手势移动 YES为是 NO为不跟随 默认为NO
152 | */
153 | @property (nonatomic,assign) BOOL paopaoFollowSliding;
154 |
155 | /**
156 | block返回泡泡选中的值
157 | */
158 | @property (nonatomic,copy) void (^returnPaoPaoDataBlock)(NSArray *array,NSString *title);
159 |
160 | -(void)show;
161 | //初始化
162 | -(void)initNew;
163 | @end
164 |
--------------------------------------------------------------------------------
/chartTest/chartTest/category/NSString/NSString+Extension.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+Extension.m
3 | // SCH
4 | //
5 | // Created by SCH_YUH on 2017/1/10.
6 | // Copyright © 2017年 SCH_YUH. All rights reserved.
7 | //
8 |
9 | #import "NSString+Extension.h"
10 |
11 | @implementation NSString (Extension)
12 | + (instancetype)getDateUnqueDescription{
13 | NSDate *now = [NSDate date];
14 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
15 | [formatter setDateFormat:@"mdYHMSF"];
16 | return [formatter stringFromDate:now];
17 | }
18 |
19 | #pragma mark 字符串空判断
20 | - (BOOL)isEmpty
21 | {
22 |
23 | return [[NSNull null] isEqual:self] || [self isEqualToString:@""] || [[self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] isEqual:@""]||self==NULL;
24 | }
25 | -(BOOL)isNull{
26 | if (self == nil) {
27 | return YES;
28 | }
29 | if ([self isEqualToString:@""]) {
30 | return YES;
31 | }
32 | return NO;
33 | }
34 | + (BOOL) isNullOrEmpty:(NSString *)string
35 | {
36 | return string == nil
37 | || [string isEqual: (id)[NSNull null]]
38 | || [string isKindOfClass:[NSString class]] == NO
39 | || [@"" isEqualToString:string]
40 | || [[string stringByReplacingOccurrencesOfString:@" " withString:@""] length] == 0U
41 | || [[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] == 0U;
42 | }
43 |
44 | #pragma mark 邮箱判断
45 | -(BOOL)verifyEmail{
46 | NSString *emailRegex = @"[A-Z0-9a-z_%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
47 | NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
48 | return [emailTest evaluateWithObject:self];
49 | }
50 | #pragma mark 手机号判断
51 | -(BOOL)isPhoneNumber{
52 |
53 | // NSString *phoneRegex = @"^((14[5,7])|(13[0-9])|(15[0-9])|(17[0-9])|(18[0,0-9]))\\d{8}$";
54 | NSString *phoneRegex = @"^((1[0-9]))\\d{9}$";
55 | NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
56 | return [phoneTest evaluateWithObject:self];
57 |
58 | }
59 | #pragma mark - 座机
60 | -(BOOL)isTelephoneNumber{
61 | ///八位或11位数字 座机号码
62 | NSString *telephoneNumberRegex = @"^\\d{8}$|^\\d{11}$";
63 | NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", telephoneNumberRegex];
64 | return [predicate evaluateWithObject:self];
65 | }
66 |
67 | /**
68 | *返回值是该字符串所占一行的width
69 | *font : 该字符串所用的字体(字体大小不一样,显示出来的面积也不同)
70 | */
71 | -(CGFloat)getSingleLineTextSizeWithFont: (UIFont*)font {
72 | NSDictionary *attrs = @{NSFontAttributeName : font};
73 | return [self boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size.width;
74 | }
75 | -(void)call{
76 | NSString *str = [self stringByReplacingOccurrencesOfString:@" " withString:@""];
77 | NSString *calUrl = [NSString stringWithFormat:@"tel:%@",str];
78 | if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:calUrl]]) {
79 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:calUrl]];
80 | }
81 | }
82 |
83 |
84 |
85 | + (NSString *)pictureNaming {
86 |
87 | char data[32];
88 |
89 | for (int x=0;x<32;data[x++] = (char)('A' + (arc4random_uniform(26))));
90 |
91 | //随机字符串32位
92 | NSString *str=[[NSString alloc] initWithBytes:data length:32 encoding:NSUTF8StringEncoding];
93 | //当前时间戳
94 | NSString *DateTime = [NSString getDateUnqueDescription];
95 | str=[NSString stringWithFormat:@"%@%@",str,DateTime];
96 | return str;
97 | }
98 |
99 | +(NSString *)roundUpNum:(CGFloat )num unit:(NSString *)unit{
100 |
101 | NSString *numStr = @"";
102 | if (num < 1000) {
103 | numStr = [NSString stringWithFormat:@"%.0f%@",num,unit];
104 | return numStr;
105 | }else{
106 |
107 | numStr = [NSString stringWithFormat:@"%.1fk%@",ceil(num/1000 *10)/10,unit];
108 | return numStr;
109 | }
110 | }
111 | +(NSString *)roundUpFloorfNum:(CGFloat )num unit:(NSString *)unit{
112 |
113 | NSString *numStr = @"";
114 | if (num < 1000) {
115 | numStr = [NSString stringWithFormat:@"%.0f%@",num,unit];
116 | return numStr;
117 | }else{
118 | float f = num/1000;
119 |
120 | NSString *fStr = [NSString stringWithFormat:@"%f",f];
121 | // 点的位置
122 | NSUInteger ponitLoc = [fStr rangeOfString:@"."].location;
123 | // 需要改变的区间
124 | NSRange range = NSMakeRange(0,ponitLoc);
125 | NSRange secRange;
126 | if (fStr.length>ponitLoc+2) {
127 | secRange = NSMakeRange(ponitLoc, 2);
128 | }else{
129 | secRange = NSMakeRange(ponitLoc,fStr.length-ponitLoc);
130 | }
131 |
132 | NSString *firstComponent = [fStr substringWithRange:range];
133 | NSString *secondComponent = [fStr substringWithRange:secRange];
134 |
135 | if ([secondComponent isEqualToString:@".0"]) {
136 | secondComponent = @"";
137 | }
138 |
139 | numStr = [NSString stringWithFormat:@"%@%@k%@", firstComponent, secondComponent, unit];
140 | return numStr;
141 | }
142 | }
143 | +(CGSize)getAttributeSizeWithText:(NSString *)text fontSize:(int)fontSize
144 | {
145 | CGSize size=[text sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:fontSize]}];
146 |
147 | return size;
148 | }
149 |
150 | +(NSDictionary *)dic_roundUpNum:(CGFloat )num unit:(NSString *)unit{
151 | NSString *numStr = @"";
152 | if (num < 1000) {
153 | numStr = [NSString stringWithFormat:@"%.0f%@",num,unit];
154 | return @{@"num":[NSString stringWithFormat:@"%.0f",num],
155 | @"unit":unit
156 | };
157 | }else{
158 |
159 | numStr = [NSString stringWithFormat:@"%.1fk%@",ceil(num/1000 *10)/10,unit];
160 | return @{@"num":[NSString stringWithFormat:@"%.1f",ceil(num/1000 *10)/10],
161 | @"unit":[NSString stringWithFormat:@"k%@",unit]
162 | };
163 | }
164 | }
165 | +(NSString *)dic_roundUpNum:(NSDictionary *)dic{
166 | if (dic[@"num"] != nil) {
167 | return dic[@"num"];
168 | }
169 | return @"";
170 | }
171 | +(NSString *)dic_roundUpUnit:(NSDictionary *)dic{
172 | if (dic[@"unit"] != nil) {
173 | return dic[@"unit"];
174 | }
175 | return @"";
176 | }
177 |
178 | + (float)measureSinglelineStringWidth:(NSString*)str andFont:(UIFont*)wordFont {
179 | if (str == nil) return 0;
180 | CGSize measureSize = [str boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingUsesFontLeading attributes:[NSDictionary dictionaryWithObjectsAndKeys:wordFont, NSFontAttributeName, nil] context:nil].size;
181 | return ceil(measureSize.width);
182 | }
183 |
184 | + (float)measureMultilineStringHeight:(NSString*)str andFont:(UIFont*)wordFont andWidth:(CGFloat)width {
185 | if (str == nil) {
186 | return 0;
187 | }
188 | CGSize measureSize = [str boundingRectWithSize:CGSizeMake(width, [wordFont pointSize] * 3) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:wordFont, NSFontAttributeName, nil] context:nil].size;
189 | return ceil(measureSize.height);
190 | }
191 |
192 | + (NSString *)stringChangeMoneyWithStr:(NSString *)str numberStyle:(NSNumberFormatterStyle)numberStyle {
193 |
194 | // 判断是否null 若是赋值为0 防止崩溃
195 | if (([str isEqual:[NSNull null]] || str == nil)) {
196 | str = 0;
197 | }
198 |
199 | NSNumberFormatter *formatter = [[NSNumberFormatter alloc]init];
200 | formatter.numberStyle = numberStyle;
201 | // 注意传入参数的数据长度,可用double
202 | NSString *money = [formatter stringFromNumber:[NSNumber numberWithDouble:[str doubleValue]]];
203 |
204 | return money;
205 | }
206 |
207 | + (NSString *)stringChangeMoneyWithDouble:(double)number {
208 |
209 | NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
210 | formatter.positiveFormat = @",###.##"; // 正数格式
211 | // 注意传入参数的数据长度,可用double
212 | NSString *money = [formatter stringFromNumber:@(number)];
213 | // money = [NSString stringWithFormat:@"¥%@", money];
214 |
215 | return money;
216 | }
217 |
218 | + (NSString *)replaceNullString:(NSString *)string {
219 | if (!string) {
220 | return @"";
221 | }
222 | return string;
223 | }
224 |
225 | @end
226 |
--------------------------------------------------------------------------------
/chartTest/chartTest/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // chartTest
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "LHYChartView.h"
11 | @interface ViewController ()
12 |
13 | @property (nonatomic,strong) LHYChartView *chartView;
14 | @end
15 |
16 | @implementation ViewController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 | self.view.backgroundColor = [UIColor whiteColor];
21 | [self addFirstChartView];
22 | // [self addSecondChartView];
23 | }
24 |
25 | -(void)addFirstChartView{
26 | LHYChartView *incomeChartLineView = [[LHYChartView alloc]initWithFrame:CGRectMake(20, 50, [UIScreen mainScreen].bounds.size.width - 40, 300)];
27 | //是否默认选中第一个
28 | // incomeChartLineView.isShowFirstPaoPao = YES;
29 | incomeChartLineView.showPaoPaoForIndex = 6;
30 | //是否有网格
31 | incomeChartLineView.isGrid = YES;
32 | //是否显示所有点
33 | incomeChartLineView.isShow = YES;
34 | //是否可以浮动
35 | incomeChartLineView.isFloating = NO;
36 | //显示多少行
37 | incomeChartLineView.row = 6;
38 | //显示多少列
39 | incomeChartLineView.xRow = 6;
40 | //设置X轴坐标字体大小
41 | incomeChartLineView.x_Font = [UIFont systemFontOfSize:10];
42 | //设置X轴坐标字体颜色
43 | incomeChartLineView.x_Color = [UIColor colorWithHexString:@"#999999"];
44 | //设置Y轴坐标字体大小
45 | incomeChartLineView.y_Font = [UIFont systemFontOfSize:10];
46 | //设置Y轴坐标字体颜色
47 | incomeChartLineView.y_Color = [UIColor colorWithHexString:@"#999999"];
48 | //设置背景颜色
49 | incomeChartLineView.backgroundColor = [UIColor whiteColor];
50 | //边框标线颜色
51 | incomeChartLineView.borderLineColor = [UIColor colorWithHexString:@"#999999"];
52 | //中间标线颜色
53 | incomeChartLineView.middleLineColor = [UIColor colorWithHexString:@"#cbcbcb" andAlpha:0.5];
54 | //边框三角颜色
55 | incomeChartLineView.borderTriangleColor = [UIColor colorWithHexString:@"#999999"];
56 | //设置泡泡背景颜色
57 | incomeChartLineView.paopaoBackGroundColor = [UIColor colorWithHexString:@"#000000" andAlpha:0.85];
58 | incomeChartLineView.markColor = [UIColor colorWithHexString:@"#333333"];
59 | //设置泡泡的标题颜色
60 | incomeChartLineView.paopaoTitleColor = [UIColor whiteColor];
61 | //设置折线样式
62 | incomeChartLineView.chartViewStyle = LHYChartViewMoreClickLine;
63 | //设置图层效果
64 | incomeChartLineView.chartLayerStyle = LHYChartGradient;
65 | //设置折现效果
66 | incomeChartLineView.lineLayerStyle = LHYLineLayerNone;
67 |
68 | incomeChartLineView.lineWidth = 3;
69 |
70 | incomeChartLineView.paopaoBackGroundColor = [UIColor colorWithHexString:@"#111111" andAlpha:0.8];
71 | //渐变开始比例
72 | incomeChartLineView.proportion = 1;
73 |
74 | incomeChartLineView.isShowBezier = NO;
75 | //折线图是否从零点开始画
76 | incomeChartLineView.hiddenZreo = YES;
77 | //设置颜色
78 | incomeChartLineView.leftColorStrArr = @[@"#6dd89c",@"#00a1eb",@"#bc69e0",@"#385af0"];
79 | //是否显示Y轴零位
80 | incomeChartLineView.isShowZero = YES;
81 | //泡泡是否跟随屏幕滑动而滑动
82 | incomeChartLineView.paopaoFollowSliding = NO;
83 | //折线图数据
84 | incomeChartLineView.leftDataArr = @[@[@"-9999.4",@"30907",@"32010",@"33450",@"30069",@"31574",@"30692",@"33156",@"29808",@"31846",@"29772",@"29630"]];
85 | //底部日期
86 | incomeChartLineView.dataArrOfX = @[@"4月",@"5月",@"6月",@"7月",@"8月",@"9月",@"10月",@"11月",@"12月",@"1月",@"2月",@"3月"];
87 | //泡泡标题
88 | // incomeChartLineView.paopaoTitleArray = @[@"2018-04",@"2018-05",@"2018-06",@"2018-07",@"2018-08",@"2018-09",@"2018-10",@"2018-11",@"2018-12",@"2019-01",@"2019-02",@"2019-03"];
89 | //返回泡泡选中值
90 | incomeChartLineView.returnPaoPaoDataBlock = ^(NSArray *array, NSString *title) {
91 | NSLog(@"%@-----%@",array,title);
92 | };
93 | incomeChartLineView.paopaoDataColors = @[[UIColor colorWithHexString:@"#6dd89c"],[UIColor colorWithHexString:@"#00a1eb"],[UIColor colorWithHexString:@"#bc69e0"],[UIColor colorWithHexString:@"#385af0"]];
94 | //泡泡数据
95 | incomeChartLineView.paopaoDataArray = @[@[@"-10,000元m²",@"30,907元m²",@"32,010元m²",@"33,450元m²",@"30,069元m²",@"31,574元m²",@"30,692元m²",@"33,156元m²",@"29,808元m²",@"31,846元m²",@"29,772元m²",@"29,630元m²"],@[@"46,175元m²",@"44,915元m²",@"36,228元m²",@"50,473元m²",@"28,811元m²",@"11,876元m²",@"23,213元m²",@"26,847元m²",@"27,905元m²",@"9,562元m²",@"34,263元m²",@"25,459元m²"],@[@"20,549元m²",@"15,981元m²",@"23,375元m²",@"20,516元m²",@"19,208元m²",@"15,121元m²",@"13,776元m²",@"16,282元m²",@"30,748元m²",@"26,531元m²",@"31,298元m²",@"33,183元m²"],@[@"11,053元m²",@"25,811元m²"]];
96 | //开始画图
97 | [incomeChartLineView show];
98 | [self.view addSubview:incomeChartLineView];
99 | }
100 |
101 | -(LHYChartView *)chartView {
102 | if (!_chartView) {
103 | _chartView = [[LHYChartView alloc]initWithFrame:CGRectMake(15, 50, self.view.frame.size.width - 30, 300)];
104 | //是否默认选中第一个
105 | _chartView.isShowFirstPaoPao = YES;
106 | //是否有网格
107 | _chartView.isGrid = YES;
108 | //是否可以浮动
109 | _chartView.isFloating = NO;
110 | //泡泡是否跟随手势移动
111 | _chartView.paopaoFollowSliding = YES;
112 | //显示多少行
113 | _chartView.row = 6;
114 | //显示多少列
115 | _chartView.xRow = 7;
116 | //线宽
117 | _chartView.lineWidth = 2;
118 | //设置X轴坐标字体大小
119 | _chartView.x_Font = [UIFont systemFontOfSize:10];
120 | //设置X轴坐标字体颜色
121 | _chartView.x_Color = [UIColor colorWithHexString:@"#999999"];
122 | //设置Y轴坐标字体大小
123 | _chartView.y_Font = [UIFont systemFontOfSize:10];
124 | //设置Y轴坐标字体颜色
125 | _chartView.y_Color = [UIColor colorWithHexString:@"#999999"];
126 | //设置背景颜色
127 | _chartView.backgroundColor = [UIColor whiteColor];
128 | //边框标线颜色
129 | _chartView.borderLineColor = [UIColor colorWithHexString:@"#999999"];
130 | //中间标线颜色
131 | _chartView.middleLineColor = [UIColor colorWithHexString:@"#cbcbcb" andAlpha:0.5];
132 | //边框三角颜色
133 | _chartView.borderTriangleColor = [UIColor colorWithHexString:@"#999999"];
134 | //设置泡泡背景颜色
135 | _chartView.paopaoBackGroundColor = [UIColor colorWithHexString:@"#000000" andAlpha:0.85];
136 | _chartView.markColor = [UIColor colorWithHexString:@"#333333"];
137 | //设置泡泡的标题颜色
138 | _chartView.paopaoTitleColor = [UIColor whiteColor];
139 | //设置折线样式
140 | _chartView.chartViewStyle = LHYChartViewLeftRightLine;
141 | //设置图层效果
142 | _chartView.chartLayerStyle = LHYChartGradient;
143 | //设置折现效果
144 | _chartView.lineLayerStyle = LHYLineLayerNone;
145 | _chartView.paopaoBackGroundColor = [UIColor colorWithHexString:@"#111111" andAlpha:0.8];
146 | //渐变效果的颜色组
147 | //渐变开始比例
148 | _chartView.proportion = 0.5;
149 | //折线图是否从零点开始画
150 | _chartView.hiddenZreo = NO;
151 | //折线为0的时候,不偏移
152 | _chartView.showChartOffset = NO;
153 | //设置颜色
154 | _chartView.leftColorStrArr = @[@"#00a1eb"];
155 | _chartView.rightColorStrArr = @[@"#6dd89c"];
156 | //显示折线为贝塞尔曲线
157 | _chartView.isShowBezier = YES;
158 | //折线图数据
159 | _chartView.leftDataArr = @[@[@"2500",@"3090",@"3201",@"3345",@"3006",@"3157",@"3069"]];
160 | _chartView.rightDataArr = @[@[@"89",@"70",@"92",@"88",@"100",@"60",@"77"]];
161 | //底部日期
162 | _chartView.dataArrOfX = @[@"周一",@"周二",@"周三",@"周四",@"周五",@"周六",@"周日"];
163 | //泡泡标题
164 | _chartView.paopaoTitleArray = @[@"周一",@"周二",@"周三",@"周四",@"周五",@"周六",@"周日"];
165 | //泡泡数据
166 | _chartView.paopaoDataArray = @[
167 | @[@"2500步",@"3090步",@"3201步",@"3345步",@"3006步",@"3157步",@"3069步"],
168 | @[@"89次/分钟",@"70次/分钟",@"92次/分钟",@"88次/分钟",@"100次/分钟",@"60次/分钟",@"77次/分钟"]
169 | ];
170 |
171 | //开始画图
172 | [_chartView show];
173 | }
174 | return _chartView;
175 | }
176 |
177 | -(void)addSecondChartView{
178 | [self.view addSubview:self.chartView];
179 | // LHYChartView *incomeChartLineView = [[LHYChartView alloc]initWithFrame:CGRectMake(20, 350, [UIScreen mainScreen].bounds.size.width - 40, 173)];
180 | // //是否默认选中第一个
181 | // incomeChartLineView.isShowFirstPaoPao = NO;
182 | // //是否有网格
183 | // incomeChartLineView.isGrid = YES;
184 | // //是否可以浮动
185 | // incomeChartLineView.isFloating = YES;
186 | // incomeChartLineView.isShowYtext = YES;
187 | // //显示多少行
188 | // incomeChartLineView.row = 5;
189 | // //显示多少列
190 | // incomeChartLineView.xRow = 32;
191 | // //设置X轴坐标字体大小
192 | // incomeChartLineView.x_Font = [UIFont systemFontOfSize:10];
193 | // //设置X轴坐标字体颜色
194 | // incomeChartLineView.x_Color = [UIColor colorWithHexString:@"#999999"];
195 | // //设置Y轴坐标字体大小
196 | // incomeChartLineView.y_Font = [UIFont systemFontOfSize:10];
197 | // //设置Y轴坐标字体颜色
198 | // incomeChartLineView.y_Color = [UIColor colorWithHexString:@"#999999"];
199 | // //设置背景颜色
200 | // incomeChartLineView.backgroundColor = [UIColor whiteColor];
201 | // //边框标线颜色
202 | // incomeChartLineView.borderLineColor = [UIColor colorWithHexString:@"#999999"];
203 | // //中间标线颜色
204 | // incomeChartLineView.middleLineColor = [UIColor colorWithHexString:@"#cbcbcb" andAlpha:0.5];
205 | // //边框三角颜色
206 | // incomeChartLineView.borderTriangleColor = [UIColor colorWithHexString:@"#999999"];
207 | // //设置泡泡背景颜色
208 | // incomeChartLineView.paopaoBackGroundColor = [UIColor colorWithHexString:@"#000000" andAlpha:0.85];
209 | // incomeChartLineView.markColor = [UIColor colorWithHexString:@"#333333"];
210 | // //设置泡泡的标题颜色
211 | // incomeChartLineView.paopaoTitleColor = [UIColor whiteColor];
212 | // //设置折线样式
213 | // incomeChartLineView.chartViewStyle = LHYChartViewMoreClickLine;
214 | // //设置图层效果
215 | // incomeChartLineView.chartLayerStyle = LHYChartGradient;
216 | // //设置折现效果
217 | // incomeChartLineView.lineLayerStyle = LHYLineLayerNone;
218 | // incomeChartLineView.paopaoBackGroundColor = [UIColor colorWithHexString:@"#111111" andAlpha:0.8];
219 | // //渐变效果的颜色组
220 | // //渐变开始比例
221 | // incomeChartLineView.proportion = 1;
222 | // //折线图是否从零点开始画
223 | // incomeChartLineView.hiddenZreo = YES;
224 | //
225 | // incomeChartLineView.colors = @[@"4b7ffe",@"4b7ffe"];
226 | //
227 | // //折线为0的时候,不偏移
228 | // incomeChartLineView.showChartOffset = NO;
229 | // //设置颜色
230 | // incomeChartLineView.leftColorStrArr = @[@"4b7ffe"];
231 | // //显示折线为直线
232 | // incomeChartLineView.isShowBezier = NO;
233 | // incomeChartLineView.lineWidth = 3;
234 | // incomeChartLineView.hiddenZreo = NO;
235 | // incomeChartLineView.paopaoFollowSliding = YES;
236 | // NSMutableArray *arr = [NSMutableArray array];
237 | // // for (NSInteger i = 0; i<31; i++) {
238 | // //// NSMutableDictionary *dict = [NSMutableDictionary dictionary];
239 | // // if(i%2 == 0){
240 | // // [arr addObject:[NSString stringWithFormat:@"%ld",i+4]];
241 | // //
242 | // // //[dict setObject:[NSString stringWithFormat:@"%ld",i] forKey:@"data"];
243 | // // }else{
244 | // // //[dict setObject:[NSString stringWithFormat:@"%ld",i+1] forKey:@"data"];
245 | // // [arr addObject:[NSString stringWithFormat:@"%ld",i+3]];
246 | // //
247 | // // }
248 | // ////
249 | // //// [dict setObject:@"咨询人数" forKey:@"detail"];
250 | // // //[arr addObject:[NSString stringWithFormat:@"%ld",i]];
251 | // //
252 | // // }
253 | // arr = [NSMutableArray arrayWithObjects:@"0",@"0",@"5",@"1",@"6",@"0",@"7",@"0",@"0",@"1",@"1",@"6",@"0",@"7",@"0",@"0",@"1",@"6",@"0",@"7",@"0",@"0",@"1",@"6",@"0",@"7",@"0",@"0",@"5", nil];
254 | // NSMutableArray * arr1 = [NSMutableArray array];
255 | // [arr1 addObject:arr];
256 | // incomeChartLineView.leftDataArr = arr1;
257 | // //折线图数据
258 | // // incomeChartLineView.leftDataArr = @[@[@"25000",@"30907",@"32010",@"33450",@"30069",@"31574",@"30692",@"33156",@"29808",@"31846",@"29772",@"29630",@"25000",@"30907",@"32010",@"33450",@"30069",@"31574",@"30692",@"33156",@"29808",@"31846",@"29772",@"29630",@"25000",@"30907",@"32010",@"33450",@"30069",@"31574",@"30692",@"33156"]];
259 | // //底部日期
260 | // incomeChartLineView.dataArrOfX = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"1",@"2",@"3",@"4",@"5",@"6"];
261 | // //泡泡标题
262 | // incomeChartLineView.paopaoTitleArray = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"1",@"2",@"3",@"4",@"5",@"6"];
263 | // //泡泡数据
264 | // incomeChartLineView.paopaoDataArray = @[@[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"1",@"2",@"3",@"4",@"5",@"6"]];
265 | // //开始画图
266 | // [incomeChartLineView show];
267 | // [self.view addSubview:incomeChartLineView];
268 | }
269 | @end
270 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/LHYLinesPaoPaoView.m:
--------------------------------------------------------------------------------
1 | //
2 | // YJYLinesPaoPaoView.m
3 | // YJYLinesView
4 | //
5 | // Created by lihaiyang on 2018/10/23.
6 | // Copyright © 2018 lihaiyang. All rights reserved.
7 | //
8 |
9 | #import "LHYLinesPaoPaoView.h"
10 | #import "LinesSelectCell.h"
11 | @interface LHYLinesPaoPaoView()
12 | @property (nonatomic,strong) UITableView *listTb;
13 | @property (assign, nonatomic) CGFloat maxLeftTitleWidth;
14 | @property (assign, nonatomic) CGFloat maxRightTitleWidth;
15 | /** 遮罩 */
16 | @property (nonatomic, strong) CAShapeLayer *maskLayer;
17 | /** 路径 */
18 | @property (nonatomic, strong) UIBezierPath *borderPath;
19 | @end
20 |
21 | @implementation LHYLinesPaoPaoView {
22 |
23 | NSArray *_dataArr;
24 |
25 | NSArray *_colorArr;
26 |
27 | }
28 | - (instancetype)initWithFrame:(CGRect)frame {
29 | self = [super initWithFrame:frame];
30 | if (self) {
31 | self.backgroundColor = [UIColor clearColor];
32 | _beyondLeft = NO;
33 | _beyondRight = NO;
34 | [self setUp];
35 | }
36 | return self;
37 | }
38 | - (instancetype)init {
39 | self = [super init];
40 | if (self) {
41 | [self setUp];
42 | }
43 | return self;
44 | }
45 | - (void)setUp {
46 | UIImageView *bgImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame))];
47 | bgImageView.backgroundColor = [UIColor clearColor];
48 | [self addSubview:bgImageView];
49 | // [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
50 | // make.top.left.bottom.right.equalTo(self);
51 | // }];
52 | [self addSubview:self.listTb];
53 | // [self.listTb mas_makeConstraints:^(MASConstraintMaker *make) {
54 | // make.top.left.bottom.right.equalTo(self);
55 | // }];
56 | }
57 |
58 | -(void)setFrame:(CGRect)frame{
59 | super.frame = frame;
60 | [self.listTb setFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame))];
61 | }
62 |
63 | - (void)show:(NSArray *)dataArr and:(NSString *)title andTitleColor:(UIColor *)titleColor colorArr:(NSArray *)color {
64 | self.maxLeftTitleWidth = 0;
65 | NSMutableArray *titleArray = [NSMutableArray array];
66 | for (int i = 0; i < dataArr.count; i++) {
67 | id obj = dataArr[i];
68 | NSMutableArray * marr = [NSMutableArray array];
69 | if ([obj isKindOfClass:[NSString class]]) {
70 | NSString *dataTitle = dataArr[i];
71 | float titleWidth= 0;
72 | titleWidth = [LHYLinesPaoPaoView measureSinglelineStringWidth:dataTitle andFont:[UIFont systemFontOfSize:13]];
73 | self.maxLeftTitleWidth = titleWidth + 5 > self.maxLeftTitleWidth ? titleWidth + 5 : self.maxLeftTitleWidth;
74 | [marr addObject:dataTitle];
75 | }else if([obj isKindOfClass:[NSArray class]]){
76 | NSArray * arr = obj;
77 | for (int o = 0 ; o < arr.count ; o++) {
78 | NSString * dataTitle = arr[o];
79 | float titleWidth= 0;
80 | if (o == 0) {
81 | titleWidth = [LHYLinesPaoPaoView measureSinglelineStringWidth:dataTitle andFont:[UIFont systemFontOfSize:13]];
82 | self.maxLeftTitleWidth = titleWidth + 5 > self.maxLeftTitleWidth ? titleWidth + 5 : self.maxLeftTitleWidth;
83 | }else{
84 | titleWidth = [LHYLinesPaoPaoView measureSinglelineStringWidth:dataTitle andFont:[UIFont systemFontOfSize:13]];
85 | self.maxRightTitleWidth = titleWidth + 5 > self.maxRightTitleWidth ? titleWidth + 5 : self.maxRightTitleWidth;
86 | }
87 | [marr addObject:dataTitle];
88 | }
89 | }
90 | [titleArray addObject:marr];
91 | }
92 | _dataArr = titleArray;
93 | _colorArr = color;
94 | if (title && title.length > 0) {
95 | UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame), 23.5)];
96 | UILabel * titleLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 6.5, CGRectGetWidth(view.frame) - 20, 17)];
97 | titleLab.font = [UIFont fontWithName:@"Helvetica-Bold" size:13];
98 | titleLab.textColor = [UIColor colorWithHexString:@"#d3d3d3"];
99 | titleLab.text = title;
100 | titleLab.textColor = titleColor;
101 | [view addSubview:titleLab];
102 | self.listTb.tableHeaderView = view;
103 | }else{
104 | UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame), 6.5)];
105 | self.listTb.tableHeaderView = view;
106 | }
107 | self.listTb.rowHeight = 17;
108 | [self.listTb reloadData];
109 | }
110 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
111 | return _dataArr.count;
112 | }
113 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
114 | LinesSelectCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LinesSelectCell"];
115 | if (!cell) {
116 | cell = [[LinesSelectCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"LinesSelectCell"];
117 | cell.selectionStyle = UITableViewCellSelectionStyleNone;
118 | cell.leftWidth = self.maxLeftTitleWidth;
119 | cell.rightWith = self.maxRightTitleWidth;
120 | }
121 | NSArray * arr = _dataArr[indexPath.row];
122 | if (arr.count == 1) {
123 | [cell showTitle:arr[0] andTitleColor:_colorArr[indexPath.row] andTitleFont:[UIFont fontWithName:@"Helvetica-Bold" size:13] andDescTile:nil andDescTileColor:nil andDescTitleFont:nil];
124 | }else if (arr.count == 2){
125 | [cell showTitle:arr[0] andTitleColor:_colorArr[indexPath.row] andTitleFont:[UIFont fontWithName:@"Helvetica-Bold" size:13] andDescTile:arr[1] andDescTileColor:_colorArr[indexPath.row] andDescTitleFont:[UIFont systemFontOfSize:12]];
126 | }
127 | return cell;
128 | }
129 | -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
130 | return 17;
131 | }
132 | +(CGSize)getWidthAndHeight:(NSArray *)dataArray{
133 | CGFloat width = 0;
134 | CGFloat height = 0;
135 | if (dataArray.count > 0) height = 17 * (dataArray.count + 1);
136 | for (int i = 0; i < dataArray.count; i++) {
137 | id obj = dataArray[i];
138 | if ([obj isKindOfClass:[NSString class]]) {
139 | float sizeWidth = [LHYLinesPaoPaoView measureSinglelineStringWidth:(NSString *)obj andFont:[UIFont systemFontOfSize:13]];
140 | sizeWidth = sizeWidth + 5 < 80 ? 80 : sizeWidth + 5;
141 | width = sizeWidth > width ? sizeWidth : width;
142 | }else if ([obj isKindOfClass:[NSArray class]]){
143 | NSArray * arr = obj;
144 | if (arr.count > 0) width += (arr.count - 1) * 10;
145 | for (int i = 0; i < arr.count; i++) {
146 | float sizeWidth = [LHYLinesPaoPaoView measureSinglelineStringWidth:(NSString *)obj andFont:[UIFont systemFontOfSize:13]];
147 | sizeWidth = sizeWidth + 5 < 80 ? 80 : sizeWidth + 5;
148 | width = sizeWidth > width ? sizeWidth : width;
149 | }
150 | }
151 | }
152 | if (width < 80) width = 80;
153 | width += 20;
154 | return CGSizeMake(width, height);
155 | }
156 | - (UITableView *)listTb {
157 | if (!_listTb) {
158 | _listTb = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame)) style:UITableViewStylePlain];
159 | _listTb.backgroundColor = [UIColor clearColor];
160 | _listTb.separatorStyle = UITableViewCellSeparatorStyleNone;
161 | _listTb.allowsSelection = NO;
162 | _listTb.bounces = NO;
163 | _listTb.dataSource = self;
164 | _listTb.delegate = self;
165 | // [self addSubview:_listTb];
166 | }
167 | return _listTb;
168 | }
169 | #pragma mark ---------画边框并填充颜色-------------
170 | -(void)drawBoxWithDirection:(Direction)direction{
171 | UIView * view = [[UIView alloc] initWithFrame:self.bounds];
172 | view.backgroundColor = self.backgroundColor;
173 | self.backgroundColor = [UIColor clearColor];
174 | [self addSubview:view];
175 | [self bringSubviewToFront:self.listTb];
176 | // 初始化遮罩
177 | self.maskLayer = [CAShapeLayer layer];
178 | // 设置遮罩
179 | [view.layer setMask:self.maskLayer];
180 | // 初始化路径
181 | self.borderPath = [UIBezierPath bezierPath];
182 | // 遮罩层frame
183 | self.maskLayer.frame = view.bounds;
184 | CGFloat pathX = 0;
185 | if (_beyondLeft) {
186 | pathX = _pointX;
187 | }else if (_beyondRight) {
188 | pathX = self.bounds.size.width - (self.chartContentWidth - _pointX);
189 | }else{
190 | pathX = self.bounds.size.width/2;
191 | }
192 | if (direction == directionTop) {
193 | CGRect frame = self.listTb.frame;
194 | frame.origin.y = 0;
195 | [self.listTb setFrame:frame];
196 | // [self.listTb mas_makeConstraints:^(MASConstraintMaker *make) {
197 | // make.top.mas_equalTo(0);
198 | // }];
199 | // 设置path起点
200 | [self.borderPath moveToPoint:CGPointMake(5, 5)];
201 | // 左上角的圆角
202 | [self.borderPath addQuadCurveToPoint:CGPointMake(10, 0) controlPoint:CGPointMake(5, 0)];
203 | // 直线,到右上角
204 | [self.borderPath addLineToPoint:CGPointMake(self.bounds.size.width - 10, 0)];
205 | // 右上角的圆角
206 | [self.borderPath addQuadCurveToPoint:CGPointMake(self.bounds.size.width -5, 5) controlPoint:CGPointMake(self.bounds.size.width - 5, 0)];
207 | // 直线,到右下角
208 | [self.borderPath addLineToPoint:CGPointMake(self.bounds.size.width - 5, self.bounds.size.height - 10)];
209 | // 右下角的圆角
210 | [self.borderPath addQuadCurveToPoint:CGPointMake(self.bounds.size.width - 10, self.bounds.size.height - 5) controlPoint:CGPointMake(self.bounds.size.width - 5, self.bounds.size.height - 5)];
211 | // 底部的小三角形
212 | [self.borderPath addLineToPoint:CGPointMake(pathX + 5, self.bounds.size.height - 5)];
213 | [self.borderPath addLineToPoint:CGPointMake(pathX, self.bounds.size.height)];
214 | [self.borderPath addLineToPoint:CGPointMake(pathX - 5, self.bounds.size.height - 5)];
215 |
216 | // 直线,到左下角
217 | [self.borderPath addLineToPoint:CGPointMake(10, self.bounds.size.height - 5)];
218 | // 左下角的圆角
219 | [self.borderPath addQuadCurveToPoint:CGPointMake(5, self.bounds.size.height - 10) controlPoint:CGPointMake(5, self.bounds.size.height - 5)];
220 | // 直线,回到起点
221 | [self.borderPath addLineToPoint:CGPointMake(5, 5)];
222 | }else{
223 | CGRect frame = self.listTb.frame;
224 | frame.origin.y = 5;
225 | [self.listTb setFrame:frame];
226 | // [self.listTb mas_makeConstraints:^(MASConstraintMaker *make) {
227 | // make.top.mas_equalTo(5);
228 | // }];
229 | // 设置path起点
230 | [self.borderPath moveToPoint:CGPointMake(5, 10)];
231 | // 左上角的圆角
232 | [self.borderPath addQuadCurveToPoint:CGPointMake(10, 5) controlPoint:CGPointMake(5, 5)];
233 | // 顶部的小三角形
234 | [self.borderPath addLineToPoint:CGPointMake(pathX - 5, 5)];
235 | [self.borderPath addLineToPoint:CGPointMake(pathX, 0)];
236 | [self.borderPath addLineToPoint:CGPointMake(pathX + 5, 5)];
237 | // 直线,到右上角
238 | [self.borderPath addLineToPoint:CGPointMake(self.bounds.size.width - 10, 5)];
239 | // 右上角的圆角
240 | [self.borderPath addQuadCurveToPoint:CGPointMake(self.bounds.size.width - 5, 10) controlPoint:CGPointMake(self.bounds.size.width - 5, 5)];
241 | // 直线,到右下角
242 | [self.borderPath addLineToPoint:CGPointMake(self.bounds.size.width - 5, self.bounds.size.height - 5)];
243 | // 右下角的圆角
244 | [self.borderPath addQuadCurveToPoint:CGPointMake(self.bounds.size.width - 10, self.bounds.size.height) controlPoint:CGPointMake(self.bounds.size.width - 5, self.bounds.size.height)];
245 | // 直线,到左下角
246 | [self.borderPath addLineToPoint:CGPointMake(10, self.bounds.size.height)];
247 | // 左下角的圆角
248 | [self.borderPath addQuadCurveToPoint:CGPointMake(5, self.bounds.size.height - 5) controlPoint:CGPointMake(5, self.bounds.size.height)];
249 | // 直线,回到起点
250 | [self.borderPath addLineToPoint:CGPointMake(5, 10)];
251 | }
252 | // 将这个path赋值给maskLayer的path
253 | self.maskLayer.path = self.borderPath.CGPath;
254 | }
255 |
256 | -(UIColor*)colorWithHexString:(NSString*)stringToConvert{
257 | if([stringToConvert hasPrefix:@"#"])
258 | {
259 | stringToConvert = [stringToConvert substringFromIndex:1];
260 | }
261 | NSScanner*scanner = [NSScanner scannerWithString:stringToConvert];
262 | unsigned hexNum;
263 | if(![scanner scanHexInt:&hexNum])
264 | {
265 | return nil;
266 | }
267 | return [UIColor colorWithRGBHex:hexNum];
268 | }
269 |
270 | - (UIColor *)colorWithRGBHex:(UInt32)hex {
271 | int r = (hex >> 16) & 0xFF;
272 | int g = (hex >> 8) & 0xFF;
273 | int b = (hex) & 0xFF;
274 |
275 | return [UIColor colorWithRed:r / 255.0f
276 | green:g / 255.0f
277 | blue:b / 255.0f
278 | alpha:1.0f];
279 | }
280 |
281 | + (float)measureSinglelineStringWidth:(NSString*)str andFont:(UIFont*)wordFont {
282 | if (str == nil) return 0;
283 | CGSize measureSize = [str boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingUsesFontLeading attributes:[NSDictionary dictionaryWithObjectsAndKeys:wordFont, NSFontAttributeName, nil] context:nil].size;
284 | return ceil(measureSize.width);
285 | }
286 |
287 | @end
288 |
--------------------------------------------------------------------------------
/chartTest/chartTest/category/UIColor/UIColor+expanded.m:
--------------------------------------------------------------------------------
1 | #import "UIColor+Expanded.h"
2 |
3 | /*
4 |
5 | Thanks to Poltras, Millenomi, Eridius, Nownot, WhatAHam, jberry,
6 | and everyone else who helped out but whose name is inadvertantly omitted
7 |
8 | */
9 |
10 | /*
11 | Current outstanding request list:
12 |
13 | - PolarBearFarm - color descriptions ([UIColor warmGrayWithHintOfBlueTouchOfRedAndSplashOfYellowColor])
14 | - Crayola color set
15 | - Eridius - UIColor needs a method that takes 2 colors and gives a third complementary one
16 | - Consider UIMutableColor that can be adjusted (brighter, cooler, warmer, thicker-alpha, etc)
17 | */
18 |
19 | /*
20 | FOR REFERENCE: Color Space Models: enum CGColorSpaceModel {
21 | kCGColorSpaceModelUnknown = -1,
22 | kCGColorSpaceModelMonochrome,
23 | kCGColorSpaceModelRGB,
24 | kCGColorSpaceModelCMYK,
25 | kCGColorSpaceModelLab,
26 | kCGColorSpaceModelDeviceN,
27 | kCGColorSpaceModelIndexed,
28 | kCGColorSpaceModelPattern
29 | };
30 | */
31 |
32 | // Static cache of looked up color names. Used with +colorWithName:
33 | static NSMutableDictionary *colorNameCache = nil;
34 |
35 | #if SUPPORTS_UNDOCUMENTED_API
36 | // UIColor_Undocumented
37 | // Undocumented methods of UIColor
38 | @interface UIColor (UIColor_Undocumented)
39 | - (NSString *)styleString;
40 | @end
41 | #endif // SUPPORTS_UNDOCUMENTED_API
42 |
43 | @interface UIColor (UIColor_Expanded_Support)
44 | + (UIColor *)searchForColorByName:(NSString *)cssColorName;
45 | @end
46 |
47 | #pragma mark -
48 |
49 | @implementation UIColor (UIColor_Expanded)
50 |
51 | - (CGColorSpaceModel)colorSpaceModel {
52 | return CGColorSpaceGetModel(CGColorGetColorSpace(self.CGColor));
53 | }
54 |
55 | - (NSString *)colorSpaceString {
56 | switch (self.colorSpaceModel) {
57 | case kCGColorSpaceModelUnknown:
58 | return @"kCGColorSpaceModelUnknown";
59 | case kCGColorSpaceModelMonochrome:
60 | return @"kCGColorSpaceModelMonochrome";
61 | case kCGColorSpaceModelRGB:
62 | return @"kCGColorSpaceModelRGB";
63 | case kCGColorSpaceModelCMYK:
64 | return @"kCGColorSpaceModelCMYK";
65 | case kCGColorSpaceModelLab:
66 | return @"kCGColorSpaceModelLab";
67 | case kCGColorSpaceModelDeviceN:
68 | return @"kCGColorSpaceModelDeviceN";
69 | case kCGColorSpaceModelIndexed:
70 | return @"kCGColorSpaceModelIndexed";
71 | case kCGColorSpaceModelPattern:
72 | return @"kCGColorSpaceModelPattern";
73 | default:
74 | return @"Not a valid color space";
75 | }
76 | }
77 |
78 | - (BOOL)canProvideRGBComponents {
79 | switch (self.colorSpaceModel) {
80 | case kCGColorSpaceModelRGB:
81 | case kCGColorSpaceModelMonochrome:
82 | return YES;
83 | default:
84 | return NO;
85 | }
86 | }
87 |
88 | - (NSArray *)arrayFromRGBAComponents {
89 | NSAssert(self.canProvideRGBComponents, @"Must be an RGB color to use -arrayFromRGBAComponents");
90 |
91 | CGFloat r,g,b,a;
92 | if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
93 |
94 | return [NSArray arrayWithObjects:
95 | [NSNumber numberWithFloat:r],
96 | [NSNumber numberWithFloat:g],
97 | [NSNumber numberWithFloat:b],
98 | [NSNumber numberWithFloat:a],
99 | nil];
100 | }
101 |
102 | - (BOOL)red:(CGFloat *)red green:(CGFloat *)green blue:(CGFloat *)blue alpha:(CGFloat *)alpha {
103 | const CGFloat *components = CGColorGetComponents(self.CGColor);
104 |
105 | CGFloat r,g,b,a;
106 |
107 | switch (self.colorSpaceModel) {
108 | case kCGColorSpaceModelMonochrome:
109 | r = g = b = components[0];
110 | a = components[1];
111 | break;
112 | case kCGColorSpaceModelRGB:
113 | r = components[0];
114 | g = components[1];
115 | b = components[2];
116 | a = components[3];
117 | break;
118 | default: // We don't know how to handle this model
119 | return NO;
120 | }
121 |
122 | if (red) *red = r;
123 | if (green) *green = g;
124 | if (blue) *blue = b;
125 | if (alpha) *alpha = a;
126 |
127 | return YES;
128 | }
129 |
130 | - (CGFloat)red {
131 | NSAssert(self.canProvideRGBComponents, @"Must be an RGB color to use -red");
132 | const CGFloat *c = CGColorGetComponents(self.CGColor);
133 | return c[0];
134 | }
135 |
136 | - (CGFloat)green {
137 | NSAssert(self.canProvideRGBComponents, @"Must be an RGB color to use -green");
138 | const CGFloat *c = CGColorGetComponents(self.CGColor);
139 | if (self.colorSpaceModel == kCGColorSpaceModelMonochrome) return c[0];
140 | return c[1];
141 | }
142 |
143 | - (CGFloat)blue {
144 | NSAssert(self.canProvideRGBComponents, @"Must be an RGB color to use -blue");
145 | const CGFloat *c = CGColorGetComponents(self.CGColor);
146 | if (self.colorSpaceModel == kCGColorSpaceModelMonochrome) return c[0];
147 | return c[2];
148 | }
149 |
150 | - (CGFloat)white {
151 | NSAssert(self.colorSpaceModel == kCGColorSpaceModelMonochrome, @"Must be a Monochrome color to use -white");
152 | const CGFloat *c = CGColorGetComponents(self.CGColor);
153 | return c[0];
154 | }
155 |
156 | - (CGFloat)alpha {
157 | return CGColorGetAlpha(self.CGColor);
158 | }
159 |
160 | - (UInt32)rgbHex {
161 | NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use rgbHex");
162 |
163 | CGFloat r,g,b,a;
164 | if (![self red:&r green:&g blue:&b alpha:&a]) return 0;
165 |
166 | r = MIN(MAX(self.red, 0.0f), 1.0f);
167 | g = MIN(MAX(self.green, 0.0f), 1.0f);
168 | b = MIN(MAX(self.blue, 0.0f), 1.0f);
169 |
170 | return (((int)roundf(r * 255)) << 16)
171 | | (((int)roundf(g * 255)) << 8)
172 | | (((int)roundf(b * 255)));
173 | }
174 |
175 | #pragma mark Arithmetic operations
176 |
177 | - (UIColor *)colorByLuminanceMapping {
178 | NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
179 |
180 | CGFloat r,g,b,a;
181 | if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
182 |
183 | // http://en.wikipedia.org/wiki/Luma_(video)
184 | // Y = 0.2126 R + 0.7152 G + 0.0722 B
185 | return [UIColor colorWithWhite:r*0.2126f + g*0.7152f + b*0.0722f
186 | alpha:a];
187 |
188 | }
189 |
190 | - (UIColor *)colorByMultiplyingByRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {
191 | NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
192 |
193 | CGFloat r,g,b,a;
194 | if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
195 |
196 | return [UIColor colorWithRed:MAX(0.0, MIN(1.0, r * red))
197 | green:MAX(0.0, MIN(1.0, g * green))
198 | blue:MAX(0.0, MIN(1.0, b * blue))
199 | alpha:MAX(0.0, MIN(1.0, a * alpha))];
200 | }
201 |
202 | - (UIColor *)colorByAddingRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {
203 | NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
204 |
205 | CGFloat r,g,b,a;
206 | if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
207 |
208 | return [UIColor colorWithRed:MAX(0.0, MIN(1.0, r + red))
209 | green:MAX(0.0, MIN(1.0, g + green))
210 | blue:MAX(0.0, MIN(1.0, b + blue))
211 | alpha:MAX(0.0, MIN(1.0, a + alpha))];
212 | }
213 |
214 | - (UIColor *)colorByLighteningToRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {
215 | NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
216 |
217 | CGFloat r,g,b,a;
218 | if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
219 |
220 | return [UIColor colorWithRed:MAX(r, red)
221 | green:MAX(g, green)
222 | blue:MAX(b, blue)
223 | alpha:MAX(a, alpha)];
224 | }
225 |
226 | - (UIColor *)colorByDarkeningToRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha {
227 | NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
228 |
229 | CGFloat r,g,b,a;
230 | if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
231 |
232 | return [UIColor colorWithRed:MIN(r, red)
233 | green:MIN(g, green)
234 | blue:MIN(b, blue)
235 | alpha:MIN(a, alpha)];
236 | }
237 |
238 | - (UIColor *)colorByMultiplyingBy:(CGFloat)f {
239 | return [self colorByMultiplyingByRed:f green:f blue:f alpha:1.0f];
240 | }
241 |
242 | - (UIColor *)colorByAdding:(CGFloat)f {
243 | return [self colorByMultiplyingByRed:f green:f blue:f alpha:0.0f];
244 | }
245 |
246 | - (UIColor *)colorByLighteningTo:(CGFloat)f {
247 | return [self colorByLighteningToRed:f green:f blue:f alpha:0.0f];
248 | }
249 |
250 | - (UIColor *)colorByDarkeningTo:(CGFloat)f {
251 | return [self colorByDarkeningToRed:f green:f blue:f alpha:1.0f];
252 | }
253 |
254 | - (UIColor *)colorByMultiplyingByColor:(UIColor *)color {
255 | NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
256 |
257 | CGFloat r,g,b,a;
258 | if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
259 |
260 | return [self colorByMultiplyingByRed:r green:g blue:b alpha:1.0f];
261 | }
262 |
263 | - (UIColor *)colorByAddingColor:(UIColor *)color {
264 | NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
265 |
266 | CGFloat r,g,b,a;
267 | if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
268 |
269 | return [self colorByAddingRed:r green:g blue:b alpha:0.0f];
270 | }
271 |
272 | - (UIColor *)colorByLighteningToColor:(UIColor *)color {
273 | NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
274 |
275 | CGFloat r,g,b,a;
276 | if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
277 |
278 | return [self colorByLighteningToRed:r green:g blue:b alpha:0.0f];
279 | }
280 |
281 | - (UIColor *)colorByDarkeningToColor:(UIColor *)color {
282 | NSAssert(self.canProvideRGBComponents, @"Must be a RGB color to use arithmatic operations");
283 |
284 | CGFloat r,g,b,a;
285 | if (![self red:&r green:&g blue:&b alpha:&a]) return nil;
286 |
287 | return [self colorByDarkeningToRed:r green:g blue:b alpha:1.0f];
288 | }
289 |
290 | #pragma mark String utilities
291 |
292 | - (NSString *)stringFromColor {
293 | NSAssert(self.canProvideRGBComponents, @"Must be an RGB color to use -stringFromColor");
294 | NSString *result;
295 | switch (self.colorSpaceModel) {
296 | case kCGColorSpaceModelRGB:
297 | result = [NSString stringWithFormat:@"{%0.3f, %0.3f, %0.3f, %0.3f}", self.red, self.green, self.blue, self.alpha];
298 | break;
299 | case kCGColorSpaceModelMonochrome:
300 | result = [NSString stringWithFormat:@"{%0.3f, %0.3f}", self.white, self.alpha];
301 | break;
302 | default:
303 | result = nil;
304 | }
305 | return result;
306 | }
307 |
308 | - (NSString *)hexStringFromColor {
309 | return [NSString stringWithFormat:@"%0.6X", (int)self.rgbHex];
310 | }
311 |
312 | - (BOOL)isDark{
313 | CGFloat gray = self.red * 0.299 + self.green * 0.587 + self.blue * 0.114;//纯白为1,纯黑为0
314 | return gray < 186.f/255;
315 | }
316 |
317 | + (UIColor *)colorWithString:(NSString *)stringToConvert {
318 | NSScanner *scanner = [NSScanner scannerWithString:stringToConvert];
319 | if (![scanner scanString:@"{" intoString:NULL]) return nil;
320 | const NSUInteger kMaxComponents = 4;
321 | CGFloat c[kMaxComponents];
322 | NSUInteger i = 0;
323 | if (![scanner scanFloat:(float *)&c[i++]]) return nil;
324 | while (1) {
325 | if ([scanner scanString:@"}" intoString:NULL]) break;
326 | if (i >= kMaxComponents) return nil;
327 | if ([scanner scanString:@"," intoString:NULL]) {
328 | if (![scanner scanFloat:(float *)&c[i++]]) return nil;
329 | } else {
330 | // either we're at the end of there's an unexpected character here
331 | // both cases are error conditions
332 | return nil;
333 | }
334 | }
335 | if (![scanner isAtEnd]) return nil;
336 | UIColor *color;
337 | switch (i) {
338 | case 2: // monochrome
339 | color = [UIColor colorWithWhite:c[0] alpha:c[1]];
340 | break;
341 | case 4: // RGB
342 | color = [UIColor colorWithRed:c[0] green:c[1] blue:c[2] alpha:c[3]];
343 | break;
344 | default:
345 | color = nil;
346 | }
347 | return color;
348 | }
349 |
350 | #pragma mark Class methods
351 |
352 | + (UIColor *)randomColor {
353 | return [UIColor colorWithRed:(arc4random()%256)/256.f
354 | green:(arc4random()%256)/256.f
355 | blue:(arc4random()%256)/256.f
356 | alpha:1.0f];
357 | }
358 |
359 | + (UIColor *)colorWithRGBHex:(UInt32)hex {
360 | int r = (hex >> 16) & 0xFF;
361 | int g = (hex >> 8) & 0xFF;
362 | int b = (hex) & 0xFF;
363 |
364 | return [UIColor colorWithRed:r / 255.0f
365 | green:g / 255.0f
366 | blue:b / 255.0f
367 | alpha:1.0f];
368 | }
369 |
370 | // Returns a UIColor by scanning the string for a hex number and passing that to +[UIColor colorWithRGBHex:]
371 | // Skips any leading whitespace and ignores any trailing characters
372 | +(UIColor*)colorWithHexString:(NSString*)stringToConvert{
373 | if([stringToConvert hasPrefix:@"#"])
374 | {
375 | stringToConvert = [stringToConvert substringFromIndex:1];
376 | }
377 | NSScanner*scanner = [NSScanner scannerWithString:stringToConvert];
378 | unsigned hexNum;
379 | if(![scanner scanHexInt:&hexNum])
380 | {
381 | return nil;
382 | }
383 | return [UIColor colorWithRGBHex:hexNum];
384 | }
385 |
386 | + (UIColor *)colorWithHexString:(NSString *)stringToConvert andAlpha:(CGFloat)alpha{
387 | UIColor *color = [UIColor colorWithHexString:stringToConvert];
388 | return [UIColor colorWithRed:color.red green:color.green blue:color.blue alpha:alpha];
389 | }
390 |
391 | // Lookup a color using css 3/svg color name
392 | + (UIColor *)colorWithName:(NSString *)cssColorName {
393 | UIColor *color;
394 | @synchronized(colorNameCache) {
395 | // Look for the color in the cache
396 | color = [colorNameCache objectForKey:cssColorName];
397 |
398 | if ((id)color == [NSNull null]) {
399 | // If it wasn't there previously, it's still not there now
400 | color = nil;
401 | } else if (!color) {
402 | // Color not in cache, so search for it now
403 | color = [self searchForColorByName:cssColorName];
404 |
405 | // Set the value in cache, storing NSNull on failure
406 | [colorNameCache setObject:(color ?: (id)[NSNull null])
407 | forKey:cssColorName];
408 | }
409 | }
410 |
411 | return color;
412 | }
413 |
414 | #pragma mark UIColor_Expanded initialization
415 |
416 | + (void)load {
417 | colorNameCache = [[NSMutableDictionary alloc] init];
418 | }
419 |
420 | @end
421 |
422 | #pragma mark -
423 |
424 | #if SUPPORTS_UNDOCUMENTED_API
425 | @implementation UIColor (UIColor_Undocumented_Expanded)
426 | - (NSString *)fetchStyleString {
427 | return [self styleString];
428 | }
429 |
430 | // Convert a color into RGB Color space, courtesy of Poltras
431 | // via http://ofcodeandmen.poltras.com/2009/01/22/convert-a-cgcolorref-to-another-cgcolorspaceref/
432 | //
433 | - (UIColor *)rgbColor {
434 | // Call to undocumented method "styleString".
435 | NSString *style = [self styleString];
436 | NSScanner *scanner = [NSScanner scannerWithString:style];
437 | CGFloat red, green, blue;
438 | if (![scanner scanString:@"rgb(" intoString:NULL]) return nil;
439 | if (![scanner scanFloat:&red]) return nil;
440 | if (![scanner scanString:@"," intoString:NULL]) return nil;
441 | if (![scanner scanFloat:&green]) return nil;
442 | if (![scanner scanString:@"," intoString:NULL]) return nil;
443 | if (![scanner scanFloat:&blue]) return nil;
444 | if (![scanner scanString:@")" intoString:NULL]) return nil;
445 | if (![scanner isAtEnd]) return nil;
446 |
447 | return [UIColor colorWithRed:red green:green blue:blue alpha:self.alpha];
448 | }
449 | @end
450 | #endif // SUPPORTS_UNDOCUMENTED_API
451 |
452 | @implementation UIColor (UIColor_Expanded_Support)
453 | /*
454 | * Database of color names and hex rgb values, derived
455 | * from the css 3 color spec:
456 | * http://www.w3.org/TR/css3-color/
457 | *
458 | * We think this is a very compact way of storing
459 | * this information, and relatively cheap to lookup.
460 | *
461 | * Note that we search for color names starting with ','
462 | * and terminated by '#', so that we don't get false matches.
463 | * For this reason, the database begins with ','.
464 | */
465 | static const char *colorNameDB = ","
466 | "aliceblue#f0f8ff,antiquewhite#faebd7,aqua#00ffff,aquamarine#7fffd4,azure#f0ffff,"
467 | "beige#f5f5dc,bisque#ffe4c4,black#000000,blanchedalmond#ffebcd,blue#0000ff,"
468 | "blueviolet#8a2be2,brown#a52a2a,burlywood#deb887,cadetblue#5f9ea0,chartreuse#7fff00,"
469 | "chocolate#d2691e,coral#ff7f50,cornflowerblue#6495ed,cornsilk#fff8dc,crimson#dc143c,"
470 | "cyan#00ffff,darkblue#00008b,darkcyan#008b8b,darkgoldenrod#b8860b,darkgray#a9a9a9,"
471 | "darkgreen#006400,darkgrey#a9a9a9,darkkhaki#bdb76b,darkmagenta#8b008b,"
472 | "darkolivegreen#556b2f,darkorange#ff8c00,darkorchid#9932cc,darkred#8b0000,"
473 | "darksalmon#e9967a,darkseagreen#8fbc8f,darkslateblue#483d8b,darkslategray#2f4f4f,"
474 | "darkslategrey#2f4f4f,darkturquoise#00ced1,darkviolet#9400d3,deeppink#ff1493,"
475 | "deepskyblue#00bfff,dimgray#696969,dimgrey#696969,dodgerblue#1e90ff,"
476 | "firebrick#b22222,floralwhite#fffaf0,forestgreen#228b22,fuchsia#ff00ff,"
477 | "gainsboro#dcdcdc,ghostwhite#f8f8ff,gold#ffd700,goldenrod#daa520,gray#808080,"
478 | "green#008000,greenyellow#adff2f,grey#808080,honeydew#f0fff0,hotpink#ff69b4,"
479 | "indianred#cd5c5c,indigo#4b0082,ivory#fffff0,khaki#f0e68c,lavender#e6e6fa,"
480 | "lavenderblush#fff0f5,lawngreen#7cfc00,lemonchiffon#fffacd,lightblue#add8e6,"
481 | "lightcoral#f08080,lightcyan#e0ffff,lightgoldenrodyellow#fafad2,lightgray#d3d3d3,"
482 | "lightgreen#90ee90,lightgrey#d3d3d3,lightpink#ffb6c1,lightsalmon#ffa07a,"
483 | "lightseagreen#20b2aa,lightskyblue#87cefa,lightslategray#778899,"
484 | "lightslategrey#778899,lightsteelblue#b0c4de,lightyellow#ffffe0,lime#00ff00,"
485 | "limegreen#32cd32,linen#faf0e6,magenta#ff00ff,maroon#800000,mediumaquamarine#66cdaa,"
486 | "mediumblue#0000cd,mediumorchid#ba55d3,mediumpurple#9370db,mediumseagreen#3cb371,"
487 | "mediumslateblue#7b68ee,mediumspringgreen#00fa9a,mediumturquoise#48d1cc,"
488 | "mediumvioletred#c71585,midnightblue#191970,mintcream#f5fffa,mistyrose#ffe4e1,"
489 | "moccasin#ffe4b5,navajowhite#ffdead,navy#000080,oldlace#fdf5e6,olive#808000,"
490 | "olivedrab#6b8e23,orange#ffa500,orangered#ff4500,orchid#da70d6,palegoldenrod#eee8aa,"
491 | "palegreen#98fb98,paleturquoise#afeeee,palevioletred#db7093,papayawhip#ffefd5,"
492 | "peachpuff#ffdab9,peru#cd853f,pink#ffc0cb,plum#dda0dd,powderblue#b0e0e6,"
493 | "purple#800080,red#ff0000,rosybrown#bc8f8f,royalblue#4169e1,saddlebrown#8b4513,"
494 | "salmon#fa8072,sandybrown#f4a460,seagreen#2e8b57,seashell#fff5ee,sienna#a0522d,"
495 | "silver#c0c0c0,skyblue#87ceeb,slateblue#6a5acd,slategray#708090,slategrey#708090,"
496 | "snow#fffafa,springgreen#00ff7f,steelblue#4682b4,tan#d2b48c,teal#008080,"
497 | "thistle#d8bfd8,tomato#ff6347,turquoise#40e0d0,violet#ee82ee,wheat#f5deb3,"
498 | "white#ffffff,whitesmoke#f5f5f5,yellow#ffff00,yellowgreen#9acd32";
499 |
500 | + (UIColor *)searchForColorByName:(NSString *)cssColorName {
501 | UIColor *result = nil;
502 |
503 | // Compile the string we'll use to search against the database
504 | // We search for ",#" to avoid false matches
505 | const char *searchString = [[NSString stringWithFormat:@",%@#", cssColorName] UTF8String];
506 |
507 | // Search for the color name
508 | const char *found = strstr(colorNameDB, searchString);
509 |
510 | // If found, step past the search string and grab the hex representation
511 | if (found) {
512 | const char *after = found + strlen(searchString);
513 | int hex;
514 | if (sscanf(after, "%x", &hex) == 1) {
515 | result = [self colorWithRGBHex:hex];
516 | }
517 | }
518 |
519 | return result;
520 | }
521 | @end
522 |
--------------------------------------------------------------------------------
/chartTest/chartTest.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | C80D9489217F1F230004AEE1 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C80D9488217F1F230004AEE1 /* AppDelegate.m */; };
11 | C80D948C217F1F230004AEE1 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C80D948B217F1F230004AEE1 /* ViewController.m */; };
12 | C80D948F217F1F230004AEE1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C80D948D217F1F230004AEE1 /* Main.storyboard */; };
13 | C80D9491217F1F240004AEE1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C80D9490217F1F240004AEE1 /* Assets.xcassets */; };
14 | C80D9494217F1F240004AEE1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C80D9492217F1F240004AEE1 /* LaunchScreen.storyboard */; };
15 | C80D9497217F1F240004AEE1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C80D9496217F1F240004AEE1 /* main.m */; };
16 | C80D94A1217F1F240004AEE1 /* chartTestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C80D94A0217F1F240004AEE1 /* chartTestTests.m */; };
17 | C80D94AC217F1F240004AEE1 /* chartTestUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = C80D94AB217F1F240004AEE1 /* chartTestUITests.m */; };
18 | C80D94C7217F1F410004AEE1 /* YJYLinesCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C80D94BA217F1F400004AEE1 /* YJYLinesCell.m */; };
19 | C80D94C8217F1F410004AEE1 /* LHYLinesPaoPaoView.m in Sources */ = {isa = PBXBuildFile; fileRef = C80D94BE217F1F400004AEE1 /* LHYLinesPaoPaoView.m */; };
20 | C80D94C9217F1F410004AEE1 /* LHYChartView.m in Sources */ = {isa = PBXBuildFile; fileRef = C80D94BF217F1F400004AEE1 /* LHYChartView.m */; };
21 | C80D94CA217F1F410004AEE1 /* LinesSelectCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C80D94C0217F1F400004AEE1 /* LinesSelectCell.m */; };
22 | C80D94CB217F1F410004AEE1 /* YJYTouchCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = C80D94C1217F1F400004AEE1 /* YJYTouchCollectionView.m */; };
23 | C80D94CC217F1F410004AEE1 /* YJYTouchScroll.m in Sources */ = {isa = PBXBuildFile; fileRef = C80D94C3217F1F400004AEE1 /* YJYTouchScroll.m */; };
24 | C80D94CD217F1F410004AEE1 /* YJYLinesCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C80D94C5217F1F400004AEE1 /* YJYLinesCell.xib */; };
25 | C8A1491A224489B200DA0981 /* UIColor+expanded.m in Sources */ = {isa = PBXBuildFile; fileRef = C8A14919224489B200DA0981 /* UIColor+expanded.m */; };
26 | C8A1492622448A1500DA0981 /* NSString+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = C8A1492222448A1500DA0981 /* NSString+Extension.m */; };
27 | /* End PBXBuildFile section */
28 |
29 | /* Begin PBXContainerItemProxy section */
30 | C80D949D217F1F240004AEE1 /* PBXContainerItemProxy */ = {
31 | isa = PBXContainerItemProxy;
32 | containerPortal = C80D947C217F1F230004AEE1 /* Project object */;
33 | proxyType = 1;
34 | remoteGlobalIDString = C80D9483217F1F230004AEE1;
35 | remoteInfo = chartTest;
36 | };
37 | C80D94A8217F1F240004AEE1 /* PBXContainerItemProxy */ = {
38 | isa = PBXContainerItemProxy;
39 | containerPortal = C80D947C217F1F230004AEE1 /* Project object */;
40 | proxyType = 1;
41 | remoteGlobalIDString = C80D9483217F1F230004AEE1;
42 | remoteInfo = chartTest;
43 | };
44 | /* End PBXContainerItemProxy section */
45 |
46 | /* Begin PBXFileReference section */
47 | C80D9484217F1F230004AEE1 /* chartTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = chartTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
48 | C80D9487217F1F230004AEE1 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
49 | C80D9488217F1F230004AEE1 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
50 | C80D948A217F1F230004AEE1 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
51 | C80D948B217F1F230004AEE1 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
52 | C80D948E217F1F230004AEE1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
53 | C80D9490217F1F240004AEE1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
54 | C80D9493217F1F240004AEE1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
55 | C80D9495217F1F240004AEE1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
56 | C80D9496217F1F240004AEE1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
57 | C80D949C217F1F240004AEE1 /* chartTestTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = chartTestTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
58 | C80D94A0217F1F240004AEE1 /* chartTestTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = chartTestTests.m; sourceTree = ""; };
59 | C80D94A2217F1F240004AEE1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
60 | C80D94A7217F1F240004AEE1 /* chartTestUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = chartTestUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
61 | C80D94AB217F1F240004AEE1 /* chartTestUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = chartTestUITests.m; sourceTree = ""; };
62 | C80D94AD217F1F240004AEE1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
63 | C80D94BA217F1F400004AEE1 /* YJYLinesCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YJYLinesCell.m; sourceTree = ""; };
64 | C80D94BB217F1F400004AEE1 /* YJYTouchCollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YJYTouchCollectionView.h; sourceTree = ""; };
65 | C80D94BC217F1F400004AEE1 /* LinesSelectCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinesSelectCell.h; sourceTree = ""; };
66 | C80D94BD217F1F400004AEE1 /* YJYTouchScroll.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YJYTouchScroll.h; sourceTree = ""; };
67 | C80D94BE217F1F400004AEE1 /* LHYLinesPaoPaoView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LHYLinesPaoPaoView.m; sourceTree = ""; };
68 | C80D94BF217F1F400004AEE1 /* LHYChartView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LHYChartView.m; sourceTree = ""; };
69 | C80D94C0217F1F400004AEE1 /* LinesSelectCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LinesSelectCell.m; sourceTree = ""; };
70 | C80D94C1217F1F400004AEE1 /* YJYTouchCollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YJYTouchCollectionView.m; sourceTree = ""; };
71 | C80D94C2217F1F400004AEE1 /* YJYLinesCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YJYLinesCell.h; sourceTree = ""; };
72 | C80D94C3217F1F400004AEE1 /* YJYTouchScroll.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YJYTouchScroll.m; sourceTree = ""; };
73 | C80D94C4217F1F400004AEE1 /* LHYLinesPaoPaoView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LHYLinesPaoPaoView.h; sourceTree = ""; };
74 | C80D94C5217F1F400004AEE1 /* YJYLinesCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = YJYLinesCell.xib; sourceTree = ""; };
75 | C80D94C6217F1F400004AEE1 /* LHYChartView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LHYChartView.h; sourceTree = ""; };
76 | C8A14918224489B200DA0981 /* UIColor+expanded.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+expanded.h"; sourceTree = ""; };
77 | C8A14919224489B200DA0981 /* UIColor+expanded.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+expanded.m"; sourceTree = ""; };
78 | C8A1491D22448A1500DA0981 /* NSString+Extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Extension.h"; sourceTree = ""; };
79 | C8A1492222448A1500DA0981 /* NSString+Extension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Extension.m"; sourceTree = ""; };
80 | /* End PBXFileReference section */
81 |
82 | /* Begin PBXFrameworksBuildPhase section */
83 | C80D9481217F1F230004AEE1 /* Frameworks */ = {
84 | isa = PBXFrameworksBuildPhase;
85 | buildActionMask = 2147483647;
86 | files = (
87 | );
88 | runOnlyForDeploymentPostprocessing = 0;
89 | };
90 | C80D9499217F1F240004AEE1 /* Frameworks */ = {
91 | isa = PBXFrameworksBuildPhase;
92 | buildActionMask = 2147483647;
93 | files = (
94 | );
95 | runOnlyForDeploymentPostprocessing = 0;
96 | };
97 | C80D94A4217F1F240004AEE1 /* Frameworks */ = {
98 | isa = PBXFrameworksBuildPhase;
99 | buildActionMask = 2147483647;
100 | files = (
101 | );
102 | runOnlyForDeploymentPostprocessing = 0;
103 | };
104 | /* End PBXFrameworksBuildPhase section */
105 |
106 | /* Begin PBXGroup section */
107 | C80D947B217F1F230004AEE1 = {
108 | isa = PBXGroup;
109 | children = (
110 | C80D9486217F1F230004AEE1 /* chartTest */,
111 | C80D949F217F1F240004AEE1 /* chartTestTests */,
112 | C80D94AA217F1F240004AEE1 /* chartTestUITests */,
113 | C80D9485217F1F230004AEE1 /* Products */,
114 | );
115 | sourceTree = "";
116 | };
117 | C80D9485217F1F230004AEE1 /* Products */ = {
118 | isa = PBXGroup;
119 | children = (
120 | C80D9484217F1F230004AEE1 /* chartTest.app */,
121 | C80D949C217F1F240004AEE1 /* chartTestTests.xctest */,
122 | C80D94A7217F1F240004AEE1 /* chartTestUITests.xctest */,
123 | );
124 | name = Products;
125 | sourceTree = "";
126 | };
127 | C80D9486217F1F230004AEE1 /* chartTest */ = {
128 | isa = PBXGroup;
129 | children = (
130 | C8A14916224489B200DA0981 /* category */,
131 | C80D9487217F1F230004AEE1 /* AppDelegate.h */,
132 | C80D9488217F1F230004AEE1 /* AppDelegate.m */,
133 | C80D948A217F1F230004AEE1 /* ViewController.h */,
134 | C80D948B217F1F230004AEE1 /* ViewController.m */,
135 | C80D94B9217F1F400004AEE1 /* charView */,
136 | C80D948D217F1F230004AEE1 /* Main.storyboard */,
137 | C80D9490217F1F240004AEE1 /* Assets.xcassets */,
138 | C80D9492217F1F240004AEE1 /* LaunchScreen.storyboard */,
139 | C80D9495217F1F240004AEE1 /* Info.plist */,
140 | C80D9496217F1F240004AEE1 /* main.m */,
141 | );
142 | path = chartTest;
143 | sourceTree = "";
144 | };
145 | C80D949F217F1F240004AEE1 /* chartTestTests */ = {
146 | isa = PBXGroup;
147 | children = (
148 | C80D94A0217F1F240004AEE1 /* chartTestTests.m */,
149 | C80D94A2217F1F240004AEE1 /* Info.plist */,
150 | );
151 | path = chartTestTests;
152 | sourceTree = "";
153 | };
154 | C80D94AA217F1F240004AEE1 /* chartTestUITests */ = {
155 | isa = PBXGroup;
156 | children = (
157 | C80D94AB217F1F240004AEE1 /* chartTestUITests.m */,
158 | C80D94AD217F1F240004AEE1 /* Info.plist */,
159 | );
160 | path = chartTestUITests;
161 | sourceTree = "";
162 | };
163 | C80D94B9217F1F400004AEE1 /* charView */ = {
164 | isa = PBXGroup;
165 | children = (
166 | C80D94C6217F1F400004AEE1 /* LHYChartView.h */,
167 | C80D94BF217F1F400004AEE1 /* LHYChartView.m */,
168 | C80D94C2217F1F400004AEE1 /* YJYLinesCell.h */,
169 | C80D94BA217F1F400004AEE1 /* YJYLinesCell.m */,
170 | C80D94C5217F1F400004AEE1 /* YJYLinesCell.xib */,
171 | C80D94BC217F1F400004AEE1 /* LinesSelectCell.h */,
172 | C80D94C0217F1F400004AEE1 /* LinesSelectCell.m */,
173 | C80D94C4217F1F400004AEE1 /* LHYLinesPaoPaoView.h */,
174 | C80D94BE217F1F400004AEE1 /* LHYLinesPaoPaoView.m */,
175 | C80D94BB217F1F400004AEE1 /* YJYTouchCollectionView.h */,
176 | C80D94C1217F1F400004AEE1 /* YJYTouchCollectionView.m */,
177 | C80D94BD217F1F400004AEE1 /* YJYTouchScroll.h */,
178 | C80D94C3217F1F400004AEE1 /* YJYTouchScroll.m */,
179 | );
180 | path = charView;
181 | sourceTree = "";
182 | };
183 | C8A14916224489B200DA0981 /* category */ = {
184 | isa = PBXGroup;
185 | children = (
186 | C8A1491B22448A1500DA0981 /* NSString */,
187 | C8A14917224489B200DA0981 /* UIColor */,
188 | );
189 | path = category;
190 | sourceTree = "";
191 | };
192 | C8A14917224489B200DA0981 /* UIColor */ = {
193 | isa = PBXGroup;
194 | children = (
195 | C8A14918224489B200DA0981 /* UIColor+expanded.h */,
196 | C8A14919224489B200DA0981 /* UIColor+expanded.m */,
197 | );
198 | path = UIColor;
199 | sourceTree = "";
200 | };
201 | C8A1491B22448A1500DA0981 /* NSString */ = {
202 | isa = PBXGroup;
203 | children = (
204 | C8A1491D22448A1500DA0981 /* NSString+Extension.h */,
205 | C8A1492222448A1500DA0981 /* NSString+Extension.m */,
206 | );
207 | path = NSString;
208 | sourceTree = "";
209 | };
210 | /* End PBXGroup section */
211 |
212 | /* Begin PBXNativeTarget section */
213 | C80D9483217F1F230004AEE1 /* chartTest */ = {
214 | isa = PBXNativeTarget;
215 | buildConfigurationList = C80D94B0217F1F240004AEE1 /* Build configuration list for PBXNativeTarget "chartTest" */;
216 | buildPhases = (
217 | C80D9480217F1F230004AEE1 /* Sources */,
218 | C80D9481217F1F230004AEE1 /* Frameworks */,
219 | C80D9482217F1F230004AEE1 /* Resources */,
220 | );
221 | buildRules = (
222 | );
223 | dependencies = (
224 | );
225 | name = chartTest;
226 | productName = chartTest;
227 | productReference = C80D9484217F1F230004AEE1 /* chartTest.app */;
228 | productType = "com.apple.product-type.application";
229 | };
230 | C80D949B217F1F240004AEE1 /* chartTestTests */ = {
231 | isa = PBXNativeTarget;
232 | buildConfigurationList = C80D94B3217F1F240004AEE1 /* Build configuration list for PBXNativeTarget "chartTestTests" */;
233 | buildPhases = (
234 | C80D9498217F1F240004AEE1 /* Sources */,
235 | C80D9499217F1F240004AEE1 /* Frameworks */,
236 | C80D949A217F1F240004AEE1 /* Resources */,
237 | );
238 | buildRules = (
239 | );
240 | dependencies = (
241 | C80D949E217F1F240004AEE1 /* PBXTargetDependency */,
242 | );
243 | name = chartTestTests;
244 | productName = chartTestTests;
245 | productReference = C80D949C217F1F240004AEE1 /* chartTestTests.xctest */;
246 | productType = "com.apple.product-type.bundle.unit-test";
247 | };
248 | C80D94A6217F1F240004AEE1 /* chartTestUITests */ = {
249 | isa = PBXNativeTarget;
250 | buildConfigurationList = C80D94B6217F1F240004AEE1 /* Build configuration list for PBXNativeTarget "chartTestUITests" */;
251 | buildPhases = (
252 | C80D94A3217F1F240004AEE1 /* Sources */,
253 | C80D94A4217F1F240004AEE1 /* Frameworks */,
254 | C80D94A5217F1F240004AEE1 /* Resources */,
255 | );
256 | buildRules = (
257 | );
258 | dependencies = (
259 | C80D94A9217F1F240004AEE1 /* PBXTargetDependency */,
260 | );
261 | name = chartTestUITests;
262 | productName = chartTestUITests;
263 | productReference = C80D94A7217F1F240004AEE1 /* chartTestUITests.xctest */;
264 | productType = "com.apple.product-type.bundle.ui-testing";
265 | };
266 | /* End PBXNativeTarget section */
267 |
268 | /* Begin PBXProject section */
269 | C80D947C217F1F230004AEE1 /* Project object */ = {
270 | isa = PBXProject;
271 | attributes = {
272 | LastUpgradeCheck = 1000;
273 | ORGANIZATIONNAME = lihaiyang;
274 | TargetAttributes = {
275 | C80D9483217F1F230004AEE1 = {
276 | CreatedOnToolsVersion = 10.0;
277 | };
278 | C80D949B217F1F240004AEE1 = {
279 | CreatedOnToolsVersion = 10.0;
280 | TestTargetID = C80D9483217F1F230004AEE1;
281 | };
282 | C80D94A6217F1F240004AEE1 = {
283 | CreatedOnToolsVersion = 10.0;
284 | TestTargetID = C80D9483217F1F230004AEE1;
285 | };
286 | };
287 | };
288 | buildConfigurationList = C80D947F217F1F230004AEE1 /* Build configuration list for PBXProject "chartTest" */;
289 | compatibilityVersion = "Xcode 9.3";
290 | developmentRegion = en;
291 | hasScannedForEncodings = 0;
292 | knownRegions = (
293 | en,
294 | Base,
295 | );
296 | mainGroup = C80D947B217F1F230004AEE1;
297 | productRefGroup = C80D9485217F1F230004AEE1 /* Products */;
298 | projectDirPath = "";
299 | projectRoot = "";
300 | targets = (
301 | C80D9483217F1F230004AEE1 /* chartTest */,
302 | C80D949B217F1F240004AEE1 /* chartTestTests */,
303 | C80D94A6217F1F240004AEE1 /* chartTestUITests */,
304 | );
305 | };
306 | /* End PBXProject section */
307 |
308 | /* Begin PBXResourcesBuildPhase section */
309 | C80D9482217F1F230004AEE1 /* Resources */ = {
310 | isa = PBXResourcesBuildPhase;
311 | buildActionMask = 2147483647;
312 | files = (
313 | C80D94CD217F1F410004AEE1 /* YJYLinesCell.xib in Resources */,
314 | C80D9494217F1F240004AEE1 /* LaunchScreen.storyboard in Resources */,
315 | C80D9491217F1F240004AEE1 /* Assets.xcassets in Resources */,
316 | C80D948F217F1F230004AEE1 /* Main.storyboard in Resources */,
317 | );
318 | runOnlyForDeploymentPostprocessing = 0;
319 | };
320 | C80D949A217F1F240004AEE1 /* Resources */ = {
321 | isa = PBXResourcesBuildPhase;
322 | buildActionMask = 2147483647;
323 | files = (
324 | );
325 | runOnlyForDeploymentPostprocessing = 0;
326 | };
327 | C80D94A5217F1F240004AEE1 /* Resources */ = {
328 | isa = PBXResourcesBuildPhase;
329 | buildActionMask = 2147483647;
330 | files = (
331 | );
332 | runOnlyForDeploymentPostprocessing = 0;
333 | };
334 | /* End PBXResourcesBuildPhase section */
335 |
336 | /* Begin PBXSourcesBuildPhase section */
337 | C80D9480217F1F230004AEE1 /* Sources */ = {
338 | isa = PBXSourcesBuildPhase;
339 | buildActionMask = 2147483647;
340 | files = (
341 | C8A1491A224489B200DA0981 /* UIColor+expanded.m in Sources */,
342 | C80D94C7217F1F410004AEE1 /* YJYLinesCell.m in Sources */,
343 | C80D94CB217F1F410004AEE1 /* YJYTouchCollectionView.m in Sources */,
344 | C80D948C217F1F230004AEE1 /* ViewController.m in Sources */,
345 | C80D94CC217F1F410004AEE1 /* YJYTouchScroll.m in Sources */,
346 | C8A1492622448A1500DA0981 /* NSString+Extension.m in Sources */,
347 | C80D9497217F1F240004AEE1 /* main.m in Sources */,
348 | C80D9489217F1F230004AEE1 /* AppDelegate.m in Sources */,
349 | C80D94CA217F1F410004AEE1 /* LinesSelectCell.m in Sources */,
350 | C80D94C8217F1F410004AEE1 /* LHYLinesPaoPaoView.m in Sources */,
351 | C80D94C9217F1F410004AEE1 /* LHYChartView.m in Sources */,
352 | );
353 | runOnlyForDeploymentPostprocessing = 0;
354 | };
355 | C80D9498217F1F240004AEE1 /* Sources */ = {
356 | isa = PBXSourcesBuildPhase;
357 | buildActionMask = 2147483647;
358 | files = (
359 | C80D94A1217F1F240004AEE1 /* chartTestTests.m in Sources */,
360 | );
361 | runOnlyForDeploymentPostprocessing = 0;
362 | };
363 | C80D94A3217F1F240004AEE1 /* Sources */ = {
364 | isa = PBXSourcesBuildPhase;
365 | buildActionMask = 2147483647;
366 | files = (
367 | C80D94AC217F1F240004AEE1 /* chartTestUITests.m in Sources */,
368 | );
369 | runOnlyForDeploymentPostprocessing = 0;
370 | };
371 | /* End PBXSourcesBuildPhase section */
372 |
373 | /* Begin PBXTargetDependency section */
374 | C80D949E217F1F240004AEE1 /* PBXTargetDependency */ = {
375 | isa = PBXTargetDependency;
376 | target = C80D9483217F1F230004AEE1 /* chartTest */;
377 | targetProxy = C80D949D217F1F240004AEE1 /* PBXContainerItemProxy */;
378 | };
379 | C80D94A9217F1F240004AEE1 /* PBXTargetDependency */ = {
380 | isa = PBXTargetDependency;
381 | target = C80D9483217F1F230004AEE1 /* chartTest */;
382 | targetProxy = C80D94A8217F1F240004AEE1 /* PBXContainerItemProxy */;
383 | };
384 | /* End PBXTargetDependency section */
385 |
386 | /* Begin PBXVariantGroup section */
387 | C80D948D217F1F230004AEE1 /* Main.storyboard */ = {
388 | isa = PBXVariantGroup;
389 | children = (
390 | C80D948E217F1F230004AEE1 /* Base */,
391 | );
392 | name = Main.storyboard;
393 | sourceTree = "";
394 | };
395 | C80D9492217F1F240004AEE1 /* LaunchScreen.storyboard */ = {
396 | isa = PBXVariantGroup;
397 | children = (
398 | C80D9493217F1F240004AEE1 /* Base */,
399 | );
400 | name = LaunchScreen.storyboard;
401 | sourceTree = "";
402 | };
403 | /* End PBXVariantGroup section */
404 |
405 | /* Begin XCBuildConfiguration section */
406 | C80D94AE217F1F240004AEE1 /* Debug */ = {
407 | isa = XCBuildConfiguration;
408 | buildSettings = {
409 | ALWAYS_SEARCH_USER_PATHS = NO;
410 | CLANG_ANALYZER_NONNULL = YES;
411 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
412 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
413 | CLANG_CXX_LIBRARY = "libc++";
414 | CLANG_ENABLE_MODULES = YES;
415 | CLANG_ENABLE_OBJC_ARC = YES;
416 | CLANG_ENABLE_OBJC_WEAK = YES;
417 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
418 | CLANG_WARN_BOOL_CONVERSION = YES;
419 | CLANG_WARN_COMMA = YES;
420 | CLANG_WARN_CONSTANT_CONVERSION = YES;
421 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
422 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
423 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
424 | CLANG_WARN_EMPTY_BODY = YES;
425 | CLANG_WARN_ENUM_CONVERSION = YES;
426 | CLANG_WARN_INFINITE_RECURSION = YES;
427 | CLANG_WARN_INT_CONVERSION = YES;
428 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
429 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
430 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
431 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
432 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
433 | CLANG_WARN_STRICT_PROTOTYPES = YES;
434 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
435 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
436 | CLANG_WARN_UNREACHABLE_CODE = YES;
437 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
438 | CODE_SIGN_IDENTITY = "iPhone Developer";
439 | COPY_PHASE_STRIP = NO;
440 | DEBUG_INFORMATION_FORMAT = dwarf;
441 | ENABLE_STRICT_OBJC_MSGSEND = YES;
442 | ENABLE_TESTABILITY = YES;
443 | GCC_C_LANGUAGE_STANDARD = gnu11;
444 | GCC_DYNAMIC_NO_PIC = NO;
445 | GCC_NO_COMMON_BLOCKS = YES;
446 | GCC_OPTIMIZATION_LEVEL = 0;
447 | GCC_PREPROCESSOR_DEFINITIONS = (
448 | "DEBUG=1",
449 | "$(inherited)",
450 | );
451 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
452 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
453 | GCC_WARN_UNDECLARED_SELECTOR = YES;
454 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
455 | GCC_WARN_UNUSED_FUNCTION = YES;
456 | GCC_WARN_UNUSED_VARIABLE = YES;
457 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
458 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
459 | MTL_FAST_MATH = YES;
460 | ONLY_ACTIVE_ARCH = YES;
461 | SDKROOT = iphoneos;
462 | };
463 | name = Debug;
464 | };
465 | C80D94AF217F1F240004AEE1 /* Release */ = {
466 | isa = XCBuildConfiguration;
467 | buildSettings = {
468 | ALWAYS_SEARCH_USER_PATHS = NO;
469 | CLANG_ANALYZER_NONNULL = YES;
470 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
471 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
472 | CLANG_CXX_LIBRARY = "libc++";
473 | CLANG_ENABLE_MODULES = YES;
474 | CLANG_ENABLE_OBJC_ARC = YES;
475 | CLANG_ENABLE_OBJC_WEAK = YES;
476 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
477 | CLANG_WARN_BOOL_CONVERSION = YES;
478 | CLANG_WARN_COMMA = YES;
479 | CLANG_WARN_CONSTANT_CONVERSION = YES;
480 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
481 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
482 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
483 | CLANG_WARN_EMPTY_BODY = YES;
484 | CLANG_WARN_ENUM_CONVERSION = YES;
485 | CLANG_WARN_INFINITE_RECURSION = YES;
486 | CLANG_WARN_INT_CONVERSION = YES;
487 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
488 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
489 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
490 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
491 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
492 | CLANG_WARN_STRICT_PROTOTYPES = YES;
493 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
494 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
495 | CLANG_WARN_UNREACHABLE_CODE = YES;
496 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
497 | CODE_SIGN_IDENTITY = "iPhone Developer";
498 | COPY_PHASE_STRIP = NO;
499 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
500 | ENABLE_NS_ASSERTIONS = NO;
501 | ENABLE_STRICT_OBJC_MSGSEND = YES;
502 | GCC_C_LANGUAGE_STANDARD = gnu11;
503 | GCC_NO_COMMON_BLOCKS = YES;
504 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
505 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
506 | GCC_WARN_UNDECLARED_SELECTOR = YES;
507 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
508 | GCC_WARN_UNUSED_FUNCTION = YES;
509 | GCC_WARN_UNUSED_VARIABLE = YES;
510 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
511 | MTL_ENABLE_DEBUG_INFO = NO;
512 | MTL_FAST_MATH = YES;
513 | SDKROOT = iphoneos;
514 | VALIDATE_PRODUCT = YES;
515 | };
516 | name = Release;
517 | };
518 | C80D94B1217F1F240004AEE1 /* Debug */ = {
519 | isa = XCBuildConfiguration;
520 | buildSettings = {
521 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
522 | CODE_SIGN_STYLE = Automatic;
523 | INFOPLIST_FILE = chartTest/Info.plist;
524 | LD_RUNPATH_SEARCH_PATHS = (
525 | "$(inherited)",
526 | "@executable_path/Frameworks",
527 | );
528 | PRODUCT_BUNDLE_IDENTIFIER = com.cookie.smallScreen.chartTest;
529 | PRODUCT_NAME = "$(TARGET_NAME)";
530 | TARGETED_DEVICE_FAMILY = "1,2";
531 | };
532 | name = Debug;
533 | };
534 | C80D94B2217F1F240004AEE1 /* Release */ = {
535 | isa = XCBuildConfiguration;
536 | buildSettings = {
537 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
538 | CODE_SIGN_STYLE = Automatic;
539 | INFOPLIST_FILE = chartTest/Info.plist;
540 | LD_RUNPATH_SEARCH_PATHS = (
541 | "$(inherited)",
542 | "@executable_path/Frameworks",
543 | );
544 | PRODUCT_BUNDLE_IDENTIFIER = com.cookie.smallScreen.chartTest;
545 | PRODUCT_NAME = "$(TARGET_NAME)";
546 | TARGETED_DEVICE_FAMILY = "1,2";
547 | };
548 | name = Release;
549 | };
550 | C80D94B4217F1F240004AEE1 /* Debug */ = {
551 | isa = XCBuildConfiguration;
552 | buildSettings = {
553 | BUNDLE_LOADER = "$(TEST_HOST)";
554 | CODE_SIGN_STYLE = Automatic;
555 | INFOPLIST_FILE = chartTestTests/Info.plist;
556 | LD_RUNPATH_SEARCH_PATHS = (
557 | "$(inherited)",
558 | "@executable_path/Frameworks",
559 | "@loader_path/Frameworks",
560 | );
561 | PRODUCT_BUNDLE_IDENTIFIER = com.cookie.smallScreen.chartTestTests;
562 | PRODUCT_NAME = "$(TARGET_NAME)";
563 | TARGETED_DEVICE_FAMILY = "1,2";
564 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/chartTest.app/chartTest";
565 | };
566 | name = Debug;
567 | };
568 | C80D94B5217F1F240004AEE1 /* Release */ = {
569 | isa = XCBuildConfiguration;
570 | buildSettings = {
571 | BUNDLE_LOADER = "$(TEST_HOST)";
572 | CODE_SIGN_STYLE = Automatic;
573 | INFOPLIST_FILE = chartTestTests/Info.plist;
574 | LD_RUNPATH_SEARCH_PATHS = (
575 | "$(inherited)",
576 | "@executable_path/Frameworks",
577 | "@loader_path/Frameworks",
578 | );
579 | PRODUCT_BUNDLE_IDENTIFIER = com.cookie.smallScreen.chartTestTests;
580 | PRODUCT_NAME = "$(TARGET_NAME)";
581 | TARGETED_DEVICE_FAMILY = "1,2";
582 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/chartTest.app/chartTest";
583 | };
584 | name = Release;
585 | };
586 | C80D94B7217F1F240004AEE1 /* Debug */ = {
587 | isa = XCBuildConfiguration;
588 | buildSettings = {
589 | CODE_SIGN_STYLE = Automatic;
590 | INFOPLIST_FILE = chartTestUITests/Info.plist;
591 | LD_RUNPATH_SEARCH_PATHS = (
592 | "$(inherited)",
593 | "@executable_path/Frameworks",
594 | "@loader_path/Frameworks",
595 | );
596 | PRODUCT_BUNDLE_IDENTIFIER = com.cookie.smallScreen.chartTestUITests;
597 | PRODUCT_NAME = "$(TARGET_NAME)";
598 | TARGETED_DEVICE_FAMILY = "1,2";
599 | TEST_TARGET_NAME = chartTest;
600 | };
601 | name = Debug;
602 | };
603 | C80D94B8217F1F240004AEE1 /* Release */ = {
604 | isa = XCBuildConfiguration;
605 | buildSettings = {
606 | CODE_SIGN_STYLE = Automatic;
607 | INFOPLIST_FILE = chartTestUITests/Info.plist;
608 | LD_RUNPATH_SEARCH_PATHS = (
609 | "$(inherited)",
610 | "@executable_path/Frameworks",
611 | "@loader_path/Frameworks",
612 | );
613 | PRODUCT_BUNDLE_IDENTIFIER = com.cookie.smallScreen.chartTestUITests;
614 | PRODUCT_NAME = "$(TARGET_NAME)";
615 | TARGETED_DEVICE_FAMILY = "1,2";
616 | TEST_TARGET_NAME = chartTest;
617 | };
618 | name = Release;
619 | };
620 | /* End XCBuildConfiguration section */
621 |
622 | /* Begin XCConfigurationList section */
623 | C80D947F217F1F230004AEE1 /* Build configuration list for PBXProject "chartTest" */ = {
624 | isa = XCConfigurationList;
625 | buildConfigurations = (
626 | C80D94AE217F1F240004AEE1 /* Debug */,
627 | C80D94AF217F1F240004AEE1 /* Release */,
628 | );
629 | defaultConfigurationIsVisible = 0;
630 | defaultConfigurationName = Release;
631 | };
632 | C80D94B0217F1F240004AEE1 /* Build configuration list for PBXNativeTarget "chartTest" */ = {
633 | isa = XCConfigurationList;
634 | buildConfigurations = (
635 | C80D94B1217F1F240004AEE1 /* Debug */,
636 | C80D94B2217F1F240004AEE1 /* Release */,
637 | );
638 | defaultConfigurationIsVisible = 0;
639 | defaultConfigurationName = Release;
640 | };
641 | C80D94B3217F1F240004AEE1 /* Build configuration list for PBXNativeTarget "chartTestTests" */ = {
642 | isa = XCConfigurationList;
643 | buildConfigurations = (
644 | C80D94B4217F1F240004AEE1 /* Debug */,
645 | C80D94B5217F1F240004AEE1 /* Release */,
646 | );
647 | defaultConfigurationIsVisible = 0;
648 | defaultConfigurationName = Release;
649 | };
650 | C80D94B6217F1F240004AEE1 /* Build configuration list for PBXNativeTarget "chartTestUITests" */ = {
651 | isa = XCConfigurationList;
652 | buildConfigurations = (
653 | C80D94B7217F1F240004AEE1 /* Debug */,
654 | C80D94B8217F1F240004AEE1 /* Release */,
655 | );
656 | defaultConfigurationIsVisible = 0;
657 | defaultConfigurationName = Release;
658 | };
659 | /* End XCConfigurationList section */
660 | };
661 | rootObject = C80D947C217F1F230004AEE1 /* Project object */;
662 | }
663 |
--------------------------------------------------------------------------------
/chartTest/chartTest/charView/LHYChartView.m:
--------------------------------------------------------------------------------
1 | //
2 | // LHYChartView.m
3 | // LHYChartView
4 | //
5 | // Created by lreson on 16/7/21.
6 | // Copyright © 2016年 lreson. All rights reserved.
7 | //
8 |
9 | #import "LHYChartView.h"
10 | #import "YJYTouchCollectionView.h"
11 | #import "YJYTouchScroll.h"
12 | #import "YJYLinesCell.h"
13 | #import "LHYLinesPaoPaoView.h"
14 | #define btnW 12
15 | #define kPaoPaoWidth 75.f
16 | #define chartViewHeight self.bounds.size.height - 30
17 | #define KCircleRadius 3 //线条上圆圈半径
18 | #define KCircleRadius1 5 //线条上圆圈半径
19 | //-------------------------------使用方法(双边多条数据)-----------------------------------
20 | // NSArray *tempDataArrOfY = @[@[@"400",@"600",@"500",@"800",@"600",@"700",@"500"]];
21 | // NSArray *tempDataArrOfY1 = @[@[@"30",@"50",@"30",@"90",@"40",@"50",@"40"]];
22 | //
23 | // _incomeChartLineView = [[LHYChartView alloc]initWithFrame:CGRectMake(0, 40, Main_Screen_Width, 300)];
24 | // //设置X轴坐标字体大小
25 | // _incomeChartLineView.x_Font = [UIFont systemFontOfSize:10];
26 | // //设置X轴坐标字体颜色
27 | // _incomeChartLineView.x_Color = [UIColor colorWithHexString:@"0x999999"];
28 | // //设置Y轴坐标字体大小
29 | // _incomeChartLineView.y_Font = [UIFont systemFontOfSize:10];
30 | // //设置Y轴坐标字体颜色
31 | // _incomeChartLineView.y_Color = [UIColor colorWithHexString:@"0x999999"];
32 | // //设置X轴数据间隔
33 | // _incomeChartLineView.Xmargin = 50;
34 | //
35 | // _incomeChartLineView.backgroundColor = [UIColor clearColor];
36 | // //设置折线样式
37 | // _incomeChartLineView.chartViewStyle = LHYChartViewLeftRightLine;
38 | // //设置X轴字体大小
39 | // _incomeChartLineView.x_Font = [UIFont systemFontOfSize:10];
40 | // //设置X轴字体颜色
41 | // _incomeChartLineView.x_Color = [UIColor colorWithHexString:@"0x999999"];
42 | // //泡泡是否根据折线浮动
43 | // _incomeChartLineView.isFloating = YES;
44 | // //折线图数据
45 | // _incomeChartLineView.leftDataArr = tempDataArrOfY;
46 | // _incomeChartLineView.rightDataArr = tempDataArrOfY1;
47 | // //设置图层效果
48 | // _incomeChartLineView.chartLayerStyle = LHYChartProjection;
49 | //
50 | // _incomeChartLineView.leftColorStrArr = @[@"#febf83"];
51 | // _incomeChartLineView.rightColorStrArr = @[@"#53d2f8"];
52 | //
53 | // //底部日期
54 | // _incomeChartLineView.dataArrOfX = @[@"01-13",@"01-14",@"01-15",@"01-16",@"01-17",@"01-18",@"01-19"];//拿到X轴坐标
55 | //
56 | // [_incomeChartLineView show];
57 | // [self.view addSubview:_incomeChartLineView];
58 | //--------------------------使用方法(单边多条)--------------------------------
59 | // NSArray *tempDataArrOfY = @[@[@"400",@"600",@"500",@"800",@"600",@"700",@"500",@"500",@"500",@"500"],@[@"300",@"500",@"400",@"700",@"500",@"600",@"400",@"400",@"400",@"400"],@[@"500",@"800",@"300",@"600",@"400",@"500",@"300",@"300",@"300",@"300"]];
60 | //
61 | // DLog(@"%f---------------",Main_Screen_Width);
62 | // _incomeChartLineView = [[LHYChartView alloc]initWithFrame:CGRectMake(0, 40, Main_Screen_Width, 300)];
63 | //
64 | //
65 | // //是否可以浮动
66 | // _incomeChartLineView.isFloating = YES;
67 | // //设置X轴坐标字体大小
68 | // _incomeChartLineView.x_Font = [UIFont systemFontOfSize:10];
69 | // //设置X轴坐标字体颜色
70 | // _incomeChartLineView.x_Color = [UIColor colorWithHexString:@"0x999999"];
71 | // //设置Y轴坐标字体大小
72 | // _incomeChartLineView.y_Font = [UIFont systemFontOfSize:10];
73 | // //设置Y轴坐标字体颜色
74 | // _incomeChartLineView.y_Color = [UIColor colorWithHexString:@"0x999999"];
75 | // //设置X轴数据间隔
76 | // _incomeChartLineView.Xmargin = 50;
77 | // //设置背景颜色
78 | // _incomeChartLineView.backgroundColor = [UIColor clearColor];
79 | // //是否根据折线数据浮动泡泡
80 | // //_incomeChartLineView.isFloating = YES;
81 | // //折线图数据
82 | // _incomeChartLineView.leftDataArr = tempDataArrOfY;
83 | // //折线图所有颜色
84 | // _incomeChartLineView.leftColorStrArr = @[@"#febf83",@"#53d2f8",@"#7211df"];
85 | // //设置折线样式
86 | // _incomeChartLineView.chartViewStyle = LHYChartViewMoreClickLine;
87 | // //设置图层效果
88 | // _incomeChartLineView.chartLayerStyle = LHYChartProjection;
89 | // //设置折现效果
90 | // _incomeChartLineView.lineLayerStyle = LHYLineLayerNone;
91 | // //渐变效果的颜色组
92 | // _incomeChartLineView.colors = @[@[[UIColor colorWithHexString:@"#febf83"],[UIColor greenColor]],@[[UIColor colorWithHexString:@"#53d2f8"],[UIColor blueColor]],@[[UIColor colorWithHexString:@"#7211df"],[UIColor redColor]]];
93 | // //渐变开始比例
94 | // _incomeChartLineView.proportion = 0.5;
95 | // //底部日期
96 | // _incomeChartLineView.dataArrOfX = @[@"01-13",@"01-14",@"01-15",@"01-16",@"01-17",@"01-18",@"01-19",@"01-20",@"01-21",@"01-22"];
97 | // //开始画图
98 | // [_incomeChartLineView show];
99 | // [self.view addSubview:_incomeChartLineView];
100 |
101 | @interface LHYChartView ()
102 | {
103 | CGPoint lastPoint;//最后一个坐标点
104 | CGFloat titleWOfY;
105 | }
106 |
107 | @property (nonatomic,strong)YJYTouchScroll *chartScrollView;//折线图滑动的scrollview
108 | @property (nonatomic,strong)YJYTouchCollectionView * xAxiCollectionView;//底部日期滑动的collectionview
109 | @property (nonatomic,strong)UIPageControl *pageControl;//分页
110 | @property (nonatomic,strong)NSMutableArray *leftPointArr;//左边的数据源
111 | @property (nonatomic,strong)NSMutableArray *rightPointArr;//左边的数据源
112 | @property (nonatomic,strong)NSMutableArray *leftBtnArr;//左边按钮
113 | @property (nonatomic,strong)NSMutableArray *leftScaleViewArr;//左边的点击显示图
114 | @property (nonatomic,assign)CGFloat leftJiange;//左侧坐标系的间距
115 | @property (nonatomic,assign)CGFloat rightJiange;//右侧坐标系的间距
116 | @property (nonatomic,assign)BOOL showSelect;
117 | @property (nonatomic,assign) NSInteger selectIndex;
118 | @property (nonatomic,strong)UIView *selectView;
119 | @property (nonatomic,strong)LHYLinesPaoPaoView * paopaoView;
120 | @property (nonatomic,strong)NSMutableArray *charCircleViewArr;
121 | @property (strong,nonatomic) UIBezierPath *circlePath;
122 | @property (strong,nonatomic) CAGradientLayer *gradientlayer;
123 | @property (strong,nonatomic) CAShapeLayer *percentLayer;
124 | @property (nonatomic,strong) UIView * circleView;
125 | @property (nonatomic,assign) NSInteger indexPathIndex;
126 | @property (nonatomic,strong) NSMutableArray * markArray;
127 | @property (nonatomic,strong) CAShapeLayer * dashLayer;
128 | //最后点击
129 | @property (nonatomic,assign) NSInteger lastIndex;
130 | //是否是刷新
131 | @property (nonatomic,assign) BOOL reLoading;
132 | //记录滚动位置
133 | @property (nonatomic,assign) CGPoint contentOffset;
134 | //最后一次点击的坐标
135 | @property (nonatomic,strong) NSValue * lastValue;
136 | //选中的泡泡Tag
137 | @property (nonatomic,assign) NSInteger selectTag;
138 |
139 | @property (nonatomic,assign) CGFloat minValue;
140 |
141 | @property (nonatomic,assign) NSInteger leftIndex;
142 | @end
143 |
144 | @implementation LHYChartView
145 |
146 | #pragma mark --------初始化-----------
147 | -(instancetype)initWithFrame:(CGRect)frame{
148 | if (self = [super initWithFrame:frame]) {
149 | [self initNew];
150 | }
151 | return self;
152 | }
153 |
154 | -(void)awakeFromNib{
155 | [super awakeFromNib];
156 | [self initNew];
157 | }
158 |
159 | -(instancetype)init{
160 | if (self = [super init]) {
161 | [self initNew];
162 | }
163 | return self;
164 | }
165 |
166 | -(void)initNew{
167 | _precisionScale = 1;
168 | _indexPathIndex = -1;
169 | self.leftPointArr = [NSMutableArray array];
170 | self.rightPointArr = [NSMutableArray array];
171 | self.leftBtnArr = [NSMutableArray array];
172 | self.leftScaleViewArr = [NSMutableArray array];
173 | self.markArray = [NSMutableArray array];
174 | self.borderLineColor = [UIColor colorWithRed:224/255.0f green:224/255.0f blue:224/255.0f alpha:1];
175 | self.borderTriangleColor = [UIColor colorWithRed:224/255.0f green:224/255.0f blue:224/255.0f alpha:1];
176 | self.showSelect = NO;
177 | self.isFloating = NO;
178 | self.chartViewStyle = 0;
179 | self.chartLayerStyle = 0;
180 | self.lineLayerStyle = 0;
181 | self.minValue = 0;
182 | self.proportion = 0.5;
183 | self.colors = [NSArray array];
184 | self.lineWidth = 1;
185 | self.isShow = NO;
186 | self.paopaoBackGroundColor = [UIColor whiteColor];
187 | self.markColor = [UIColor whiteColor];
188 | self.paopaoDataArray = [NSArray new];
189 | self.unitStyle = LHYUnitDefault;
190 | self.paopaoTitleArray = [NSArray array];
191 | self.isSelect = YES;
192 | self.leftJiange = 1;
193 | self.rightJiange = 1;
194 | self.xRow = 7;
195 | self.isShowYtext = YES;
196 | self.isShowFirstPaoPao = NO;
197 | self.unitName = @"";
198 | self.selectTag = -1;
199 | self.showChartOffset = YES;
200 | self.isShowBezier = YES;
201 | self.paopaoFollowSliding = NO;
202 | self.showPaoPaoForIndex = -1;
203 | self.middleLineColor = [UIColor colorWithHexString:@"e0e0e0"];
204 | UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewClick:)];
205 | [self addGestureRecognizer:tap];
206 | titleWOfY = 0;
207 | _row = 5;
208 | }
209 |
210 | -(NSMutableArray *)charCircleViewArr{
211 | if (!_charCircleViewArr) {
212 | _charCircleViewArr = [NSMutableArray new];
213 | }
214 | return _charCircleViewArr;
215 | }
216 |
217 | -(YJYTouchCollectionView *)xAxiCollectionView{
218 | if (!_xAxiCollectionView) {
219 | UICollectionViewFlowLayout *collectionViewLayout = [[UICollectionViewFlowLayout alloc]init];
220 | collectionViewLayout.minimumInteritemSpacing = 0;
221 | collectionViewLayout.minimumLineSpacing = 0;
222 | collectionViewLayout.sectionInset = UIEdgeInsetsMake(0, 4, 0, 0);
223 | collectionViewLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
224 | _xAxiCollectionView = [[YJYTouchCollectionView alloc]initWithFrame:CGRectMake(CGRectGetMinX(_chartScrollView.frame), CGRectGetMaxY(_chartScrollView.frame) + 10, CGRectGetWidth(_chartScrollView.frame) + CGRectGetWidth(_chartScrollView.frame) / (_xRow - 1), 20) collectionViewLayout:collectionViewLayout];
225 | _xAxiCollectionView.backgroundColor = [UIColor clearColor];
226 | [_xAxiCollectionView registerNib:[UINib nibWithNibName:@"YJYLinesCell" bundle:nil] forCellWithReuseIdentifier:@"YJYLinesCell"];
227 | _xAxiCollectionView.delegate = self;
228 | _xAxiCollectionView.dataSource = self;
229 | _xAxiCollectionView.bounces = NO;
230 | _xAxiCollectionView.showsHorizontalScrollIndicator = NO;
231 | _xAxiCollectionView.userInteractionEnabled = YES;
232 | [self addSubview:_xAxiCollectionView];
233 | }
234 | return _xAxiCollectionView;
235 | }
236 |
237 | - (UIView *)selectView {
238 | if (!_selectView) {
239 | _selectView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0.5, self.chartScrollView.frame.size.height)];
240 | _selectView.backgroundColor = _markColor;
241 | [self.chartScrollView addSubview:_selectView];
242 | }
243 | return _selectView;
244 | }
245 |
246 | -(void)setMarkColor:(UIColor *)markColor{
247 | _markColor = markColor;
248 | }
249 |
250 | -(LHYLinesPaoPaoView *)paopaoView{
251 | if (!_paopaoView) {
252 | _paopaoView = [[LHYLinesPaoPaoView alloc] initWithFrame:CGRectZero];
253 | _paopaoView.backgroundColor = _paopaoBackGroundColor;
254 | _paopaoView.layer.shadowColor = [UIColor blackColor].CGColor;
255 | _paopaoView.layer.shadowOffset = CGSizeMake(0, 3);
256 | _paopaoView.layer.shadowOpacity = 0.5;
257 | [self.chartScrollView addSubview:_paopaoView];
258 | }
259 | return _paopaoView;
260 | }
261 |
262 | #pragma -mark --------------collViewDelegate----------------
263 | -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
264 | if (self.dataArrOfX.count > 0) {
265 | return self.dataArrOfX.count + 2;
266 | }
267 | return self.dataArrOfX.count;
268 | }
269 | -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
270 | YJYLinesCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"YJYLinesCell" forIndexPath:indexPath];
271 | if (indexPath.row == _indexPathIndex + 1) {
272 | if (self.x_Select_Font) {
273 | cell.titleLB.font = self.x_Select_Font;
274 | }else{
275 | cell.titleLB.font = self.x_Font;
276 | }
277 | if (self.x_Select_Color) {
278 | cell.titleLB.textColor = self.x_Select_Color;
279 | }else{
280 | cell.titleLB.textColor = self.x_Color;
281 | }
282 | }else{
283 | cell.titleLB.font = self.x_Font;
284 | cell.titleLB.textColor = self.x_Color;
285 | }
286 | if (indexPath.row == 0 || indexPath.row == self.dataArrOfX.count + 1) {
287 | cell.titleLB.text = @"";
288 | }else{
289 | cell.titleLB.text = self.dataArrOfX[indexPath.row - 1];
290 | }
291 | cell.titleLB.textAlignment=NSTextAlignmentCenter;
292 | return cell;
293 | }
294 | -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
295 | if (indexPath.row == 0 || indexPath.row == self.dataArrOfX.count + 1) {
296 | return CGSizeMake(CGRectGetWidth(_chartScrollView.frame) / (_xRow - 1) / 2, 20);
297 | }else{
298 | return CGSizeMake(CGRectGetWidth(self.chartScrollView.frame) / (self.xRow - 1), 20);
299 | }
300 |
301 | }
302 |
303 | -(void)setLeftDataArr:(NSArray *)leftDataArr{
304 | _leftDataArr = leftDataArr;
305 | }
306 |
307 | -(void)setRightDataArr:(NSArray *)rightDataArr{
308 | _rightDataArr = rightDataArr;
309 | self.pageControl.numberOfPages = 1;
310 | }
311 | // 获取数据最大值,并计算每一行间隔值
312 | - (CGFloat)spaceValue:(NSArray *)array{
313 | CGFloat minValue = MAXFLOAT;
314 | CGFloat maxValue = -MAXFLOAT;
315 | for (int i = 0; i < [array count]; i++) {
316 | if ([array[i] floatValue] * _precisionScale> maxValue) {
317 | maxValue = [array[i] floatValue] * _precisionScale;
318 | }
319 | if ([array[i] floatValue] * _precisionScale < minValue) {
320 | minValue = [array[i] floatValue] * _precisionScale;
321 | }
322 | }
323 | NSInteger max = [self getNumber:maxValue];
324 | if (!self.min && !self.min.length) {
325 | NSInteger min = [self getMinNumber:minValue];
326 | self.minValue = min < self.minValue ? min : self.minValue;
327 | }else{
328 | self.minValue = [self.min floatValue];
329 | }
330 | max = max - self.minValue;
331 | if (_unitStyle == LHYUnitMillion) {
332 | NSInteger maxValueInterger = max / 100000000.f + 0.99;
333 | NSInteger xMaxValue = maxValueInterger % (_row - 1);
334 | if (xMaxValue != 0) {
335 | xMaxValue = (_row - 1) - xMaxValue + maxValueInterger;
336 | }else{
337 | xMaxValue = maxValueInterger;
338 | }
339 | return xMaxValue / (_row - 1) * 100000000.f;
340 | }else if (_unitStyle == LHYUnitWan) {
341 | NSInteger maxValueInterger = max / 10000.f + 0.99;
342 | NSInteger xMaxValue = maxValueInterger % (_row - 1);
343 | if (xMaxValue != 0) {
344 | xMaxValue = (_row - 1) - xMaxValue + maxValueInterger;
345 | }else{
346 | xMaxValue = maxValueInterger;
347 | }
348 | return xMaxValue / (_row - 1) * 10000.f;
349 | }else if (_unitStyle == LHYUnitThousand) {
350 | NSInteger maxValueInterger = max / 1000.f + 0.99;
351 | NSInteger xMaxValue = maxValueInterger % (_row - 1);
352 | if (xMaxValue != 0) {
353 | xMaxValue = (_row - 1) - xMaxValue + maxValueInterger;
354 | }else{
355 | xMaxValue = maxValueInterger;
356 | }
357 | return xMaxValue / (_row - 1) * 1000.f;
358 | }else if (_unitStyle == LHYUnitMoneyDefault) {
359 | if (max == 0) {
360 | return 10000.f;
361 | }
362 | NSInteger maxValueInterger = 0;
363 | if (max < 100000000) {
364 | maxValueInterger = max / 1000.f + 0.999;
365 | }else{
366 | maxValueInterger = max / 10000000.f + 0.9999999;
367 | }
368 | NSInteger xMaxValue = maxValueInterger % (_row - 1);
369 | if (xMaxValue != 0) {
370 | xMaxValue = (_row - 1) - xMaxValue + maxValueInterger;
371 | }else{
372 | if (maxValueInterger == 0) {
373 | xMaxValue = _row - 1;
374 | }else{
375 | xMaxValue = maxValueInterger;
376 | }
377 | }
378 | if (max >= 100000000) {
379 | return xMaxValue / (_row - 1) * 10000000.f;
380 | }
381 | return xMaxValue / (_row - 1) * 1000.f;
382 | }else{
383 | NSInteger maxValueInterger = 0;
384 | if (max >= 1000) {
385 | maxValueInterger = max / 100.f + 0.99;
386 | }else{
387 | maxValueInterger = max;
388 | }
389 | NSInteger xMaxValue = maxValueInterger % (_row - 1);
390 | if (xMaxValue != 0) {
391 | xMaxValue = (_row - 1) - xMaxValue + maxValueInterger;
392 | }else{
393 | xMaxValue = maxValueInterger;
394 | }
395 | if (max >= 1000) {
396 | return xMaxValue / (_row - 1) * 100;
397 | }
398 | return xMaxValue / (_row - 1);
399 | }
400 | }
401 | // 只取小数点之前的数字
402 | - (CGFloat)getNumber:(CGFloat)value{
403 | CGFloat upValue = ceil(value);
404 | NSString *string = [NSString stringWithFormat:@"%.0f",upValue];
405 | return [string integerValue];
406 | }
407 |
408 | // 只取小数点之前的数字
409 | - (CGFloat)getMinNumber:(CGFloat)value{
410 | CGFloat upValue = floor(value);
411 | NSString *string = [NSString stringWithFormat:@"%.0f",upValue];
412 | return [string integerValue];
413 | }
414 | #pragma mark ----------显示---------------
415 | -(void)show{
416 | self.reLoading = NO;
417 | self.contentOffset = CGPointMake(0, 0);
418 | self.lastIndex = 0;
419 | [self onLoading];
420 | }
421 |
422 | -(void)reShow{
423 | self.reLoading = YES;
424 | self.selectIndex = -1;
425 | [self onLoading];
426 | }
427 |
428 | -(void)onLoading{
429 | if (_dashLayer) {
430 | [_dashLayer removeFromSuperlayer];
431 | _dashLayer = nil;
432 | }
433 | [self.chartScrollView removeFromSuperview];
434 | [self.xAxiCollectionView removeFromSuperview];
435 | [self.paopaoView removeFromSuperview];
436 | self.chartScrollView = nil;
437 | self.xAxiCollectionView = nil;
438 | self.paopaoView = nil;
439 | [self colorConversion];
440 | self.selectView = nil;
441 | ////添加连线
442 | [self addDetailViews];
443 | [self.xAxiCollectionView reloadData];
444 | switch (_chartViewStyle) {
445 | case 0:
446 | [self showLeftRightView];
447 | break;
448 | case 1:
449 | [self showLeftRightView];
450 | break;
451 | case 2:
452 | [self showLeftRightView];
453 | break;
454 | default:
455 | break;
456 | }
457 | [_chartScrollView setContentOffset:self.contentOffset];
458 | if (!self.reLoading) {
459 | if (self.leftPointArr.count > 0) {
460 | NSArray * pointArray = self.leftPointArr[0];
461 | if (self.isShowFirstPaoPao && pointArray.count > 0) {
462 | NSValue * pointValue = pointArray[0];
463 | CGPoint point = [pointValue CGPointValue];
464 | point.x += titleWOfY;
465 | [self viewClick:[NSValue valueWithCGPoint:point]];
466 | if (self.paopaoView.hidden) {
467 | [self viewClick:[NSValue valueWithCGPoint:point]];
468 | }
469 | }
470 | if (self.isShowLastPaoPao && pointArray.count > 0) {
471 | CGFloat contentSizeWidth = self.chartScrollView.contentSize.width;
472 | CGFloat offsetX = contentSizeWidth - CGRectGetWidth(self.chartScrollView.frame);
473 | CGPoint contentPoint = CGPointMake(offsetX < 0 ? 0 : offsetX, 0);
474 | [self.chartScrollView setContentOffset:contentPoint];
475 | }
476 |
477 | if (self.showPaoPaoForIndex >= 0 && pointArray.count > self.showPaoPaoForIndex) {
478 | CGFloat margin = CGRectGetWidth(self.chartScrollView.frame) / (self.xRow - 1);
479 | CGFloat contentX = margin * (self.showPaoPaoForIndex + 1);
480 | contentX = (contentX - CGRectGetWidth(self.chartScrollView.frame) / 2) > 0 ? (contentX - CGRectGetWidth(self.chartScrollView.frame) / 2) : 0;
481 | CGPoint contentPoint = CGPointMake(contentX > self.chartScrollView.contentSize.width ? self.chartScrollView.contentSize.width : contentX, 0);
482 | [self.chartScrollView setContentOffset:contentPoint];
483 | }
484 | }
485 | }else{
486 | if (self.leftPointArr.count > 0) {
487 | if (self.lastIndex) {
488 | CGPoint point = self.lastValue.CGPointValue;
489 | self.lastValue = [NSValue valueWithCGPoint:point];
490 | point.x -= titleWOfY;
491 | if (self.selectTag >= 0) {
492 | [self drawOtherLin:self.selectTag AndPoint:point];
493 | }
494 | }
495 | }
496 | }
497 | if (self.paopaoFollowSliding) {
498 | if (CGRectGetWidth(self.chartScrollView.frame) >= self.chartScrollView.contentSize.width) {
499 | self.chartScrollView.scrollEnabled = NO;
500 | UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(viewClick:)];
501 | [self addGestureRecognizer:pan];
502 | }else{
503 | for (int i = 0; i < self.gestureRecognizers.count; i++) {
504 | id obj = self.gestureRecognizers[i];
505 | if ([obj isKindOfClass:[UIPanGestureRecognizer class]]) {
506 | UIPanGestureRecognizer * pan = obj;
507 | [pan removeTarget:self action:@selector(viewClick:)];
508 | }
509 | }
510 | self.chartScrollView.scrollEnabled = YES;
511 | }
512 | }
513 | }
514 |
515 | //转换颜色
516 | -(void)colorConversion{
517 | NSMutableArray * colorArray = [NSMutableArray array];
518 | for (id obj in _leftColorStrArr) {
519 | UIColor * color;
520 | if ([obj isKindOfClass:[UIColor class]]) {
521 | color = obj;
522 | }else{
523 | NSString * colorStr = obj;
524 | color = [UIColor colorWithHexString:colorStr];
525 | }
526 | [colorArray addObject:color];
527 | }
528 | _leftColorStrArr = [NSArray arrayWithArray:colorArray];
529 | [colorArray removeAllObjects];
530 | for (id obj in _rightColorStrArr) {
531 | UIColor * color;
532 | if ([obj isKindOfClass:[UIColor class]]) {
533 | color = obj;
534 | }else{
535 | NSString * colorStr = obj;
536 | color = [UIColor colorWithHexString:colorStr];
537 | }
538 | [colorArray addObject:color];
539 | }
540 | _rightColorStrArr = [NSArray arrayWithArray:colorArray];
541 | }
542 | //显示左右两种标线
543 | -(void)showLeftRightView{
544 | [self.leftPointArr removeAllObjects];
545 |
546 | if (_leftDataArr.count > 0) {
547 | if (!self.reLoading) {
548 | if (_unitStyle == LHYUnitThousand) {
549 | _leftJiange = 1000;
550 | }else if (_unitStyle == LHYUnitWan){
551 | _leftJiange = 10000;
552 | }else if (_unitStyle == LHYUnitMillion){
553 | _leftJiange = 100000000;
554 | }else{
555 | _leftJiange = 1;
556 | }
557 | }
558 | if (!self.min || !self.min.length) {
559 | self.minValue = 0;
560 | }else{
561 | self.minValue = [self.min floatValue];
562 | }
563 | if (self.max) {
564 | CGFloat jiange = [self spaceValue:@[[NSString stringWithFormat:@"%f",self.max]] ];
565 | if (jiange > _leftJiange) {
566 | _leftJiange = jiange;
567 | }
568 | }else{
569 | for (int i = 0; i < _leftDataArr.count; i++) {
570 | CGFloat jiange = [self spaceValue:_leftDataArr[i]];
571 | if (jiange > _leftJiange) {
572 | _leftJiange = jiange;
573 | }
574 | }
575 | }
576 | [self addLeftViews];
577 | [self setChartViewContentSize];
578 | if (!_rightDataArr || _rightDataArr.count == 0) {
579 | [self calculateLeftLabelMaxWidth];
580 | [self addLines1With:self.chartScrollView];
581 | }
582 | if (_rightDataArr.count > 0) {
583 | if (self.max) {
584 | CGFloat jiange = [self spaceValue:@[[NSString stringWithFormat:@"%f",self.max]]];
585 | if (jiange > _leftJiange) {
586 | _leftJiange = jiange;
587 | }
588 | }else{
589 | for (int i = 0; i < _rightDataArr.count; i++) {
590 | if (_unitStyle == LHYUnitThousand) {
591 | _rightJiange = 1000;
592 | }else if (_unitStyle == LHYUnitWan){
593 | _rightJiange = 10000;
594 | }else if (_unitStyle == LHYUnitMillion){
595 | _rightJiange = 100000000;
596 | }else{
597 | _rightJiange = 1;
598 | }
599 | CGFloat jiange = [self spaceValue:_rightDataArr[i]];
600 | if (jiange > _rightJiange) {
601 | _rightJiange = jiange;
602 | }
603 | }
604 | }
605 |
606 | [self addLeftViews];
607 | [self setChartViewContentSize];
608 | [self calculateLeftLabelMaxWidth];
609 | [self addLines1With:self.chartScrollView];
610 | NSMutableArray * pointMarray = [NSMutableArray array];
611 | for (int i = 0; i < _rightDataArr.count; i++) {
612 | NSArray * dataArray = _rightDataArr[i];
613 | [pointMarray addObject:[self addDataPointWith:self.chartScrollView andArr:dataArray andInterval:_rightJiange]];//添加点
614 | }
615 | [self.rightPointArr addObjectsFromArray:pointMarray];
616 | for (int i = 0; i 0) {
649 | for (int i = 0; i < self.leftPointArr.count; i++) {
650 | NSMutableArray * pointMarray = [NSMutableArray arrayWithArray:self.leftPointArr[i]];
651 | if (pointMarray.count > 2 && pointMarray.count == self.dataArrOfX.count) {
652 | [pointMarray removeObjectAtIndex:pointMarray.count - 1];
653 | [pointMarray removeObjectAtIndex:0];
654 | }else if (pointMarray.count > 0){
655 | [pointMarray removeObjectAtIndex:0];
656 | }
657 | self.leftPointArr[i] = pointMarray;
658 | }
659 | }
660 | if (self.rightPointArr.count > 0) {
661 | for (int i = 0; i < self.rightPointArr.count; i++) {
662 | NSMutableArray * pointMarray = [NSMutableArray arrayWithArray:self.rightPointArr[i]];
663 | if (pointMarray.count > 2 && pointMarray.count == self.dataArrOfX.count) {
664 | [pointMarray removeObjectAtIndex:pointMarray.count - 1];
665 | [pointMarray removeObjectAtIndex:0];
666 | }else if (pointMarray.count > 0){
667 | [pointMarray removeObjectAtIndex:0];
668 | }
669 | self.rightPointArr[i] = pointMarray;
670 | }
671 | }
672 | }
673 |
674 | [self addBottomViewsWith:self.chartScrollView];
675 | }
676 |
677 | -(void)setChartViewContentSize{
678 | CGFloat chartScrollViewwidth = _chartViewStyle == LHYChartViewLeftRightLine ? self.bounds.size.width-titleWOfY * 2 :self.bounds.size.width-titleWOfY;
679 | CGFloat xMargin = chartScrollViewwidth / (_xRow - 1);
680 | if (self.dataArrOfX.count > 0) {
681 | self.chartScrollView.contentSize = CGSizeMake(xMargin*(self.dataArrOfX.count + 1), 0);
682 | }
683 | }
684 |
685 | -(void)setIsShowYtext:(BOOL)isShowYtext{
686 | _isShowYtext = isShowYtext;
687 | titleWOfY = isShowYtext ? titleWOfY : 0;
688 | }
689 | #pragma mark *******************数据源************************
690 | -(void)setDataArrOfX:(NSArray *)dataArrOfX{
691 | _dataArrOfX = dataArrOfX;
692 | }
693 | #pragma mark *******************分割线************************
694 | -(void)addDetailViews{
695 | CGFloat width = 0;
696 | width = _chartViewStyle == LHYChartViewLeftRightLine ? self.bounds.size.width-titleWOfY * 2 :self.bounds.size.width-titleWOfY;
697 | self.chartScrollView = [[YJYTouchScroll alloc]initWithFrame:CGRectMake(titleWOfY, 0, width, chartViewHeight)];
698 | self.chartScrollView.backgroundColor = [UIColor clearColor];
699 | self.chartScrollView.bounces = NO;
700 | self.chartScrollView.delegate = self;
701 | self.chartScrollView.showsHorizontalScrollIndicator = NO;
702 | self.chartScrollView.userInteractionEnabled = YES;
703 | [self addSubview:self.chartScrollView];
704 | [self addSubview:self.xAxiCollectionView];
705 | }
706 | #pragma mark 渐变线条
707 | -(void)buildBGCircleLayer:(NSArray *)colors
708 | {
709 | CAShapeLayer *bgCircleLayer = [CAShapeLayer layer];
710 | bgCircleLayer.path = _circlePath.CGPath;
711 | bgCircleLayer.strokeColor = [UIColor lightGrayColor].CGColor;
712 | bgCircleLayer.fillColor = [UIColor clearColor].CGColor;
713 | bgCircleLayer.lineWidth = _lineWidth;
714 | bgCircleLayer.lineCap = kCALineCapRound; // 截面形状
715 | [self addShowPercentLayer:colors];
716 | [self percentAnimation];
717 | }
718 |
719 | -(void)addShowPercentLayer:(NSArray *)colors
720 | {
721 | _gradientlayer = (id)[CAGradientLayer layer];
722 | if (colors && colors.count > 0) {
723 | NSMutableArray * colorMarray = [NSMutableArray array];
724 | for (int i = 0; i < colors.count; i++) {
725 | UIColor * color = colors[i];
726 | [colorMarray addObject:(id)color.CGColor];
727 | }
728 | _gradientlayer.colors = colorMarray;
729 | }else{
730 | _gradientlayer.colors = [NSArray arrayWithObjects:(id)[[UIColor redColor]CGColor],(id)[[UIColor blueColor]CGColor], nil];
731 | }
732 | _gradientlayer.startPoint= CGPointMake(0.10, 1);
733 | _gradientlayer.endPoint = CGPointMake(0.90, 1);
734 | if (_locations && _locations.count > 0) {
735 | _gradientlayer.locations = _locations;
736 | }else{
737 | _gradientlayer.locations = @[[NSNumber numberWithFloat:_proportion]];
738 | }
739 | _gradientlayer.frame = CGRectMake(0, 0, self.chartScrollView.contentSize.width, CGRectGetHeight(self.chartScrollView.frame));
740 | _percentLayer = [CAShapeLayer layer];
741 | _percentLayer.path = _circlePath.CGPath;
742 | _percentLayer.strokeColor = [UIColor redColor].CGColor;
743 | _percentLayer.fillColor = [UIColor clearColor].CGColor;
744 | _percentLayer.lineWidth = _lineWidth;
745 | _percentLayer.strokeStart = 0;
746 | _percentLayer.strokeEnd = 1;
747 | _percentLayer.lineCap = kCALineCapRound;
748 | if (_chartLayerStyle == 2) {
749 | _percentLayer.shadowColor = [UIColor redColor].CGColor;
750 | _percentLayer.shadowOffset = CGSizeMake(0,5);
751 | _percentLayer.shadowOpacity = 0.5;
752 | }
753 | [_gradientlayer setMask:_percentLayer];
754 | [self.chartScrollView.layer addSublayer:_gradientlayer];
755 |
756 | }
757 | -(void)percentAnimation
758 | {
759 | CABasicAnimation *strokeAnmi = [CABasicAnimation animation];
760 | strokeAnmi.keyPath = @"strokeEnd";
761 | strokeAnmi.fromValue = [NSNumber numberWithFloat:0];
762 | strokeAnmi.toValue = [NSNumber numberWithFloat:1.0f];
763 | strokeAnmi.duration =2.0f;
764 | strokeAnmi.delegate = self;
765 | strokeAnmi.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
766 | strokeAnmi.autoreverses = NO;
767 | if (!self.reLoading) [_percentLayer addAnimation:strokeAnmi forKey:@"stroke"];
768 | }
769 | //等动画结束之后的操作
770 | -(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
771 | {
772 | if (_isShow) {
773 | [self drawCircleArr:self.leftPointArr color:self.leftColorStrArr];
774 | }
775 | //是否动画结束后显示最后一条数据
776 | if (!self.leftPointArr || !self.leftPointArr.count) return;
777 | NSArray * pointArray = self.leftPointArr[0];
778 | if (self.isShowLastPaoPao && pointArray.count > 0) {
779 | CGPoint point = [pointArray[pointArray.count - 1] CGPointValue];
780 | if (point.x >= CGRectGetWidth(self.chartScrollView.frame)) {
781 | point.x = [pointArray[self.xRow - 3] CGPointValue].x;
782 | }
783 | point.x += titleWOfY;
784 | NSValue * value = [NSValue valueWithCGPoint:point];
785 | if (!self.paopaoView || !CGRectGetWidth(self.paopaoView.frame) || self.paopaoView.hidden) {
786 | [self viewClick:value];
787 | }
788 | }
789 | if (self.showPaoPaoForIndex >= 0 && pointArray.count > self.showPaoPaoForIndex) {
790 | CGPoint point = [pointArray[self.showPaoPaoForIndex] CGPointValue];
791 | point.x -= self.chartScrollView.contentOffset.x;
792 | point.x += titleWOfY;
793 | NSValue * value = [NSValue valueWithCGPoint:point];
794 | if (!self.paopaoView || !CGRectGetWidth(self.paopaoView.frame) || self.paopaoView.hidden) {
795 | [self viewClick:value];
796 | }
797 | }
798 |
799 | if (self.charCircleViewArr) {
800 | for (int i = 0; i < self.charCircleViewArr.count; i++) {
801 | UIView * circleView = self.charCircleViewArr[i];
802 | [self.chartScrollView bringSubviewToFront:circleView];
803 | }
804 | }
805 | }
806 | #pragma mark ----------绘画折现----------------
807 | -(void)addBezierPoint:(NSArray *)pointArray andColor:(UIColor *)color andColors:(NSArray *)colors{
808 | if (pointArray.count <= 0) {
809 | return;
810 | }
811 | //取得起始点
812 | CGPoint startP = CGPointMake(0, 0);
813 | if (!self.hiddenZreo) {
814 | startP = [[pointArray objectAtIndex:0] CGPointValue];
815 | }else{
816 | startP = [[pointArray objectAtIndex:1] CGPointValue];
817 | }
818 | //直线的连线
819 | UIBezierPath *lineBeizer = [UIBezierPath bezierPath];
820 | [lineBeizer moveToPoint:startP];
821 | _circlePath = lineBeizer;
822 | //遮罩层的形状
823 | UIBezierPath *shelterBezier = [UIBezierPath bezierPath];
824 | shelterBezier.lineCapStyle = kCGLineCapRound;
825 | shelterBezier.lineJoinStyle = kCGLineJoinMiter;
826 | [shelterBezier moveToPoint:startP];
827 | for (int i = 0;i 0) {
830 | CGPoint prePoint = [[pointArray objectAtIndex:i-1] CGPointValue];
831 | CGPoint nowPoint = [[pointArray objectAtIndex:i] CGPointValue];
832 | [lineBeizer addCurveToPoint:nowPoint controlPoint1:CGPointMake((nowPoint.x+prePoint.x)/2, prePoint.y) controlPoint2:CGPointMake((nowPoint.x+prePoint.x)/2, nowPoint.y)];
833 | [lineBeizer addLineToPoint:nowPoint];
834 | if (_chartLayerStyle == LHYChartGradient) [shelterBezier addCurveToPoint:nowPoint controlPoint1:CGPointMake((nowPoint.x+prePoint.x)/2, prePoint.y) controlPoint2:CGPointMake((nowPoint.x+prePoint.x)/2, nowPoint.y)];
835 | if (i == pointArray.count-1) {
836 | [lineBeizer moveToPoint:nowPoint];//添加连线
837 | lastPoint = nowPoint;
838 | }
839 | }
840 | }else{
841 | if (pointArray.count > 2) {
842 | if (i > 1) {
843 | CGPoint prePoint = [[pointArray objectAtIndex:i-1] CGPointValue];
844 | CGPoint nowPoint = [[pointArray objectAtIndex:i] CGPointValue];
845 | [lineBeizer addCurveToPoint:nowPoint controlPoint1:CGPointMake((nowPoint.x+prePoint.x)/2, prePoint.y) controlPoint2:CGPointMake((nowPoint.x+prePoint.x)/2, nowPoint.y)];
846 | if (_chartLayerStyle == LHYChartGradient) [shelterBezier addCurveToPoint:nowPoint controlPoint1:CGPointMake((nowPoint.x+prePoint.x)/2, prePoint.y) controlPoint2:CGPointMake((nowPoint.x+prePoint.x)/2, nowPoint.y)];
847 | if (i == pointArray.count-1) {
848 | [lineBeizer moveToPoint:nowPoint];//添加连线
849 | lastPoint = nowPoint;
850 | }
851 | }
852 | }else{
853 | if (i > 0) {
854 | CGPoint prePoint = [[pointArray objectAtIndex:i] CGPointValue];
855 | CGPoint nowPoint = [[pointArray objectAtIndex:i] CGPointValue];
856 | nowPoint.x +=1;
857 | [lineBeizer addCurveToPoint:nowPoint controlPoint1:CGPointMake((nowPoint.x+prePoint.x)/2, prePoint.y) controlPoint2:CGPointMake((nowPoint.x+prePoint.x)/2, nowPoint.y)];
858 | if (_chartLayerStyle == LHYChartGradient) [shelterBezier addCurveToPoint:nowPoint controlPoint1:CGPointMake((nowPoint.x+prePoint.x)/2, prePoint.y) controlPoint2:CGPointMake((nowPoint.x+prePoint.x)/2, nowPoint.y)];
859 | if (i == pointArray.count-1) {
860 | [lineBeizer moveToPoint:nowPoint];//添加连线
861 | lastPoint = nowPoint;
862 | }
863 | }
864 | }
865 | }
866 | }
867 | [self drawLine:lineBeizer shelterBezier:shelterBezier startP:startP colors:colors color:color];
868 | }
869 |
870 | -(void)addLinePoint:(NSArray *)pointArray andColor:(UIColor *)color andColors:(NSArray *)colors{
871 | if (pointArray.count <= 0) {
872 | return;
873 | }
874 | //取得起始点
875 | CGPoint startP = CGPointMake(0, 0);
876 | if (!self.hiddenZreo) {
877 | startP = [[pointArray objectAtIndex:0] CGPointValue];
878 | }else{
879 | startP = [[pointArray objectAtIndex:1] CGPointValue];
880 | }
881 | //直线的连线
882 | UIBezierPath *lineBeizer = [UIBezierPath bezierPath];
883 | [lineBeizer moveToPoint:startP];
884 | _circlePath = lineBeizer;
885 | //遮罩层的形状
886 | UIBezierPath *shelterBezier = [UIBezierPath bezierPath];
887 | shelterBezier.lineCapStyle = kCGLineCapRound;
888 | shelterBezier.lineJoinStyle = kCGLineJoinMiter;
889 | [shelterBezier moveToPoint:startP];
890 | for (int i = 0;i 0) {
893 | CGPoint nowPoint = [[pointArray objectAtIndex:i] CGPointValue];
894 | [lineBeizer addLineToPoint:nowPoint];
895 | if (_chartLayerStyle == LHYChartGradient) [shelterBezier addLineToPoint:nowPoint];
896 | if (i == pointArray.count-1) {
897 | [lineBeizer moveToPoint:nowPoint];//添加连线
898 | lastPoint = nowPoint;
899 | }
900 | }
901 | }else{
902 | if (pointArray.count > 2) {
903 | if (i > 1) {
904 | CGPoint nowPoint = [[pointArray objectAtIndex:i] CGPointValue];
905 | [lineBeizer addLineToPoint:nowPoint];
906 | if (_chartLayerStyle == LHYChartGradient) [shelterBezier addLineToPoint:nowPoint];
907 | if (i == pointArray.count-1) {
908 | [lineBeizer moveToPoint:nowPoint];//添加连线
909 | lastPoint = nowPoint;
910 | }
911 | }
912 | }else{
913 | if (i > 0) {
914 | CGPoint nowPoint = [[pointArray objectAtIndex:i] CGPointValue];
915 | nowPoint.x +=1;
916 | [lineBeizer addLineToPoint:nowPoint];
917 | if (_chartLayerStyle == LHYChartGradient) [shelterBezier addLineToPoint:nowPoint];
918 | if (i == pointArray.count-1) {
919 | [lineBeizer moveToPoint:nowPoint];//添加连线
920 | lastPoint = nowPoint;
921 | }
922 | }
923 | }
924 | }
925 | }
926 | [self drawLine:lineBeizer shelterBezier:shelterBezier startP:startP colors:colors color:color];
927 | }
928 |
929 | -(void)drawLine:(UIBezierPath *)lineBeizer shelterBezier:(UIBezierPath *)shelterBezier startP:(CGPoint)startP colors:(NSArray *)colors color:(UIColor *)color{
930 | CGFloat bgViewHeight = self.chartScrollView.bounds.size.height;
931 | //获取最后一个点的X值
932 | CGFloat lastPointX = lastPoint.x;
933 | //最后一个点对应的X轴的值
934 | CGPoint lastPointX1 = CGPointMake(lastPointX, bgViewHeight);
935 | [shelterBezier addLineToPoint:lastPointX1];
936 | //回到原点
937 | [shelterBezier addLineToPoint:CGPointMake(startP.x, bgViewHeight)];
938 | [shelterBezier addLineToPoint:startP];
939 | if (_lineLayerStyle == 1) {
940 | if (_chartLayerStyle == 1) {
941 | [self addGradientWithBezierPath:shelterBezier andColor:color];
942 | }
943 | [self buildBGCircleLayer:colors];
944 | return;
945 | }
946 | // //*****************添加动画连线******************//
947 | CAShapeLayer *shapeLayer = [CAShapeLayer layer];
948 | shapeLayer.path = lineBeizer.CGPath;
949 | shapeLayer.fillColor = [UIColor clearColor].CGColor;
950 | shapeLayer.strokeColor = color.CGColor;
951 | shapeLayer.lineWidth = _lineWidth;
952 | switch (_chartLayerStyle) {
953 | case 0:
954 | break;
955 | case 1:
956 | [self addGradientWithBezierPath:shelterBezier andColor:color];
957 | break;
958 | case 2:
959 | #pragma mark ------------阴影投影---------------
960 | shapeLayer.shadowOffset = CGSizeMake(0, 10);
961 | shapeLayer.shadowColor = color.CGColor;
962 | shapeLayer.shadowOpacity = 0.5;
963 | break;
964 | default:
965 | break;
966 | }
967 | [self.chartScrollView.layer addSublayer:shapeLayer];
968 | CABasicAnimation *strokeAnmi = [CABasicAnimation animation];
969 | strokeAnmi.keyPath = @"strokeEnd";
970 | strokeAnmi.fromValue = [NSNumber numberWithFloat:0];
971 | strokeAnmi.toValue = [NSNumber numberWithFloat:1.0f];
972 | strokeAnmi.duration =2.0f;
973 | strokeAnmi.delegate = self;
974 | strokeAnmi.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
975 | strokeAnmi.autoreverses = NO;
976 | if (!self.reLoading) [shapeLayer addAnimation:strokeAnmi forKey:@"stroke"];
977 | }
978 | #pragma mark ------------渐变图层---------------
979 | -(void)addGradientWithBezierPath:(UIBezierPath *)beizer andColor:(UIColor *)color{
980 | //遮罩层
981 | CAShapeLayer *shadeLayer = [CAShapeLayer layer];
982 | shadeLayer.path = beizer.CGPath;
983 | shadeLayer.fillColor = [UIColor greenColor].CGColor;
984 | CAGradientLayer *gradientLayer = [CAGradientLayer layer];
985 | gradientLayer.frame = CGRectMake(0, 0, 0, self.chartScrollView.bounds.size.height);
986 | gradientLayer.startPoint = CGPointMake(0, 0);
987 | gradientLayer.endPoint = CGPointMake(0, 1);
988 | gradientLayer.cornerRadius = 5;
989 | gradientLayer.masksToBounds = YES;
990 | gradientLayer.colors = @[(__bridge id)[color colorWithAlphaComponent:0.3].CGColor,(__bridge id)[color colorWithAlphaComponent:0].CGColor];
991 | gradientLayer.locations = @[@(self.proportion)];
992 | CALayer *baseLayer = [CALayer layer];
993 | [baseLayer addSublayer:gradientLayer];
994 | [baseLayer setMask:shadeLayer];
995 | [self.chartScrollView.layer addSublayer:baseLayer];
996 | CABasicAnimation *boundsAnmi = [CABasicAnimation animation];
997 | boundsAnmi.keyPath = @"bounds";
998 | boundsAnmi.duration = self.reLoading ? 0.0001f : 2.f;
999 | boundsAnmi.toValue = [NSValue valueWithCGRect:CGRectMake(5, 0, 2*lastPoint.x, self.chartScrollView.bounds.size.height)];
1000 | boundsAnmi.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
1001 | boundsAnmi.fillMode = kCAFillModeForwards;
1002 | boundsAnmi.delegate = self;
1003 | boundsAnmi.autoreverses = NO;
1004 | boundsAnmi.removedOnCompletion = NO;
1005 | [gradientLayer addAnimation:boundsAnmi forKey:@"bounds"];
1006 | }
1007 |
1008 |
1009 | #pragma mark ----------获取所有坐标点-------------
1010 | -(NSMutableArray *)addDataPointWith:(UIView *)view andArr:(NSArray *)DataArr andInterval:(CGFloat)interval{
1011 | CGFloat offset = 0;
1012 | if (self.showChartOffset) {
1013 | offset = 4;
1014 | }
1015 | CGFloat min = self.minValue <= 0 ? self.minValue + fabs(self.minValue) * 2 : [[NSString stringWithFormat:@"-%f",self.minValue] floatValue];
1016 | CGFloat height = self.chartScrollView.bounds.size.height - 13 - KCircleRadius1 / 2 - offset;
1017 | //初始点
1018 | NSMutableArray *arr = [NSMutableArray arrayWithArray:DataArr];
1019 | NSMutableArray * marr = [NSMutableArray array];
1020 | CGFloat xMargin = CGRectGetWidth(self.chartScrollView.frame) / (_xRow - 1);
1021 | for (int i = 0; i _lineWidth ? _lineWidth : 0))];
1024 | if (i == 0) {
1025 | NSValue *point1 = [NSValue valueWithCGPoint:CGPointMake(0 , (height *(1 - tempHeight) + 13) + (height - height *(1 - tempHeight) > _lineWidth ? _lineWidth : 0))];
1026 | [marr addObject:point1];
1027 | }
1028 | [marr addObject:point];
1029 | }
1030 | return marr;
1031 | }
1032 | #pragma mark ---------添加左侧Y轴标注--------------
1033 | -(void)addLeftViews{
1034 | CGFloat textWidth = 0;
1035 | CGFloat labelWidth = 0;
1036 | textWidth = [NSString measureSinglelineStringWidth:[self unitValue:_leftJiange * (_row - 1) + self.minValue] andFont:_y_Font];
1037 | textWidth = [NSString measureSinglelineStringWidth:[self unitValue:_leftJiange * 0 + self.minValue] andFont:_y_Font] > textWidth ? [NSString measureSinglelineStringWidth:[self unitValue:_leftJiange * 0 + self.minValue] andFont:_y_Font] : textWidth;
1038 | if (_unitStyle == LHYUnitMoneyPercentage) {
1039 | textWidth = [NSString measureSinglelineStringWidth:@"100%" andFont:_y_Font];
1040 | }
1041 | if (_isShowYtext) labelWidth = textWidth + 2 > labelWidth ? textWidth + 2 : labelWidth;
1042 | titleWOfY = labelWidth;
1043 | [self.markArray removeAllObjects];
1044 | CGFloat topHeight = 13;
1045 | CGFloat chartScrollViewwidth = _chartViewStyle == LHYChartViewLeftRightLine ? self.bounds.size.width-labelWidth * 2 :self.bounds.size.width-labelWidth;
1046 | for (NSInteger i = 0;i< _row ;i++ ) {
1047 | UILabel * leftLabel = [self viewWithTag:1000 + i + 1];
1048 | CGFloat height = CGRectGetHeight(self.chartScrollView.frame) - topHeight;
1049 | if (!leftLabel) {
1050 | leftLabel = [[UILabel alloc]init];
1051 | leftLabel.tag = 1000 + i + 1;
1052 | }
1053 | CGRect frame = CGRectMake(0,topHeight + height- height / (_row - 1) * i - [_y_Font pointSize] / 2, labelWidth, [_y_Font pointSize]);
1054 | [leftLabel setFrame:frame];
1055 | leftLabel.font = _y_Font;
1056 | leftLabel.textColor = _y_Color;
1057 | if (_unitStyle == LHYUnitMoneyPercentage) {
1058 | leftLabel.text = [NSString stringWithFormat:@"%.0f%%",100.0 / (_row - 1) * i];
1059 | }else{
1060 | leftLabel.text = [self unitValue:_leftJiange * i + self.minValue];
1061 | }
1062 | if (i >= !self.isShowZero && self.isShowYtext) [self addSubview:leftLabel];
1063 | if (self.isGrid){
1064 | CGFloat xMargin = chartScrollViewwidth / (_xRow - 1);
1065 | CGFloat width = 0;
1066 | if (xMargin*(self.dataArrOfX.count + 1) < chartScrollViewwidth){
1067 | width = chartScrollViewwidth;
1068 | }else{
1069 | width = xMargin*(self.dataArrOfX.count + 1);
1070 | }
1071 | UIView * crossView = [[UIView alloc] initWithFrame:CGRectMake(0,topHeight + height - height / (_row - 1) * i + 0.5,width, 0.5)];
1072 | crossView.backgroundColor = _middleLineColor;
1073 | [self.chartScrollView addSubview:crossView];
1074 | if (i != 0) {
1075 | UIView * markCrossView = [[UIView alloc] initWithFrame:CGRectMake(0,topHeight + height - height / (_row - 1) * i + 0.5,8, 0.5)];
1076 | markCrossView.backgroundColor = _borderLineColor;
1077 | [self.chartScrollView addSubview:markCrossView];
1078 | [self.markArray addObject:markCrossView];
1079 | }
1080 | }
1081 | }
1082 | if (self.isGrid) {
1083 | if (!self.dataArrOfX || self.dataArrOfX.count == 0 || (self.dataArrOfX.count > 0 && chartScrollViewwidth / (self.xRow - 3)*(self.dataArrOfX.count - 1) <= chartScrollViewwidth + 1)) {
1084 | CGFloat verticalX = 0;
1085 | while (verticalX <= chartScrollViewwidth + 0.5) {
1086 | UIView * vertical = [[UIView alloc] initWithFrame:CGRectMake(verticalX - 0.5,topHeight,0.5, CGRectGetHeight(self.chartScrollView.frame) - topHeight)];
1087 | vertical.backgroundColor = _middleLineColor;
1088 | [self.chartScrollView addSubview:vertical];
1089 | verticalX += chartScrollViewwidth / (self.xRow - 1);
1090 | }
1091 | }else{
1092 | for (int i = 0; i < self.dataArrOfX.count + 2; i++) {
1093 | UIView * vertical = [[UIView alloc] initWithFrame:CGRectMake(chartScrollViewwidth / (self.xRow - 1) * i - 0.5,topHeight,0.5, CGRectGetHeight(self.chartScrollView.frame)- topHeight)];
1094 | vertical.backgroundColor = _middleLineColor;
1095 | [self.chartScrollView addSubview:vertical];
1096 | }
1097 | }
1098 | }
1099 | }
1100 |
1101 | -(void)calculateLeftLabelMaxWidth{
1102 | for (NSInteger i = 0;i< _row ;i++ ) {
1103 | NSString * str = @"";
1104 | switch (_chartViewStyle) {
1105 | case 0:
1106 | str = [self unitValue:_leftJiange * i];
1107 | break;
1108 | case 1:
1109 | str = [self unitValue:_leftJiange * i];
1110 | break;
1111 | case 2:
1112 | str = [self unitValue:_leftJiange * i];
1113 | break;
1114 | default:
1115 | break;
1116 | }
1117 | }
1118 | CGFloat width = _chartViewStyle == LHYChartViewLeftRightLine ? self.bounds.size.width-titleWOfY * 2 :self.bounds.size.width-titleWOfY;
1119 | [_chartScrollView setFrame:CGRectMake(titleWOfY, 0, width, chartViewHeight)];
1120 | [_xAxiCollectionView setFrame:CGRectMake(CGRectGetMinX(_chartScrollView.frame), CGRectGetMaxY(_chartScrollView.frame) + 10, CGRectGetWidth(self.frame) - CGRectGetMinX(_chartScrollView.frame), 20)];
1121 | }
1122 |
1123 | -(NSString *)unitValue:(CGFloat)value{
1124 | CGFloat returnValue = 0;
1125 | if (_unitStyle == LHYUnitGe || _unitStyle == LHYUnitDefault) {
1126 | returnValue = value;
1127 | }else if (_unitStyle == LHYUnitMoneyPercentageDefault){
1128 | return [NSString stringWithFormat:@"%.0f%%",value];
1129 | }else if (_unitStyle == 1) {
1130 | returnValue = value / 1000;
1131 | }else if (_unitStyle == 2){
1132 | returnValue = value / 10000;
1133 | }else if (_unitStyle == 3){
1134 | returnValue = value / 100000000;
1135 | }else if (_unitStyle == 4){
1136 | if (value >= 100000000 || returnValue <= 100000000) {
1137 | return [NSString stringWithFormat:@"%.1f亿%@",value / 100000000,self.unitName];
1138 | }else{
1139 | return [NSString stringWithFormat:@"%.1f万%@",value / 10000,self.unitName];
1140 | }
1141 | }
1142 | if ((returnValue >= 1000 || returnValue <= 1000) && (self.leftJiange * (self.row - 1) >= 1000)) {
1143 | return [NSString stringWithFormat:@"%.1fk%@",returnValue / 1000,self.unitName];
1144 | }
1145 | return [NSString stringWithFormat:@"%.0f%@",returnValue,self.unitName];
1146 | }
1147 | #pragma mark ---------添加右侧Y轴标注--------------
1148 | -(void)addRightViews{
1149 | for (NSInteger i = 0;i< _row ;i++ ) {
1150 | CGFloat height = CGRectGetHeight(_chartScrollView.frame);
1151 | CGFloat jiange = (height - _row * 15) / (_row - 1);
1152 | CGRect frame = CGRectMake(CGRectGetWidth(self.frame) - titleWOfY + 5, height - 15*(i + 1) - jiange * i , titleWOfY - 5, 15);
1153 | UILabel *leftLabel = [[UILabel alloc]initWithFrame:frame];
1154 | leftLabel.font = [UIFont systemFontOfSize:10.0f];
1155 | leftLabel.textColor = [UIColor colorWithHexString:@"0x999999"];
1156 | leftLabel.textAlignment = NSTextAlignmentLeft;
1157 | leftLabel.text = [NSString stringWithFormat:@"%.0f",_rightJiange * i];
1158 | [self addSubview:leftLabel];
1159 | }
1160 | }
1161 |
1162 | -(void)addBottomViewsWith:(UIView *)View{
1163 | NSArray *bottomArr;
1164 | if (View == self.chartScrollView) {
1165 | bottomArr = _dataArrOfX;
1166 |
1167 | }else{
1168 | }
1169 | }
1170 |
1171 | -(void)TopBtnAction:(UIButton *)sender{
1172 | for (UIButton*btn in _leftBtnArr) {
1173 | if (sender.tag == btn.tag) {
1174 | btn.selected = YES;
1175 | }else{
1176 | btn.selected = NO;
1177 | }
1178 | }
1179 | }
1180 | #pragma mark - ------------scrollViewDelegate----------------
1181 | -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
1182 | self.contentOffset = scrollView.contentOffset;
1183 | if (scrollView == _chartScrollView) {
1184 | _xAxiCollectionView.contentOffset = scrollView.contentOffset;
1185 | }else{
1186 | _chartScrollView.contentOffset = scrollView.contentOffset;
1187 | }
1188 | for (UIView * markCrossView in self.markArray) {
1189 | CGRect frame = markCrossView.frame;
1190 | frame.origin.x = scrollView.contentOffset.x;
1191 | [markCrossView setFrame:frame];
1192 | }
1193 | if (_paopaoView && !_paopaoView.hidden && self.paopaoFollowSliding) {
1194 | CGFloat xMargin = CGRectGetWidth(self.chartScrollView.frame) / (_xRow - 1);
1195 | NSInteger leftIndex = ((self.selectIndex + 1) * xMargin - self.chartScrollView.contentOffset.x
1196 | + xMargin / 2) / xMargin;
1197 | if (leftIndex > self.leftIndex) {
1198 | [self drawOtherLin:self.selectIndex - 1 AndPoint:CGPointZero];
1199 | }else if (leftIndex < self.leftIndex){
1200 | [self drawOtherLin:self.selectIndex + 1 AndPoint:CGPointZero];
1201 | }
1202 | }
1203 | }
1204 | #pragma mark - 点击屏幕事件
1205 | //- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
1206 | //}
1207 | //
1208 | //- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
1209 | //
1210 | //}
1211 | -(void)viewClick:(id)sender{
1212 | if (!_isSelect) return;
1213 | [self colorConversion];
1214 | CGPoint point;
1215 | CGFloat xMargin = CGRectGetWidth(self.chartScrollView.frame) / (_xRow - 1);
1216 | if ([sender isKindOfClass:[UITapGestureRecognizer class]] || [sender isKindOfClass:[UIPanGestureRecognizer class]]) {
1217 | point = [sender locationInView:self];
1218 | self.lastValue = [NSValue valueWithCGPoint:point];
1219 | point.x -= titleWOfY;
1220 | }else{
1221 | NSValue * value = sender;
1222 | point = value.CGPointValue;
1223 | self.lastValue = [NSValue valueWithCGPoint:point];
1224 | point.x -= titleWOfY;
1225 | }
1226 | if (point.x > xMargin / 2 && point.x < CGRectGetMaxX(self.chartScrollView.frame) && point.y > CGRectGetMinY(self.chartScrollView.frame) && point.y < CGRectGetMaxY(self.chartScrollView.frame)) {
1227 | point.x = point.x + self.chartScrollView.contentOffset.x;
1228 | point.y = point.y + self.chartScrollView.contentOffset.y;
1229 | NSInteger index = point.x / xMargin - 1;
1230 | float indexF = point.x - xMargin * (index + 1);
1231 | if (indexF>xMargin / 2) {
1232 | index = index + 1;
1233 | }
1234 | self.selectTag = index;
1235 | if ([sender isKindOfClass:[UIPanGestureRecognizer class]] && self.selectIndex == index){
1236 | return;
1237 | }
1238 | [self drawOtherLin:index AndPoint:point];
1239 | return;
1240 | }
1241 | if (point.x > xMargin / 2 && point.x < CGRectGetMaxX(self.xAxiCollectionView.frame) && point.y > CGRectGetMinY(self.xAxiCollectionView.frame) && point.y < CGRectGetMaxY(self.xAxiCollectionView.frame)) {
1242 | point.x = point.x + self.xAxiCollectionView.contentOffset.x;
1243 | point.y = point.y + self.xAxiCollectionView.contentOffset.y;
1244 | NSInteger index = point.x / xMargin - 1;
1245 | float indexF = point.x - xMargin * (index + 1);
1246 | if (indexF>xMargin / 2) {
1247 | index = index + 1;
1248 | }
1249 | if ([sender isKindOfClass:[UIPanGestureRecognizer class]] && self.selectIndex == index){
1250 | return;
1251 | }
1252 | [self drawOtherLin:index AndPoint:point];
1253 | return;
1254 | }
1255 | }
1256 | //点击之后画出重点线以及数值
1257 | -(void)drawOtherLin:(NSInteger)index AndPoint:(CGPoint)touchpoint{
1258 | if(index >= self.dataArrOfX.count || index<0 || self.dataArrOfX.count == 0){
1259 | return ;
1260 | }
1261 | [self.paopaoView removeFromSuperview];
1262 | self.paopaoView = nil;
1263 | if (self.showSelect && self.selectIndex== index) {
1264 | self.lastIndex = 0;
1265 | self.selectTag = -1;
1266 | self.selectView.hidden = YES;
1267 | self.paopaoView.hidden = YES;
1268 | self.indexPathIndex = -1;
1269 | for (UIView *view in self.charCircleViewArr) {
1270 | [view removeFromSuperview];
1271 | }
1272 | self.showSelect = NO;
1273 | [_xAxiCollectionView reloadData];
1274 | return;
1275 | }
1276 | self.lastIndex = index + 1;
1277 | self.showSelect = YES;
1278 | self.selectIndex = index;
1279 | CGFloat xMargin = CGRectGetWidth(self.chartScrollView.frame) / (_xRow - 1);
1280 | self.leftIndex = ((self.selectIndex + 1) * xMargin - self.chartScrollView.contentOffset.x
1281 | + xMargin / 2) / xMargin;
1282 | self.indexPathIndex = index;
1283 | [_xAxiCollectionView reloadData];
1284 | [self setPaopaoUI:index];
1285 | }
1286 |
1287 | -(void)setPaopaoUI:(NSInteger)index{
1288 | CGFloat xMargin = CGRectGetWidth(self.chartScrollView.frame) / (_xRow - 1);
1289 | [self.chartScrollView bringSubviewToFront:self.selectView];
1290 | self.selectView.hidden = NO;
1291 | self.selectView.backgroundColor = _markColor;
1292 | if (xMargin*index + self.selectView.frame.size.width > self.chartScrollView.contentSize.width) {
1293 | self.selectView.frame = CGRectMake(xMargin*index+xMargin, 0, self.selectView.frame.size.width, self.selectView.frame.size.height);
1294 | }else{
1295 | self.selectView.frame = CGRectMake(xMargin*index+xMargin, 0, self.selectView.frame.size.width, self.selectView.frame.size.height);
1296 | }
1297 | [self.chartScrollView bringSubviewToFront:self.paopaoView];
1298 | self.paopaoView.hidden = NO;
1299 | [self.chartScrollView bringSubviewToFront:self.selectView];
1300 | NSMutableArray *dataArr = [NSMutableArray new];
1301 | if (_chartViewStyle == LHYChartViewLeftRightLine) {
1302 | if (self.paopaoDataArray.count > 0){
1303 | [self.paopaoDataArray enumerateObjectsUsingBlock:^(NSArray * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
1304 | if (index < obj.count) {
1305 | [dataArr addObject:obj[index]];
1306 | }
1307 | }];
1308 | }else{
1309 | [self.leftDataArr enumerateObjectsUsingBlock:^(NSArray * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
1310 | if (index < obj.count) {
1311 | [dataArr addObject:obj[index]];
1312 | }
1313 | }];
1314 | [self.rightDataArr enumerateObjectsUsingBlock:^(NSArray * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
1315 | if (index < obj.count) {
1316 | [dataArr addObject:obj[index]];
1317 | }
1318 | }];
1319 | }
1320 | }else{
1321 | if (self.paopaoDataArray.count > 0){
1322 | [self.paopaoDataArray enumerateObjectsUsingBlock:^(NSArray * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
1323 | if (index < obj.count) {
1324 | [dataArr addObject:obj[index]];
1325 | }
1326 | }];
1327 | }else{
1328 | [self.leftDataArr enumerateObjectsUsingBlock:^(NSArray * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
1329 | if (index < obj.count) {
1330 | [dataArr addObject:obj[index]];
1331 | }
1332 | }];
1333 | }
1334 | }
1335 | NSMutableArray *colorArr = [NSMutableArray array];
1336 | for (int i = 0; i < self.leftColorStrArr.count; i++) {
1337 | [colorArr addObject:self.leftColorStrArr[i]];
1338 | }
1339 | for (int i = 0; i < self.rightColorStrArr.count ; i++) {
1340 | [colorArr addObject:self.rightColorStrArr[i]];
1341 | }
1342 | CGSize size = [LHYLinesPaoPaoView getWidthAndHeight:dataArr];
1343 | float paopao_x = index * xMargin + xMargin - size.width * 0.5;
1344 | if (self.paopaoTitleArray.count == 0) {
1345 | size.height -= 17;
1346 | }
1347 | size.height += 13;
1348 | if (paopao_x < 0) {
1349 | paopao_x = 0;
1350 | }else if (paopao_x > self.chartScrollView.contentSize.width - size.width && paopao_x > self.chartScrollView.frame.size.width - size.width) {
1351 | paopao_x = self.chartScrollView.contentSize.width - size.width;
1352 | }
1353 | self.paopaoView.frame = CGRectMake(paopao_x, self.paopaoView.frame.origin.y, size.width, size.height + 5);
1354 | self.paopaoView.margin = xMargin;
1355 | if (paopao_x == 0 && size.width > xMargin) {
1356 | self.paopaoView.beyondLeft = YES;
1357 | }else if ((index + 1) * xMargin + size.width * 0.5 > self.chartScrollView.contentSize.width && size.width > xMargin && (index + 1) * xMargin + size.width * 0.5 > self.chartScrollView.frame.size.width){
1358 | self.paopaoView.beyondRight = YES;
1359 | }
1360 | NSArray * colorArray = _paopaoDataColors ? _paopaoDataColors : colorArr;
1361 | UIColor* titleColor = _paopaoTitleColor ? _paopaoTitleColor : [UIColor colorWithHexString:@"0x999999"];
1362 | self.paopaoView.chartContentWidth = self.chartScrollView.contentSize.width;
1363 | NSMutableArray * colorMarray = [NSMutableArray array];
1364 | if (colorArray.count < dataArr.count) {
1365 | for (int s = 0; s < self.leftDataArr.count; s++) {
1366 | NSArray * arr = self.leftDataArr[s];
1367 | if (arr.count > index) {
1368 | [colorMarray addObject:colorArr[s]];
1369 | }
1370 | }
1371 | }else{
1372 | [colorMarray addObjectsFromArray:colorArray];
1373 | }
1374 | if (self.paopaoTitleArray.count > 0) {
1375 | NSArray * pointArray = self.leftPointArr[0];
1376 | for (NSArray * arr in self.leftPointArr) {
1377 | if (index < arr.count) {
1378 | pointArray = arr;
1379 | break;
1380 | }
1381 | }
1382 | CGPoint showPoint = [pointArray[index >= pointArray.count ? pointArray.count - 1 : index] CGPointValue];
1383 | self.paopaoView.pointX = showPoint.x;
1384 | NSString *title = @"";
1385 | if (self.paopaoTitleArray && index < self.paopaoTitleArray.count) {
1386 | title = self.paopaoTitleArray[index];
1387 | }
1388 | [self.paopaoView show:dataArr and:title andTitleColor:titleColor colorArr:colorMarray];
1389 | [self returnBlock:dataArr title:title];
1390 | }else{
1391 | NSArray * pointArray = self.leftPointArr[0];
1392 | for (NSArray * arr in self.leftPointArr) {
1393 | if (index < arr.count) {
1394 | pointArray = arr;
1395 | break;
1396 | }
1397 | }
1398 | CGPoint showPoint = [pointArray[index] CGPointValue];
1399 | self.paopaoView.pointX = showPoint.x;
1400 | NSString *title = @"";
1401 | if (self.paopaoTitleArray && index < self.paopaoTitleArray.count) {
1402 | title = self.paopaoTitleArray[index];
1403 | }
1404 | [self.paopaoView show:dataArr and:@"" andTitleColor:titleColor colorArr:colorMarray];
1405 | [self returnBlock:dataArr title:title];
1406 | }
1407 | [self addCircle:index];
1408 | }
1409 | //圆圈
1410 | - (void)addCircle:(NSInteger)index{
1411 | for (UIView *circleView in self.charCircleViewArr) {
1412 | [circleView removeFromSuperview];
1413 | }
1414 | NSMutableArray * leftColorArr = [NSMutableArray array];
1415 | NSMutableArray * rightColorArr = [NSMutableArray array];
1416 | switch (_chartViewStyle) {
1417 | case 0:
1418 | for (int i = 0; i < _leftColorStrArr.count; i++) {
1419 | [leftColorArr addObject:_leftColorStrArr[i]];
1420 | }
1421 | [self.charCircleViewArr removeAllObjects];
1422 | [self drawCircle:index arr:self.leftPointArr color:leftColorArr];
1423 | break;
1424 | case 1:
1425 | for (int i = 0; i < _leftColorStrArr.count; i++) {
1426 | [leftColorArr addObject:_leftColorStrArr[i]];
1427 | }
1428 | [self.charCircleViewArr removeAllObjects];
1429 | [self drawCircle:index arr:self.leftPointArr color:leftColorArr];
1430 | break;
1431 | case 2:
1432 | [self.charCircleViewArr removeAllObjects];
1433 | for (int i = 0; i < _leftColorStrArr.count; i++) {
1434 | [leftColorArr addObject:_leftColorStrArr[i]];
1435 | [self drawCircle:index arr:self.leftPointArr color:leftColorArr];
1436 | }
1437 | for (int i = 0; i < _rightColorStrArr.count; i++) {
1438 | [rightColorArr addObject:_rightColorStrArr[i]];
1439 | [self drawCircle:index arr:self.rightPointArr color:rightColorArr];
1440 | }
1441 |
1442 |
1443 | break;
1444 | default:
1445 | break;
1446 | }
1447 | }
1448 |
1449 | - (void)drawCircle:(NSInteger)index arr:(NSArray *)pointArr color:(NSArray *)colors{
1450 | CGFloat pointY = 0;
1451 | for (int i = 0; i index){
1454 | CGPoint point = [arr[index] CGPointValue];
1455 | UIView * circleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KCircleRadius1*2, KCircleRadius1*2)];
1456 | circleView.center = point;
1457 | if (i == 0) {
1458 | pointY = point.y;
1459 | }
1460 | if (self.isFloating) {
1461 | if (point.y < pointY) {
1462 | pointY = point.y;
1463 | }
1464 | }else if(i == 0){
1465 | [self.paopaoView drawBoxWithDirection:directionTop];
1466 | }
1467 | circleView.backgroundColor = self.isShowCircleOutWhite ? colors[i] : [UIColor whiteColor];
1468 | circleView.layer.cornerRadius = KCircleRadius1;
1469 | circleView.layer.borderColor = self.isShowCircleOutWhite ? [UIColor whiteColor].CGColor : colors[i].CGColor;
1470 | circleView.layer.borderWidth = 2;
1471 | circleView.layer.masksToBounds = YES;
1472 | self.circleView = circleView;
1473 | [self.chartScrollView addSubview:circleView];
1474 | [self.charCircleViewArr addObject:circleView];
1475 | }else{
1476 | [self.paopaoView drawBoxWithDirection:directionTop];
1477 | }
1478 | }
1479 | if (self.isFloating) {
1480 | if (pointY - CGRectGetHeight(self.paopaoView.frame) - KCircleRadius >= 0) {
1481 | CGRect frame = self.paopaoView.frame;
1482 | frame.origin.y = pointY - CGRectGetHeight(self.paopaoView.frame) - KCircleRadius;
1483 | [self.paopaoView setFrame:frame];
1484 | [self.paopaoView drawBoxWithDirection:directionTop];
1485 |
1486 | }else{
1487 | CGRect frame = self.paopaoView.frame;
1488 | frame.origin.y = pointY + KCircleRadius;
1489 | [self.paopaoView setFrame:frame];
1490 | [self.paopaoView drawBoxWithDirection:directionBottom];
1491 | }
1492 | }
1493 | [self.chartScrollView bringSubviewToFront:self.paopaoView];
1494 | }
1495 |
1496 | - (void)drawCircleArr:(NSArray *)pointArr color:(NSArray *)colors{
1497 | for (int i = 0; i