作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 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/
我正在寻找绘制极坐标数据的替代方法。我需要实现像 this 这样的图表具有动态选项,例如 this . 非常感谢您的帮助! 最佳答案 我个人需要这些: Highcharts JS canvasXpre
我是一名优秀的程序员,十分优秀!