2 막대 그래프 (예 : A 및 B)가있는 차트가 있습니다.다중 막대 그래프 범례
매 시간마다 2 개의 막대 그래프가 표시됩니다.
내가 범례를 설정할 때마다 시간 및 바에 대한 견본과 텍스트가 표시되고 음모가 표시됩니다.
예 : 내 차트에서 다음 내 전설이
AAAA처럼 될 것 4 시간이
BBBB
그리고 난 단지 때문에 매 시간에
AB에게
을 원하는 , 막대는 동일을 의미합니다. 어떻게하면됩니까 ??
난이 일어날 수 있도록 모든 것을하지만 지금까지 어떤 성공을 시도....
우는 소리는 내
// CPTLegend *theLegend = [CPTLegend legendWithGraph:barChart];
CPTLegend *theLegend = [CPTLegend legendWithPlots:[NSArray arrayWithObjects:[barChart plotAtIndex:0],[barChart plotAtIndex:1], nil]];
theLegend.numberOfRows = 1;
theLegend.numberOfColumns = 2;//[horas count] +1/2;
//theLegend.fill = [CPTFill fillWithColor:[CPTColor colorWithGenericGray:0.15]];
//theLegend.borderLineStyle = barLineStyle;
theLegend.cornerRadius = 10.0;
theLegend.swatchSize = CGSizeMake(15, 15);
//whiteTextStyle.fontSize = 16.0;
//theLegend.textStyle = whiteTextStyle;
theLegend.rowMargin = 10.0;
theLegend.paddingLeft = 12.0;
theLegend.paddingTop = 12.0;
theLegend.paddingRight = 12.0;
theLegend.paddingBottom = 12.0;
//theLegend.equalColumns = YES;
//theLegend.equalRows = YES;
theLegend.delegate = self;
barChart.legend = theLegend;
- (있는 NSString *) legendTitleForBarPlot : (CPTBarPlot *) barPlot recordIndex :(NSUInteger) 인덱스 {
if ([barPlot.identifier isEqual:@"Embarque"]) {
if (index == 0)
{
return @"Embarque";
}else {
return @"";
}
}else {
if (index == 0)
{
return @"Desembarque";
}else {
return @"";
}
}
} - (BOOL)의 전설 : (CPTLegend *) 전설의 shouldDrawSwatchAtIndex : (NSUInteger) 인덱스 forPlot : (CPTPlot *) 플롯 inRect : (CGRect) RECT inContext : 각 줄에 대해 별도의 라벨을 원하지 않는다면 (CGContextRef) 컨텍스트 {
if (index == 0) {
return YES;
}else{
return NO;
}
}
감사 에릭, 나는 -legendTitleForBarPlot 댓글을 달았습니다. 두 플롯의 title 속성을 설정했습니다. 하지만 여전히 이전과 같은 일이 일어나고 있습니다. numberOfRows를 1로, numberOfCollouns를 2로 변경하려고 시도했지만 범례가 겹칩니다. 는 http://3.bp.blogspot.com/-QQa9LKUaJHY/T32WTHFcfOI/AAAAAAAAAGI/xpruAySamrQ/s1600/Captura+de+Tela+2012-04-05+às+ 노호 인쇄 화면에서 봐 주시기 바랍니다 09.50.31+ (2) .png –
데이터 소스에'-barFillForBarPlot : recordIndex :'메소드를 구현 했습니까? 그것은 또한 전설적인 행동을 유발할 것입니다. 스크린 샷에서 필요없는 것처럼 보입니다. –
예, 그랬습니다. 다른 답변에 대한 전체 코드를 게시했습니다. 미리 감사드립니다. –