2014-05-12 1 views
1

CorePlot을 iPhone 센서에서 수집 한 데이터를 플로팅하는 데 거의 사용하고 있지만 거의 완료했지만 초기화가 매우 느립니다. 여기 viewDidLoad 방법에 내 코드입니다 : 그것은 응용 프로그램을 시작 영원히 소요iOS CorePlot의 초기화 속도가 매우 느림

CPTGraphHostingView* hostView = [[CPTGraphHostingView alloc] initWithFrame:self.coreplot.frame]; 
    [self.view addSubview: hostView]; 

    // Create a CPTGraph object and add to hostView 
    graph = [[CPTXYGraph alloc] initWithFrame:hostView.bounds]; 
    hostView.hostedGraph = graph; 

    // Get the (default) plotspace from the graph so we can set its x/y ranges 
    CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) graph.defaultPlotSpace; 

    // Note that these CPTPlotRange are defined by START and LENGTH (not START and END) !! 
    [plotSpace setYRange: [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(-2000) length:CPTDecimalFromFloat(4000)]]; 
    [plotSpace setXRange: [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(100)]]; 
    // Create the plot (we do not define actual x/y values yet, these will be supplied by the datasource...) 
    CPTScatterPlot* plot = [[CPTScatterPlot alloc] initWithFrame:CGRectZero]; 

    // Let's keep it simple and let this class act as datasource (therefore we implemtn <CPTPlotDataSource>) 
    plot.dataSource = self; 
    CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle]; 
    lineStyle.lineWidth = 2.0f; 
    lineStyle.lineColor = [CPTColor redColor]; 
    plot.dataLineStyle = lineStyle; 
    // Finally, add the created plot to the default plot space of the CPTGraph object we created before 
    [graph addPlot:plot toPlotSpace:graph.defaultPlotSpace]; 
    [graph.defaultPlotSpace scaleToFitPlots:[graph allPlots]]; 

는하지만로드가 완료되면, 그것을 잘 작동합니다. 현재로서는 나에게 용납 될 수없는 빠른 로딩 방법이 있습니까?

+0

"takes forever"... 데이터 소스에서 얼마나 많은 포인트 ('numberOfRecordsForPlot'가 반환합니까?)를 정의하십시오. 당신의 데이터 포인트는'numberForPlot'에 어떻게 저장되고 접근됩니까? 어쩌면 numberForPlot 메소드도 보여줄 수 있습니다. –

+0

"앱이 시작될 때 iPhone 5에서 7-10 초 정도의 시간이 소요됩니다 (런타임 중에 포인트를 수집하기 때문에 포인트가 전혀 필요하지 않습니다). 다음은 numberForPlot 메서드입니다. if (fieldEnum == CPTScatterPlotFieldX) return [NSNumber numberWithInt : index]; else return [self.points objectAtIndex : index]; – user1775746

답변

2

눈금 표시 및 축 레이블 수를 줄이려면 축 레이블 정책 및/또는 관련 속성을 업데이트하십시오. 기본값은 눈금과 레이블을 각 축을 따라 한 단위 씩 (코드 스 니펫에 표시된 범위로 작성하고 표시 할 6,000 개가 넘는 레이블을 만듭니다.

관련 문제