如何在核心情节中只设置一条主线?

时间:2013-06-18 06:49:47

标签: iphone ios objective-c ios6 core-plot

您好我正在使用核心图创建图形,我想更改主线和次线的线条样式,线条样式已更改但我们在核心图中有两条主线顶部和底线如何删除顶部主线

- (void) setupGraphAxis: (CPTXYGraph *) graph {
CPTColor *axisColor = [CPTColor colorWithComponentRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.75];
CPTMutableLineStyle *axisLineStyle = [CPTMutableLineStyle lineStyle];
axisLineStyle.lineWidth = 1.5f;
axisLineStyle.lineColor = axisColor;


CPTMutableLineStyle *dashLineStyle = [CPTMutableLineStyle lineStyle];
dashLineStyle.lineColor = axisColor;
dashLineStyle.lineWidth = 1.5f;
dashLineStyle.dashPattern = [NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:1],[NSDecimalNumber numberWithInt:2],nil];
dashLineStyle.patternPhase = 0.0f;

CPTMutableLineStyle *fullLineStyle = [CPTMutableLineStyle lineStyle];
fullLineStyle.lineColor = axisColor;
fullLineStyle.lineWidth = 1.5f;
//fullLineStyle.dashPattern = [NSArray arrayWithObjects:[NSDecimalNumber numberWithInt:1],nil];
fullLineStyle.lineCap = 0;
fullLineStyle.patternPhase = 0.0f;

//Configure x-axis
CPTXYAxisSet *axisSet = (CPTXYAxisSet *) graph.axisSet;

CPTXYAxis *x = axisSet.xAxis;
x.axisLineStyle = nil;
x.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0");
x.minorTickLineStyle = nil;
x.majorTickLineStyle = nil;
CPTAxisLabelingPolicy policy = CPTAxisLabelingPolicyAutomatic;
x.labelingPolicy = policy;
x.labelTextStyle = nil;
x.preferredNumberOfMajorTicks = 1;


CPTXYAxis *y = axisSet.yAxis;
y.axisLineStyle = nil;
y.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0");
y.minorTickLineStyle = nil;
y.majorTickLineStyle = nil;
y.majorGridLineStyle = fullLineStyle;
y.minorGridLineStyle = dashLineStyle;
y.labelingPolicy = policy;
y.preferredNumberOfMajorTicks = 1;
}

1 个答案:

答案 0 :(得分:0)

您可以使用轴的labelExclusionRanges属性告诉它在创建刻度线,网格线和标签时跳过某些值。如果您仍然需要该点的刻度和/或标签,则可能需要添加另一个不可见的y轴,该y轴仅绘制网格线并让原始y轴绘制其他所有内容。