Ios 如何更改核心图堆叠条形图中的图例标题?
在这篇文章之后,我想更改堆叠条形图的图例标题值,默认情况下,它采用代码中给定的“集合”值。 我无法更改“set”值,因为我使用它来匹配并从web服务获取值 上面的图表不是“D”、“O”、“p”,我需要给出全名。 我尝试了一个类似于彩色条形图的代码Ios 如何更改核心图堆叠条形图中的图例标题?,ios,charts,core-plot,legend,Ios,Charts,Core Plot,Legend,在这篇文章之后,我想更改堆叠条形图的图例标题值,默认情况下,它采用代码中给定的“集合”值。 我无法更改“set”值,因为我使用它来匹配并从web服务获取值 上面的图表不是“D”、“O”、“p”,我需要给出全名。 我尝试了一个类似于彩色条形图的代码 -(NSString *)legendTitleForBarPlot:(CPTBarPlot *)barPlot recordIndex:(NSUInteger)index { return [NSString stringWithForm
-(NSString *)legendTitleForBarPlot:(CPTBarPlot *)barPlot recordIndex:(NSUInteger)index
{
return [NSString stringWithFormat:@"Bar %lu", (unsigned long)(index + 1)];
}
然后它如下所示,它获取图中所有堆叠条的索引值
如何更改核心图中的图例标题值 设置每个绘图的
标题
属性,以更改图例中显示的标签。如果要在标签中显示样式化文本,可以使用attributedTitle
。设置每个绘图的title
属性以更改图例中显示的标签。如果要在标签中显示样式化文本,可以使用attributeditle
。嗨,eric,我试过了,-(NSString*)legendTitleForBarPlot:(CPTBarPlot*)barPlot recordIndex:(NSInteger)index{if([barPlot.identifier isEqual:[sets objectForKey:@“D”]==YES){barPlot.title=@“A”}else if([barPlot.identifier isEqual:[sets objectForKey:@“O”]]==YES){barPlot.title=@“AA”}else if([barPlot.identifier isEqual:[sets objectForKey:@“P”]]==YES){barPlot.title=@“AAA”}返回barPlot.title;}但它不起作用,我可以在哪里添加条标题?我像这样累了,在方法内部“-(void)barPlot:(CPTBarPlot*)plot barwassectedAtreCordindex:(nsInteger)index”if(plotIndex==0){plot.title=@“A”;}else if(plotIndex==1){plot.title=@“AA”}else if(plotIndex==2){plot.title=@“AAA”}无法正常工作请告诉我如何解决此问题?-(double)doubleForPlot:(CPTPlot*)绘图字段:(NSInteger)字段Enum recordIndex:(NSInteger)索引{.NSInteger plotIndex=0;如果([plot.identifier isEqual:[sets objectForKey:@“D”]==YES){plotIndex=0;}如果([plot.identifier isEqual:[sets objectForKey:@“O”]==是){plotIndex=1;}如果([plot.identifier isEqual:[sets objectForKey:@“P”]]==是){plotIndex=2;}如果(plotIndex=0){plot.title=@“A”;}如果(plotIndex==1){plot.title=@“AA”;}如果(plotIndex==2){plot.title=@“AAA”;}显示所有3个图例值的“A”,我可以在这里为每个绘图设置标题,请提供一些参考。在初始设置期间,在绘图上设置标题
。在您将绘图添加到图例之前的任何时间都可以使用。嗨,eric,我试过这样做,-(NSString*)legendTitleForBarPlot:(CPTBarPlot*)barPlot recordIndex:(NSInteger)index{if([barPlot.identifier isEqual:[sets objectForKey:@“D”]]==是){barPlot.title=@“A”}如果([barPlot.identifier isEqual:[sets objectForKey:@“O”]==YES){barPlot.title=@“AA”}如果([barPlot.identifier isEqual:[sets objectForKey:@“P”]==YES){barPlot.title=@“AAA”}返回barPlot.title;}但它不起作用,我可以在哪里添加条标题?我很累,就像这样在方法内部“-(void)barPlot:(CPTBarPlot*)绘图条已选定绘图索引:(nsInteger)索引“if(plotIndex==0){plot.title=@A”}else if(plotIndex==1){plot.title=@AA”;}else如果(plotIndex==2){plot.title=@AAA”}不起作用,请告诉我如何解决此问题?-(double)doubleForPlot:(CPTPlot*)绘图字段:(nsInteger)fieldEnum recordIndex:(NSInteger)索引{.NSInteger plotIndex=0;如果([plot.identifier isEqual:[sets objectForKey:@“D”]==YES){plotIndex=0;}如果([plot.identifier isEqual:[sets objectForKey:@“O”]==YES){plotIndex=1;}如果([plot.identifier isEqual:[sets objectForKey:@“P”]=YES){plotIndex=2;}if(plotIndex==0){plot.title=@“A”}else if(plotIndex==1){plot.title=@“AA”;}else if(plotIndex==2){plot.title=@“AAA”;}显示“A”对于所有3个图例值,我可以在此处为每个绘图设置标题,请提供一些参考。在初始设置期间在绘图上设置标题
。在将绘图添加到图例之前的任何时间都可以使用。