2011-08-09 131 views
1

我正在用coreplot創建條形圖.Bar圖表正在顯示,但其顛倒..X軸開始在屏幕的頂部,而不是在屏幕的底部..and即使X軸是不可見的..它看起來好像在圖表中的酒吧懸掛:(....我如何改變其位置,使其正確,甚至使X軸可見???上下顛倒x_axis

這裏是我的代碼:

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    [self generateDataSamples]; 

    double xAxisStart = 0; 
    double xAxisLength = 14; 

    double yAxisStart = 0; 
// double yAxisLength = [[samples valueForKeyPath:@"@max.Y_VAL"] doubleValue]; 
    double yAxisLength = 190.0; 


    CPGraphHostingView *hostingView = [[CPGraphHostingView alloc] initWithFrame:self.view.bounds]; 
    [self.view addSubview:hostingView]; 

    CPXYGraph *graph = [[CPXYGraph alloc] initWithFrame:self.view.bounds]; 
    hostingView.hostedGraph = graph; 


    CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace; 
    plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromDouble(xAxisStart) 
                length:CPDecimalFromDouble(xAxisLength+1)]; 

    plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromDouble(yAxisStart) 
                length:CPDecimalFromDouble(yAxisLength+3)]; 

    CPBarPlot *plot = [[CPBarPlot alloc] initWithFrame:CGRectZero]; 
    plot.plotRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromDouble(0.0) 
               length:CPDecimalFromDouble(xAxisLength-5)]; 
    plot.barOffset = CPDecimalFromDouble(1.5); 
    plot.dataSource = self; 


    [graph addPlot:plot]; 
    [plot release]; 
    [graph release]; 
    [hostingView release]; 
} 

感謝ü

回答

0

添加一些填充繪圖區框架,使軸visibl e:

graph.plotAreaFrame.paddingTop = 20.0; 
graph.plotAreaFrame.paddingBottom = 50.0; 
graph.plotAreaFrame.paddingLeft = 50.0; 
graph.plotAreaFrame.paddingRight = 20.0; 

我不知道爲什麼圖形會顛倒。託管視圖的超級視圖是否應用了任何轉換?

+0

嗨..problem解決了..實際上,我創建了uiview上面,我創建了圖形託管視圖,其中圖形添加..刪除一切都在圖形託管視圖給了我適當的圖形..仍然在尋找掃管笏是與前面的代碼的錯誤.... – Archana

+0

現在我得到類似的問題,添加標籤..M靜態添加標籤通過傳遞數組內循環和設置位置的X和Y軸.. ..傳遞彩色圖像數組和標籤數組..即使在這裏M倒過來標籤和彩色圖像..瓦特問題可能是...下來是代碼: – Archana