iPhone核心图:条形图无法正常显示

时间:2011-04-19 09:22:12

标签: iphone cocoa-touch core-plot

您好,在我的iPhone应用程序中,我正在实施coreplot VarticalBar Chart

虽然我对Y轴采取较大的值,但它只显示到某个限制,如图所示,它只显示N500000,但实际上我传递的值更大。 (我通过下面给出的图形数组传递值)

可能是什么问题?

请帮助。

这是图片和代码,

enter image description here

我在这里为YRange传递价值

plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-5000000)length:CPDecimalFromFloat(10000000)];  plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0.0f)length:CPDecimalFromFloat(21.0f)];

生成Y轴标签的代码

CPXYAxis *y = axisSet.yAxis;
y.axisLineStyle =nil;
               y.majorTickLineStyle = nil;
       y.minorTickLineStyle = nil;
y.majorIntervalLength = CPDecimalFromString(@"2500000");
y.orthogonalCoordinateDecimal = CPDecimalFromString(@"0.0");

这里我给出了Tick标记位置的值

  NSArray *marginArray =[NSArray arrayWithObjects:
                       [NSDecimalNumber numberWithInt:-5000000],
                       [NSDecimalNumber numberWithInt:-2500000],
                       [NSDecimalNumber numberWithInt:00],
                       [NSDecimalNumber numberWithInt:2500000],
                       [NSDecimalNumber numberWithInt:5000000],
                       [NSDecimalNumber numberWithInt:7500000],
                       [NSDecimalNumber numberWithInt:10000000],
                       nil];

我在这里给出了标签名称

y.labelingPolicy = CPAxisLabelingPolicyNone;
NSArray *yAxisLabels1 = [NSArray arrayWithObjects:@"-N5000000", @"-N2500000",@"N0",@"N2500000",@"N5000000", @"N7500000",@"N10000000", nil];

 int labelLocation1;
labelLocation1 = 0;

NSMutableArray *custLabels1 = [NSMutableArray arrayWithCapacity:[yAxisLabels1 count]];
NSLog(@" %d",[yAxisLabels1 count]);

for (NSNumber *tickLocat1 in marginArray) 
{  
    CPAxisLabel *newLabel1 = [[CPAxisLabel alloc] initWithText: [yAxisLabels1 objectAtIndex:labelLocation1++]  
                                                             textStyle:y.labelTextStyle]; 
    newLabel1.tickLocation = [tickLocat1 decimalValue]; 
    newLabel1.offset = 3.0;//y.labelOffset; 
    [custLabels1 addObject:newLabel1];
    [newLabel1 release];
}
y.axisLabels =  [NSSet setWithArray:custLabels1];
y.majorTickLocations =  [NSSet setWithArray:marginArray]; 
y.title = @"Y Axis";
y.titleOffset = 45.0f;       
      y.titleLocation = CPDecimalFromFloat(150.0f);

我正在传递此数组以绘制图形

NSArray *roiGraph = [NSArray arrayWithObjects:
                                 [NSDecimalNumber numberWithInt:-5000000],                                                                                                                    
                                 [NSDecimalNumber numberWithInt:5000],    
                                 [NSDecimalNumber numberWithInt:10000000],                                                                      
                                 [NSDecimalNumber numberWithInt:-5000000],  
                                 [NSDecimalNumber numberWithInt:9000000],                                                                                                                                     
                                 [NSDecimalNumber numberWithInt:20005],   
                                 [NSDecimalNumber numberWithInt:50000],
                                 [NSDecimalNumber numberWithInt:7500000],     
                                 [NSDecimalNumber numberWithInt:400000],    
                                 [NSDecimalNumber numberWithInt:220000],     
                                 nil];   

1 个答案:

答案 0 :(得分:1)

仔细看看这一行

 plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-5000000) length:CPDecimalFromFloat(10000000)];

您将长度设置为10毫升,这意味着可见区域为(-5毫升至+5毫升)。将长度设置为其他值,例如15百万,然后再次查看结果。