2011-10-07 76 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軸)