如何为每个日期绘制一条垂直线
y轴运行良好,但为什么不是x轴?
x轴代码:
CPTMutableLineStyle *majorGridLineStyle = [CPTMutableLineStyle lineStyle];
majorGridLineStyle.lineWidth = 2;
majorGridLineStyle.lineColor = [CPTColor redColor];
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTXYAxis *x = [axisSet xAxis];
x.axisLineStyle = nil;
x.majorTickLineStyle = majorGridLineStyle;
[x setLabelingPolicy:CPTAxisLabelingPolicyNone];
x.majorGridLineStyle = majorGridLineStyle;
NSArray *subjectsArray = [self getSubjectTitlesAsArray];
[x setAxisLabels:[NSSet setWithArray:subjectsArray]];
y轴代码:
CPTXYAxis *y = axisSet.yAxis;
y.axisLineStyle = nil;
y.majorTickLineStyle = nil;
y.minorTickLineStyle = nil;
y.majorIntervalLength = CPTDecimalFromString(@"500");
y.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0");
y.majorGridLineStyle = gridLineStyle;
我的错误是什么?
答案 0 :(得分:1)
Core Plot将在主要刻度位置绘制网格线。确保日期值与刻度线位置一致,gridLineStyle
是一种将在白色背景下显示的样式。