2011-10-07 79 views
1

iPhone sdk:Core-plot如何在右侧显示y轴?iPhone sdk:Core-plot如何在右侧显示y轴

现在我正在使用iPhone SDK的核心积,

这是我做了什么至今

enter image description here

,但我希望把Y轴的右手边。

我有使allowsuserInteractive

**plotSpace.allowsUserInteraction=NO; 
volumePlotSpace.allowsUserInteraction=YES;** 

但我想X轴和Y轴始终保持右侧和底部,

无论用户规模或大或小....

是这样的: enter image description here

回答

14

您正在使用哪个版本的Core-Plot?

Core-Plot 0.9允许您在轴位置上设置约束。像这样的代码行应该做的工作:

// 'graph' is your CPTXYGraph object 
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet; 
// move axis to the rightmost position 
axisSet.yAxis.axisConstraints = [CPTConstraints constraintWithUpperOffset:0]; 
// put ticks on the right hand side of the axis 
axisSet.yAxis.tickDirection = CPTSignPositive; 
// add some padding to the right so that labels are actually visible 
graph.plotAreaFrame.paddingRight = 20.0f; 

我不知道在这个版本被引入,但至少睿情节0.2.2程序有点不同。我没有在我的箱子,所以我现在不能检查,但是这是如何解决在左侧Y轴:

CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet; 
axisSet.yAxis.isFloatingAxis = YES; 
// fixed lower constraint, no upper constraint 
CPConstraints yConstraints = {CPConstraintFixed, CPConstraintNone}; 
axisSet.yAxis.constraints = yConstraints; 

我想这对于右侧yConstraints应该{CPConstraintNone, CPConstraintFixed}

+0

您介意添加我的MSN或电子邮件吗? – nullmicgo

+0

我还有一些关于核心图的问题, – nullmicgo

+0

我有另外一个问题,请看这个链接,谢谢>。< http://stackoverflow.com/questions/7819472/iphone-core-plot-chart-zoom在缩小y轴更大y轴更小 – nullmicgo

1

在coreplot 1.5.1,可以使用CPTConstraints设置上向左或向右,OR,设置X轴上的底部或顶部

yAxis.axisConstraints = CPTConstraints(lowerOffset: CGFloat(0.0)) 

lowerOffset左装置Y轴(Y轴)或底部(X轴); upperOffset意思是右(Y轴)或顶部(X轴)