에 숨겨져 :절반은 내가 코어 플롯 막대 그래프 같은이 핵심 플롯
당신이 볼 수 있듯이 - 첫 번째 막대의 절반 y 축으로 숨겨져 있습니다. 그래프의 가시 영역 경계를 조금 더 넓게 만들려면 어떻게해야합니까?
EDIT :
- (void) drawBarPlot
{
[self configureBarGraph];
[self configureBarPlot];
[self configureAxes];
}
- (void) configureBarGraph {
// 1 - Create the graph
CPTGraph *graph = [[CPTXYGraph alloc] initWithFrame:self.barChartView.bounds];
graph.plotAreaFrame.masksToBorder = NO;
self.barChartView.hostedGraph = graph;
// 2 - Configure the graph
[graph applyTheme:nil];
graph.paddingBottom = 0.0f;
graph.paddingLeft = 0.0f;
graph.paddingTop = 0.0f;
graph.paddingRight = 0.0f;
graph.plotAreaFrame.paddingLeft = 30.0f;
graph.plotAreaFrame.paddingTop = 20.0f;
graph.plotAreaFrame.paddingRight = 30.0f;
graph.plotAreaFrame.paddingBottom = 20.0f;
// 3 - Set up plot space
CGFloat xMin = 0.0f;
CGFloat xMax = (CGFloat)[[[[PlotDataStore sharedInstance] docsCount] valueForKey:@"docs"] count];
CGFloat yMin = 0.0f;
CGFloat yMax = 10.0f; // should determine dynamically based on max price
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) graph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(xMin) length:CPTDecimalFromFloat(xMax)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(yMin) length:CPTDecimalFromFloat(yMax)];
}
- (void) configureBarPlot {
// 1 - Set up the plot
self.barPlot = [CPTBarPlot tubularBarPlotWithColor:[CPTColor darkGrayColor] horizontalBars:NO];
// 2 - Set up line style
CPTMutableLineStyle *barLineStyle = [[CPTMutableLineStyle alloc] init];
barLineStyle.lineColor = [CPTColor lightGrayColor];
barLineStyle.lineWidth = 0.5;
// 3 - Add plots to graph
CPTGraph *graph = self.barChartView.hostedGraph;
self.barPlot.dataSource = self;
self.barPlot.delegate = self;
self.barPlot.barCornerRadius = 0.0f;
self.barPlot.lineStyle = barLineStyle;
self.barPlot.baseValue = CPTDecimalFromDouble(0.0f);
self.barPlot.fill = [CPTFill fillWithColor:[CPTColor colorWithComponentRed:100.0f/255.0f green:192.0f/255.0f blue:245.0f/255.0f alpha:1.0f]];
[graph addPlot:self.barPlot toPlotSpace:(CPTPlotSpace *) graph.defaultPlotSpace];
}
- (void) configureAxes {
// 1 - Configure styles
CPTMutableTextStyle *axisLabelsStyle = [CPTMutableTextStyle textStyle];
axisLabelsStyle.color = [CPTColor grayColor];
axisLabelsStyle.fontName = @"Helvetica";
// 2 - Get the graph's axis set
CPTXYAxisSet *axisSet = (CPTXYAxisSet *) self.barChartView.hostedGraph.axisSet;
axisSet.xAxis.axisLineStyle = nil;
axisSet.xAxis.labelingPolicy = CPTAxisLabelingPolicyNone;
axisSet.xAxis.labelTextStyle = axisLabelsStyle;
NSArray *customTickLocations = [NSArray arrayWithObjects: [NSDecimalNumber numberWithInt:0], [NSDecimalNumber numberWithInt:1], [NSDecimalNumber numberWithInt:2], [NSDecimalNumber numberWithInt:3], [NSDecimalNumber numberWithInt:4], [NSDecimalNumber numberWithInt:5], [NSDecimalNumber numberWithInt:6], [NSDecimalNumber numberWithInt:7], [NSDecimalNumber numberWithInt:8], [NSDecimalNumber numberWithInt:9], [NSDecimalNumber numberWithInt:10], [NSDecimalNumber numberWithInt:11], [NSDecimalNumber numberWithInt:11], nil];
NSArray *xAxisLabels = [[[PlotDataStore sharedInstance] docsCount] valueForKey:@"dates"];
NSMutableArray *customLabels = [NSMutableArray arrayWithCapacity:[xAxisLabels count]];
for (NSNumber *tickLocation in customTickLocations) {
CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText: [xAxisLabels objectAtIndex:[tickLocation intValue]] textStyle:axisSet.xAxis.labelTextStyle];
newLabel.tickLocation = [tickLocation decimalValue];
newLabel.offset = axisSet.xAxis.labelOffset + axisSet.xAxis.minorTickLength;
[customLabels addObject:newLabel];
}
axisSet.xAxis.axisLabels = [NSSet setWithArray:customLabels];
axisSet.yAxis.labelingPolicy = CPTAxisLabelingPolicyNone;
axisSet.yAxis.axisLineStyle = nil;
axisSet.yAxis.axisLabels = nil;
}
- (NSUInteger) numberOfRecordsForPlot:(CPTPlot *)plot {
if ([plot class] == [CPTBarPlot class]) {
return (NSUInteger)[[[[PlotDataStore sharedInstance] docsCount] valueForKey:@"docs"] count];
}
return 0;
}
- (NSNumber *) numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index {
if ([plot class] == [CPTBarPlot class]) {
switch (fieldEnum) {
case CPTBarPlotFieldBarLocation:
return [NSNumber numberWithUnsignedInteger:index];
break;
case CPTBarPlotFieldBarTip:
return (NSNumber *)[[[[PlotDataStore sharedInstance] docsCount] valueForKey:@"docs"] objectAtIndex:index];
break;
}
}
}
여기에 코드를 표시하십시오. – Retro
코드로 질문을 수정했습니다. – ShurupuS