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]];
는하지만로드가 완료되면, 그것을 잘 작동합니다. 현재로서는 나에게 용납 될 수없는 빠른 로딩 방법이 있습니까?
"takes forever"... 데이터 소스에서 얼마나 많은 포인트 ('numberOfRecordsForPlot'가 반환합니까?)를 정의하십시오. 당신의 데이터 포인트는'numberForPlot'에 어떻게 저장되고 접근됩니까? 어쩌면 numberForPlot 메소드도 보여줄 수 있습니다. –
"앱이 시작될 때 iPhone 5에서 7-10 초 정도의 시간이 소요됩니다 (런타임 중에 포인트를 수집하기 때문에 포인트가 전혀 필요하지 않습니다). 다음은 numberForPlot 메서드입니다. if (fieldEnum == CPTScatterPlotFieldX) return [NSNumber numberWithInt : index]; else return [self.points objectAtIndex : index]; – user1775746