2013-07-30 3 views
1

코어 플롯으로 표시되는 간단한 산점도를 얻으 려하지만 어떤 이유로 든 선이 표시되지 않습니다. 내 대리자 메서드 (numberOfRecordsForPlot:numberForPlot:field:recordIndex:)이라고합니다. 여기에 내가 그래프 설정하고있어 무엇 : 내가 전에 다른 프로젝트에서 핵심 플롯을 사용하고 난 내 코드를 비교하고 내가 돈으로코어 플롯에 산점도가 표시되지 않습니다.

CPTGraphHostingView* extendedHost = [[CPTGraphHostingView alloc] initWithFrame:CGRectMake(0, extendedView.frameBottom, self.view.frameWidth, roomForScrollingComponentAndGraph - extendedForecastView.frameHeight)]; 
[extendedHost setBackgroundColor:backgroundColor(1.f)]; 
[self.view addSubview:extendedHost]; 

CPTXYGraph* extendedGraph = [[CPTXYGraph alloc] initWithFrame:extendedHost.bounds]; 
extendedGraph.paddingBottom = graphPadding; 
extendedGraph.paddingLeft = graphPadding; 
extendedGraph.paddingRight = graphPadding; 
extendedGraph.paddingTop = graphPadding; 

CPTXYPlotSpace* extendedPlotSpace = (CPTXYPlotSpace*)extendedGraph.defaultPlotSpace; 
extendedPlotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(0) length:CPTDecimalFromInt(20)]; 
extendedPlotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(0) length:CPTDecimalFromInt(100)]; 

[extendedGraph applyTheme:[CPTTheme themeNamed:kCPTDarkGradientTheme]]; 

CPTXYAxisSet* extendedAxisSet = (CPTXYAxisSet*)extendedGraph.axisSet; 

CPTXYAxis* extendedX = extendedAxisSet.xAxis; 
extendedX.minorTicksPerInterval = 0; 
extendedX.titleTextStyle = style; 
extendedX.orthogonalCoordinateDecimal = CPTDecimalFromInt(0); 

NSMutableArray* extendedMajorTicks = [[NSMutableArray alloc] init]; 
for(int idx = 0; idx < 14; idx++) { 
    [extendedMajorTicks addObject:@(idx)]; 
} 
extendedX.majorTickLocations = [NSSet setWithArray:extendedMajorTicks]; 
extendedX.labelingPolicy = CPTAxisLabelingPolicyLocationsProvided; 
extendedX.delegate = self; 

CPTXYAxis* extendedY = extendedAxisSet.yAxis; 
extendedY.preferredNumberOfMajorTicks = 4; 
extendedY.minorTicksPerInterval = 1; 
extendedY.labelingPolicy = CPTAxisLabelingPolicyEqualDivisions; 
extendedY.titleTextStyle = style; 
extendedY.orthogonalCoordinateDecimal = CPTDecimalFromInt(0); 
extendedY.delegate = self; 

CPTScatterPlot* extendedPlot = [[CPTScatterPlot alloc] init]; 
extendedPlot.delegate = self; 

CPTMutableLineStyle *extendedLineStyle = [CPTMutableLineStyle lineStyle]; 
extendedLineStyle.lineJoin = kCGLineJoinRound; 
extendedLineStyle.lineCap = kCGLineCapRound; 
extendedLineStyle.miterLimit = 2.f; 
extendedLineStyle.lineWidth = 2.f; 
extendedLineStyle.lineColor = [CPTColor colorWithCGColor:[UIColor whiteColor].CGColor]; 

extendedPlot.dataLineStyle = extendedLineStyle; 
extendedPlot.dataSource = self; 
extendedPlot.title = @"Extended"; 
_extendedPlot = extendedPlot; 

[extendedGraph addPlot:extendedPlot]; 

_extendedGraph = extendedGraph; 

[extendedHost setHostedGraph:_extendedGraph]; 

나는 기분을 내가 부족 것을 작은 뭔가 '있어 나는 중요한 무엇인가 놓치고 있다고 생각하지 않지만 슬프 도다.

+0

플롯 공간 범위가 플롯 데이터를 둘러싸고 있습니까? 기본 범위는 x와 y 둘 다 [0, 1]입니다. –

+0

이전에는 그렇게하지 않았지만 플롯 공간 범위를 추가 한 후 (위 코드를 편집했는데 범위가 플롯이 하단 근처에 생성 된 후에 설정 됨) 아무 변화가 없습니다. 데이터는 다양하지만 내가 게시 한 범위 안에 들어 있다는 것을 알고 있습니다. –

답변

2

플롯이 그래프에 추가 될 때까지 플롯의 플롯 공간 (extendedPlotSpace)은 nil입니다. 플롯이 그래프의 일부인 후에 플롯 공간 설정을 이동하거나 대신 graph.defaultPlotSpace을 사용하십시오.

+0

글쎄, 플롯의 플롯 공간을 올바르게 설정하면 틱 위치 문제가 해결됩니다. 진드기는 제대로 설정되었지만 음모 지역은 단지 볼 수있는 충분한 공간에만 초점을 맞추지 않았습니다. 그래도 내 음모는 아직 보이지 않습니다. 진드기를 보여주는 새 코드를 게시했습니다. –

+1

'lineStyle'이란 무엇입니까? 'nil' 인 경우, 플롯은 데이터 라인을 그리지 않습니다. –

+0

'lineStyle'은 두 개의 플롯 사이에서 공유했던 CPTMutableLineStyle 이었기 때문에 그 정의는 실제로 내 코드 스 니펫에 없었습니다. 지금 보시다시피 두 코드 모두에 대해 별도의 선 스타일을 사용하도록 코드를 변경했습니다. 'NSLog'-line 스타일은 그것이 non-nil이라는 것을 보여줍니다. –