1
CorePlot으로 작성된 내 응용 프로그램에 Graphing Calculator 플러그인이 있습니다. 그리고 작은 버그가 있습니다 - 그래픽이 화면 중앙에 점 (0; 0) 대신 화면에 나타나면 (2; 3)에 가까운 점이 표시됩니다. 그래픽이로드 될 때 (0, 0)이 나타납니다 점 때문에,CorePlot 그래프 계산기가 (0; 0) 지점에서 시작되지 않음
-(void)viewDidLoad
{
[super viewDidLoad];
graph = [[CPXYGraph alloc] initWithFrame:CGRectZero];
CPTheme *theme = [CPTheme themeNamed:kCPStocksTheme];
[graph applyTheme:theme];
CPGraphHostingView *hostingView = (CPGraphHostingView *)self.view ;
hostingView.hostedGraph = graph;
graph.paddingLeft =5;
graph.paddingTop = 5;
graph.paddingRight = 5;
graph.paddingBottom = 5;
CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.allowsUserInteraction = YES;
PlotSpaceX=2;
PlotSpaceY=3;
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(1.0) length:CPDecimalFromFloat(PlotSpaceX)];
plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(1.0) length:CPDecimalFromFloat(PlotSpaceY)];
CPXYAxisSet *axisSet = (CPXYAxisSet *)graph.axisSet;
CPXYAxis *x = axisSet.xAxis;
x.majorIntervalLength = CPDecimalFromString(@"0.5");
x.orthogonalCoordinateDecimal = CPDecimalFromString(@"0");
x.minorTicksPerInterval = 2;
CPXYAxis *y = axisSet.yAxis;
y.majorIntervalLength = CPDecimalFromString(@"0.5");
y.minorTicksPerInterval = 2;
y.orthogonalCoordinateDecimal = CPDecimalFromString(@"0");
boundLinePlot = [[[CPScatterPlot alloc] init] autorelease];
boundLinePlot.identifier = @"Blue Plot";
boundLinePlot.dataLineStyle.miterLimit = 1.0f;
boundLinePlot.dataLineStyle.lineWidth = 3.0f;
boundLinePlot.dataLineStyle.lineColor = [CPColor redColor];
boundLinePlot.dataSource = self;
[graph addPlot:boundLinePlot];
NSMutableArray *contentArray = [NSMutableArray arrayWithCapacity:100000];
NSUInteger i;
for (i = 0; i < 600000; i++) {
id x = [NSNumber numberWithFloat:i*0.05-1000];
id y =[NSNumber numberWithFloat: [x floatValue] *[x floatValue]];
[contentArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:x, @"x", y, @"y", nil]];
}
self.dataForPlot = contentArray;
}
#pragma mark -
#pragma mark Plot Data Source Methods
-(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot {
return [dataForPlot count];
}
-(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
NSNumber *num = [[dataForPlot objectAtIndex:index] valueForKey:(fieldEnum == CPScatterPlotFieldX ? @"x" : @"y")];
return num;
}
가 어떻게이 문제를 해결할 수 있습니다 여기에
코드인가?
정말 고마워요! 그것은 작동합니다! – Knodel