iPhone:在我的核心绘图图上看不到任何标签

iPhone:在我的核心绘图图上看不到任何标签,iphone,core-plot,Iphone,Core Plot,我正在构建一个带有核心图的图形,除了在x轴和y轴上看不到任何标签外,它运行良好。我只能看到主刻度和次刻度,但旁边没有值。一定有什么我遗漏了,但我不知道是什么。此外,是否可以为每个轴添加标签,例如:x(小时)、y(值) 我正在处理的图形是listview第一行的一部分 代码是: NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"GraphCustomViewCell" owner:nil opt

我正在构建一个带有核心图的图形,除了在x轴和y轴上看不到任何标签外,它运行良好。我只能看到主刻度和次刻度,但旁边没有值。一定有什么我遗漏了,但我不知道是什么。此外,是否可以为每个轴添加标签,例如:x(小时)、y(值)

我正在处理的图形是listview第一行的一部分

代码是:

            NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"GraphCustomViewCell" owner:nil options:nil];

            for(id currentObject in topLevelObjects)
            {
                if([currentObject isKindOfClass:[GraphCustomViewCell class]])
                {
                    cell = (GraphCustomViewCell *)currentObject;
                    break;
                }
            }

            CGRect frame = cell.contentView.bounds;

            CPLayerHostingView *hostingView = [[CPLayerHostingView alloc] initWithFrame: frame];
            [cell addSubview:hostingView];

            // Create graph
            CPTheme *theme = [CPTheme themeNamed:kCPPlainWhiteTheme];
            graph = (CPXYGraph *)[theme newGraph];  

            // Add graph to view
            hostingView.hostedLayer = graph;
            graph.paddingLeft = 50.0;
            graph.paddingTop = 5.0;
            graph.paddingRight = 5.0;
            graph.paddingBottom = 25.0;

            // Adjust graph
            float xmax = [[[self arrayFromData] objectForKey:@"data"] count];
            CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
            plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0)
                                                           length:CPDecimalFromFloat(xmax)];
            plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0)
                                                           length:CPDecimalFromFloat(3000)];

            CPTextStyle *blackText = [[CPTextStyle textStyle] color:[CPColor blackColor]];
            CPLineStyle *lineStyle = [CPLineStyle lineStyle];
            lineStyle.lineColor = [CPColor blackColor];
            lineStyle.lineWidth = 1.0f;

            axisSet.xAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"5"] decimalValue];
            axisSet.xAxis.minorTicksPerInterval = 4;
            axisSet.xAxis.majorTickLineStyle = lineStyle;
            axisSet.xAxis.minorTickLineStyle = lineStyle;
            axisSet.xAxis.axisLineStyle = lineStyle;
            axisSet.xAxis.minorTickLength = 4.0f;
            axisSet.xAxis.majorTickLength = 8.0f;
            axisSet.xAxis.labelOffset = 3.0f;
            axisSet.xAxis.labelTextStyle = blackText;


            axisSet.yAxis.majorIntervalLength = [[NSDecimalNumber decimalNumberWithString:@"500"] decimalValue];
            axisSet.yAxis.minorTicksPerInterval = 4;
            axisSet.yAxis.majorTickLineStyle = lineStyle;
            axisSet.yAxis.minorTickLineStyle = lineStyle;
            axisSet.yAxis.axisLineStyle = lineStyle;
            axisSet.yAxis.minorTickLength = 4.0f;
            axisSet.yAxis.majorTickLength = 8.0f;
            axisSet.yAxis.labelOffset = 1.0f;

            CPScatterPlot *dataSourceLinePlot = [[[CPScatterPlot alloc] init] autorelease];
            dataSourceLinePlot.identifier = @"MyGraph";
            dataSourceLinePlot.dataLineStyle.lineWidth = 1.f;
            dataSourceLinePlot.dataLineStyle.lineColor = [CPColor greenColor];
            dataSourceLinePlot.dataSource = self;
            [graph addPlot:dataSourceLinePlot];

            // Put an area gradient under the plot above
            CPColor *areaColor = [CPColor colorWithComponentRed:0.3 
                                                          green:1.0
                                                           blue:0.3
                                                          alpha:0.3];
            CPGradient *areaGradient = [CPGradient gradientWithBeginningColor:areaColor 
                                                                  endingColor:[CPColor clearColor]];
            areaGradient.angle = -90.0f;
            CPFill *areaGradientFill = [CPFill fillWithGradient:areaGradient];
            dataSourceLinePlot.areaFill = areaGradientFill;
            dataSourceLinePlot.areaBaseValue = CPDecimalFromString(@"1.75");
非常感谢, 当做, 卢克


ps:quick edit,我已使用graph.name=“my graph”进行了检查,但图形上没有显示任何内容。好的,这是因为要显示的标签太多,而且轴在负片区域走得不够远=>没有显示标签的位置。但是,graph.name不显示图形的名称