forked from Boris-Em/BEMSimpleLineGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBEMAverageLine.m
More file actions
73 lines (59 loc) · 1.63 KB
/
BEMAverageLine.m
File metadata and controls
73 lines (59 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// BEMAverageLine.m
// SimpleLineChart
//
// Created by Sam Spencer on 4/7/15.
// Copyright (c) 2015 Boris Emorine. All rights reserved.
//
#import "BEMAverageLine.h"
@implementation BEMAverageLine
- (instancetype)init {
self = [super init];
if (self) {
_enableAverageLine = NO;
_alpha = 1.0;
_width = 3.0;
_yValue = NAN;
}
return self;
}
- (instancetype) initWithCoder:(NSCoder *)coder {
#define RestoreProperty(property, type) {\
if ([coder containsValueForKey:@#property]) { \
self.property = [coder decode ## type ##ForKey:@#property ]; \
}\
}
self = [self init];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullable-to-nonnull-conversion"
RestoreProperty (enableAverageLine, Bool);
RestoreProperty (color, Object);
RestoreProperty (yValue, Double);
RestoreProperty (alpha, Double);
RestoreProperty (width, Double);
RestoreProperty (dashPattern, Object);
RestoreProperty (title, Object);
#pragma clang diagnostic pop
//AverageLine
return self;
}
- (void) encodeWithCoder: (NSCoder *)coder {
#define EncodeProperty(property, type) [coder encode ## type: self.property forKey:@#property]
EncodeProperty (enableAverageLine, Bool);
EncodeProperty (color, Object);
EncodeProperty (yValue, Float);
EncodeProperty (alpha, Float);
EncodeProperty (width, Float);
EncodeProperty (dashPattern, Object);
EncodeProperty (title, Object);
}
- (void)setLabel:(UILabel *)label {
if (_label != label) {
[_label removeFromSuperview];
_label = label;
}
}
- (void)dealloc {
self.label= nil;
}
@end