forked from djw/core-plot
/
_CPTPlainWhiteTheme.m
110 lines (92 loc) · 3.23 KB
/
_CPTPlainWhiteTheme.m
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#import "_CPTPlainWhiteTheme.h"
#import "CPTBorderedLayer.h"
#import "CPTColor.h"
#import "CPTFill.h"
#import "CPTGradient.h"
#import "CPTMutableLineStyle.h"
#import "CPTMutableTextStyle.h"
#import "CPTPlotAreaFrame.h"
#import "CPTUtilities.h"
#import "CPTXYAxis.h"
#import "CPTXYAxisSet.h"
#import "CPTXYGraph.h"
#import "CPTXYPlotSpace.h"
NSString *const kCPTPlainWhiteTheme = @"Plain White"; ///< Plain white theme.
/**
* @brief Creates a CPTXYGraph instance formatted with white backgrounds and black lines.
**/
@implementation _CPTPlainWhiteTheme
+(void)load
{
[self registerTheme:self];
}
+(NSString *)name
{
return kCPTPlainWhiteTheme;
}
#pragma mark -
-(void)applyThemeToBackground:(CPTXYGraph *)graph
{
graph.fill = [CPTFill fillWithColor:[CPTColor whiteColor]];
}
-(void)applyThemeToPlotArea:(CPTPlotAreaFrame *)plotAreaFrame
{
plotAreaFrame.fill = [CPTFill fillWithColor:[CPTColor whiteColor]];
CPTMutableLineStyle *borderLineStyle = [CPTMutableLineStyle lineStyle];
borderLineStyle.lineColor = [CPTColor blackColor];
borderLineStyle.lineWidth = 1.0;
plotAreaFrame.borderLineStyle = borderLineStyle;
plotAreaFrame.cornerRadius = 0.0;
}
-(void)applyThemeToAxisSet:(CPTXYAxisSet *)axisSet
{
CPTMutableLineStyle *majorLineStyle = [CPTMutableLineStyle lineStyle];
majorLineStyle.lineCap = kCGLineCapButt;
majorLineStyle.lineColor = [CPTColor colorWithGenericGray:0.5];
majorLineStyle.lineWidth = 1.0;
CPTMutableLineStyle *minorLineStyle = [CPTMutableLineStyle lineStyle];
minorLineStyle.lineCap = kCGLineCapButt;
minorLineStyle.lineColor = [CPTColor blackColor];
minorLineStyle.lineWidth = 1.0;
CPTXYAxis *x = axisSet.xAxis;
CPTMutableTextStyle *blackTextStyle = [[[CPTMutableTextStyle alloc] init] autorelease];
blackTextStyle.color = [CPTColor blackColor];
blackTextStyle.fontSize = 14.0;
CPTMutableTextStyle *minorTickBlackTextStyle = [[[CPTMutableTextStyle alloc] init] autorelease];
minorTickBlackTextStyle.color = [CPTColor blackColor];
minorTickBlackTextStyle.fontSize = 12.0;
x.labelingPolicy = CPTAxisLabelingPolicyFixedInterval;
x.majorIntervalLength = CPTDecimalFromDouble(0.5);
x.orthogonalCoordinateDecimal = CPTDecimalFromDouble(0.0);
x.tickDirection = CPTSignNone;
x.minorTicksPerInterval = 4;
x.majorTickLineStyle = majorLineStyle;
x.minorTickLineStyle = minorLineStyle;
x.axisLineStyle = majorLineStyle;
x.majorTickLength = 7.0;
x.minorTickLength = 5.0;
x.labelTextStyle = blackTextStyle;
x.minorTickLabelTextStyle = blackTextStyle;
x.titleTextStyle = blackTextStyle;
CPTXYAxis *y = axisSet.yAxis;
y.labelingPolicy = CPTAxisLabelingPolicyFixedInterval;
y.majorIntervalLength = CPTDecimalFromDouble(0.5);
y.minorTicksPerInterval = 4;
y.orthogonalCoordinateDecimal = CPTDecimalFromDouble(0.0);
y.tickDirection = CPTSignNone;
y.majorTickLineStyle = majorLineStyle;
y.minorTickLineStyle = minorLineStyle;
y.axisLineStyle = majorLineStyle;
y.majorTickLength = 7.0;
y.minorTickLength = 5.0;
y.labelTextStyle = blackTextStyle;
y.minorTickLabelTextStyle = minorTickBlackTextStyle;
y.titleTextStyle = blackTextStyle;
}
#pragma mark -
#pragma mark NSCoding methods
-(Class)classForCoder
{
return [CPTTheme class];
}
@end