iPhone COREPLOT:条形图无法正确显示

问题描述 投票:0回答:1

在我的 iPhone 应用程序中,我正在实现 coreplot VerticalBar 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");

这里我给出了刻度线位置的值

  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];   
iphone cocoa-touch core-plot
1个回答
1
投票

仔细看这条线

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

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

© www.soinside.com 2019 - 2024. All rights reserved.