gpt4 book ai didi

iOS CorePlot 初始化速度极慢

转载 作者:行者123 更新时间:2023-11-29 10:42:55 24 4
gpt4 key购买 nike

我正在尝试使用 CorePlot 绘制 iPhone 上传感器收集的数据,我几乎完成了它,但是 Coreplot 的初始化非常非常慢。这是我在 viewDidLoad 方法中的代码:

    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]];

启动应用程序需要很长时间,但是当它完成加载时,它运行良好。有没有更快的加载方式,因为目前我无法接受。

最佳答案

更新轴标签策略和/或相关属性以减少刻度线和轴标签的数量。默认值会沿每个轴创建一个单位的刻度和标签 - 使用您的代码片段中显示的范围,创建和显示超过 6,000 个标签。

关于iOS CorePlot 初始化速度极慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23612971/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com