私は2つの棒グラフ(例:AとB)を持つグラフを持っています。複数の棒グラフの凡例
1時間ごとに2つの棒グラフがあります。
凡例を設定すると、スクロールとテキストが1時間ごとに表示され、バー が表示されます。
例:私のチャートでは4時間を持って、その後、私の伝説はこの
AAAA
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;
}
}
おかげエリック、 Iは-legendTitleForBarPlotコメント:recordIndex:方法と-legend:shouldDrawSwatchAtIndex:forPlot:inRect:inContext:方法。 私は両方のプロットの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:'メソッドを実装しましたか?それはまた、伝説の行動を引き起こすでしょう。あなたのスクリーンショットから、それはあなたのように見えません。 –
はい、私はしました。 私は完全なコードを別の答えに掲載しました。 ありがとうございました –