2012-08-16 84 views
0

我有相當一段時間的搜索,並發現了大量的舊資源,在某一時刻解決我當前的問題。但是,Core Plot已經發展,並且如果以相同的方式實施,我發現的解決方案不再起作用。我希望能得到最新的答案,我確信這是各種圖形和圖表的共同特徵。核心圖:在iOS上顯示右對齊的Y軸

我現在的問題是,當我嘗試右對齊的3軸,我有我的情節之一,而軸本身,包括標題,作動,沒有刻度線,或相關的標籤。我猜我所擁有的可能不完整。

這裏是我的相關軸代碼:

CPTAxis *yRight = [[CPTXYAxis alloc] init]; 
yRight.Title = @"Right Axis"; 
yRight.titleOffset = 10.0f; 
yRight.axisLineStyle = axisLineStyle; 
yRight.majorTickLineStyle = axisLineStyle; 
yRight.minorTickLineStyle = axisLineStyle; 
yRight.labelTextStyle = axisTextStyle; 
yRight.labelOffset = 3.0f; 
yRight.majorIntervalLength = CPTDecimalFromFloat(10.0f); 
yRight.minorTicksPerInterval = 5; 
yRight.minorTickLength = 5.0f; 
yRight.majorTickLength = 7.0f; 

axisSet.axes = [NSArray arrayWithObjects:x, yRight, yLeft, nil]; 
self.hostView.hostedGraph.axisSet = axisSet; 

//Next two lines are in charge of right aligning y axis 
axisSet.yAxis.axisConstraints = [CPTConstraints constraintWithUpperOffset:0]; 
//axisSet.yAxis.tickDirection = CPTSignPositive; this is commented out because I havent found it to do anything, though may be necessary for it to work once complete. 

CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)hostView.hostedGraph.defaultPlotSpace; 
x.plotSpace = plotSpace; 
yLeft.plotSpace = plotSpace; 
yRight.plotSpace = plotSpace; 

我的感覺是什麼,我缺少的是不是一大堆,但我只是在尋找什麼江郎才盡並嘗試在這一點上。

迷你問題,是否支持iOS的浮動軸? axisSet.yAxis.isFloatingAxis給我一個錯誤:(

謝謝你的任何幫助,您可以提供!贊成軸約束取出

回答

1

isFloatingAxis財產。

yRight.axisConstraints = [CPTConstraints constraintWithUpperOffset:0]; 
yRight.coordinate = CPTCoordinateY; 

什麼yRange的情節空間?當前的標籤設置會將刻度和標籤放在0,10,20等上yRight

+0

啊,很高興知道它被刪除了。我想這很簡單,因爲人們都是這樣做的是的,我擁有所有的pi Eces,我只是玩我的yRange和間隔。感謝Eric的幫助! – 2012-08-17 16:08:39