2010-05-20 31 views
1

那麼我試圖通過NSTimeInterval(double)值來管理這個問題。但是,讓我們說核心圖 - 我們如何在不改變數據繪圖值的情況下更改x軸類的長度

X:五月01 2010下午1時03分55秒Y:32
X:05月2010下午7時02分55秒Y:20
現在,如果嘗試顯示當天明智的節目準確的結果。我的代碼段是

xRange=[CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(min) length:CPDecimalFromFloat(maxValue-min)]; 
xClassLength=[[NSString alloc]initWithFormat:@"%f",length]; //length=1 
//here the max & min values are NSTimeInterval 


CPXYAxis *x2 = [[(CPXYAxis *)[CPXYAxis alloc] initWithFrame:CGRectZero] autorelease]; 
x2.labelingPolicy = CPAxisLabelingPolicyAutomatic; 

x2.orthogonalCoordinateDecimal=CPDecimalFromInteger(startPointY); 
x2.minorTicksPerInterval = 0; 
x2.majorTickLength=[xClassLength intValue]; 
x2.preferredNumberOfMajorTicks = 5; 
x2.labelOffset = 10.0;  
x2.coordinate = CPCoordinateX; 
x2.plotSpace = graph.defaultPlotSpace; 
x2.axisLineStyle = redLineStyle; 
x2.majorTickLineStyle = redLineStyle; 
x2.labelingPolicy=CPAxisLabelingPolicyAutomatic; 
CPTimeFormatter *timeFormatter = [[[CPTimeFormatter alloc] initWithDateFormatter:xDateFormatter] autorelease]; 
timeFormatter.referenceDate = refDate; //refDate=May 01 2010 12:00 PM 
x2.labelFormatter=timeFormatter; 
x2.labelTextStyle=axisTitleTextStyle; 
x2.visibleRange =xRange; 
CPConstraints x2Constraints = {CPConstraintFixed, CPConstraintNone}; 
x2.isFloatingAxis = YES; 
x2.constraints = x2Constraints;  

//結束的代碼 那麼這裏我感到困惑的是,如果我想表現出同樣的數據,但與X級長度不同;讓說3小時。我應該在哪裏做出改變。 請指導我一樣。 關於Zahur。

回答

1

我知道它很漂亮的舊帖子。儘管如此,這可能有助於某個人或另一個人。您始終可以通過更改繪圖範圍來更改X軸長度。 CPTestApp-iPhone-SpeedTest在CorePlot的例子中有很好的解釋。

通過更改軸的長度值,我們可以更詳細地查看相同的圖形或以其他方式查看。

CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace; 
float ylen = NUM_POINTS*(rand()/(float)RAND_MAX) ; 
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0) length:CPDecimalFromFloat(NUM_POINTS)]; 
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0) length:CPDecimalFromFloat(ylen)]; 

希望,這有幫助。

相關問題