为了显示零值,我在绘图空间中添加了一个额外的 x 轴:
CPTMutableLineStyle *boldLineStyle = [xAxis.axisLineStyle mutableCopy];
boldLineStyle.lineWidth = 1;
boldLineStyle.lineColor = [CPTColor darkGrayColor];
boldLineStyle.lineCap = kCGLineCapRound;
CPTXYAxis *xZeroAxis = [[CPTXYAxis alloc] init];
xZeroAxis.coordinate = CPTCoordinateX;
xZeroAxis.plotSpace = plotSpace;
xZeroAxis.axisLineStyle = boldLineStyle;
有趣的是,显示了这个轴上的标签,但没有显示轴本身:
xZeroAxis.axisLabels = [NSSet setWithArray:naLabels];
xZeroAxis.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];
xyAxisSet.axes = @[xAxis, xLabelAxis, yAxis, xZeroAxis];
我需要如何更改代码以显示 x 轴?
谢谢!
x.axisLineStyle
设置如下:
CPTMutableLineStyle *axisLineStyle = [CPTMutableLineStyle lineStyle];
axisLineStyle.lineWidth = 1.0;
axisLineStyle.lineCap = kCGLineCapRound;
axisLineStyle.lineColor = [CPTColor darkGrayColor];
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPPTXYAxis *x = axisSet.xAxis;
x.axisLineStyle = axisLineStyle;