Я могу нарисовать стеклянную гистограмму с помощью основного участка. Моя проблема в том, что я не могу поместить ярлык поверх уложенной гистограммы. Для создания бара я сделал следующие вещиЯрлык баров не отображается поверх бара с использованием основного графика
for (NSString *set in [[barChartidentifiers allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]) {
CPTBarPlot *plot = [CPTBarPlot tubularBarPlotWithColor:[CPTColor blueColor] horizontalBars:NO];
plot.lineStyle = barLineStyle;
CGColorRef color = ((UIColor *)[barChartidentifiers objectForKey:set]).CGColor;
plot.fill = [CPTFill fillWithColor:[CPTColor colorWithCGColor:color]];
if (firstPlot) {
plot.barBasesVary = NO;
firstPlot = NO;
} else {
plot.barBasesVary = YES;
}
plot.barWidth = CPTDecimalFromFloat(0.5);
plot.barsAreHorizontal = NO;
plot.labelTextStyle = [CPTTextStyle textStyle];
plot.dataSource = self;
plot.identifier = set;
[graph addPlot:plot toPlotSpace:graph.defaultPlotSpace];
}
и ниже код я пишу в
-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
NSNumber *num;
if (fieldEnum == 0) {
num = [NSNumber numberWithInt:index];
}
else {
double offset = 0;
if (((CPTBarPlot *)plot).barBasesVary) {
for (NSString *set in [[barChartidentifiers allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]) {
if ([plot.identifier isEqual:set]) {
break;
}
offset += [[[data objectForKey:[dates objectAtIndex:index]] objectForKey:set] doubleValue];
}
}
//Y Value
if (fieldEnum == 1) {
num =[NSNumber numberWithDouble:[[[data objectForKey:[dates objectAtIndex:index]] objectForKey:plot.identifier] doubleValue] + offset];
}
//Offset for stacked bar
else {
num =[NSNumber numberWithDouble:offset];
}
}
//NSLog(@"%@ - %d - %d - %f", plot.identifier, index, fieldEnum, num);
return num;
}
Вы должны использовать значения перечисления для полей графика вместо магических чисел: 'CPTBarPlotFieldBarLocation',' CPTBarPlotFieldBarTip' и 'CPTBarPlotFieldBarBase'. –