【发布时间】:2014-04-15 14:24:12
【问题描述】:
如标题中所述,我已成功将 CorePlot 添加到我的项目中,并且它按预期工作。除了仍然显示我无法删除或隐藏的轴标签。这是我的 renderInLayer 代码,
-(void)renderInLayer:(CPTGraphHostingView *)layerHostingView withTheme:(CPTTheme *)theme animated:(BOOL)animated
{
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
CGRect bounds = layerHostingView.bounds;
#else
CGRect bounds = NSRectToCGRect(layerHostingView.bounds);
#endif
CPTGraph *graph = [[[CPTXYGraph alloc] initWithFrame:bounds] autorelease];
[self addGraph:graph toHostingView:layerHostingView];
graph.plotAreaFrame.paddingTop = 0.0;
graph.plotAreaFrame.paddingRight = 0.0;
graph.plotAreaFrame.paddingBottom = 0.0;
graph.plotAreaFrame.paddingLeft = 0.0;
graph.plotAreaFrame.masksToBorder = NO;
// Create the plot
CPTScatterPlot *dataSourceLinePlot = [[[CPTScatterPlot alloc] init] autorelease];
dataSourceLinePlot.identifier = kPlotIdentifier;
dataSourceLinePlot.cachePrecision = CPTPlotCachePrecisionDouble;
CPTMutableLineStyle *lineStyle = [[dataSourceLinePlot.dataLineStyle mutableCopy] autorelease];
lineStyle.lineWidth = 3.0;
lineStyle.lineColor = [CPTColor whiteColor];
dataSourceLinePlot.dataLineStyle = lineStyle;
dataSourceLinePlot.dataSource = self;
dataSourceLinePlot.interpolation = CPTScatterPlotInterpolationCurved;
[graph addPlot:dataSourceLinePlot];
// Plot space
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromUnsignedInteger(0) length:CPTDecimalFromUnsignedInteger(kMaxDataPoints - 2)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromUnsignedInteger(0) length:CPTDecimalFromUnsignedInteger(1)];
[dataTimer invalidate];
[dataTimer release];
if ( animated ) {
dataTimer = [[NSTimer timerWithTimeInterval:1.0 / kFrameRate
target:self
selector:@selector(newData:)
userInfo:nil
repeats:YES] retain];
[[NSRunLoop mainRunLoop] addTimer:dataTimer forMode:NSRunLoopCommonModes];
}
else {
dataTimer = nil;
}
}
用不良数据可视化,
编辑
我试过了,但是没用,
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTXYAxis *axis = axisSet.xAxis;
axis.hidden = YES;
for (CPTAxisLabel *axisLabel in axis.axisLabels) {
axisLabel.contentLayer.hidden = YES;
}
【问题讨论】:
标签: ios objective-c core-graphics core-animation core-plot