現在、iPadアプリケーションに取り組んでいます。Core-Plotを使用してiPhoneアプリケーションで棒グラフを作成し、iPadのフレームサイズを変更してiPadアプリケーションに同じものをインポートしましたが、棒グラフが小さく表示されています。画面に表示されますが、iPadで全画面表示したいのですが、これを修正するにはどうすればよいですか?私を助けてください
前もって感謝します
私はこれを試しました
iPhone
-(void) drawBarChart
{
NSLog(@"iPhone Bar chart");
double xAxisLength = [barValuesArray count];
barGraph = [[CPTXYGraph alloc] initWithFrame:CGRectMake(0, 50, 320, 350)];
barGraph.paddingLeft = 0.0f;
barGraph.paddingRight = 0.0f;
barGraph.paddingTop = 0.0f;
barGraph.paddingBottom = 0.0f;
barGraph.plotAreaFrame.paddingLeft = 60.0;
barGraph.plotAreaFrame.paddingTop = 40.0;
barGraph.plotAreaFrame.paddingRight = 10.0;
barGraph.plotAreaFrame.paddingBottom = 40.0;
if ([selectedName isEqualToString:@"(null)"] || [selectedName isEqualToString:@""] || [selectedName isEqualToString:@"NULL"] || selectedName == @"(null)" || selectedName == NULL || selectedName == @"null" || selectedName == nil)
{
barGraph.title = [namesArray objectAtIndex:0];
}
else
{
barGraph.title = selectedName;
}
hostingView = [[CPTGraphHostingView alloc] initWithFrame:CGRectMake(0, 10, 320, 400)];
hostingView.hostedGraph = barGraph;
CPTMutableTextStyle *textStyle = [CPTTextStyle textStyle];
textStyle.color = [CPTColor blackColor];
textStyle.fontSize = 16.0f;
textStyle.textAlignment = CPTTextAlignmentCenter;
barGraph.titleTextStyle = textStyle;
barGraph.titleDisplacement = CGPointMake(0.0f, -10.0f);
barGraph.titlePlotAreaFrameAnchor = CPTRectAnchorTop;
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)barGraph.axisSet;
CPTXYAxis *x = axisSet.xAxis;
// x.axisLineStyle = nil;
// x.majorTickLineStyle = nil;
// x.minorTickLineStyle = nil;
x.majorIntervalLength = CPTDecimalFromString(@"70");
x.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0");
x.title = @"Names";
x.titleLocation = CPTDecimalFromFloat(7.5f);
x.titleOffset = 50.0f; //25.0f;
x.labelRotation = M_PI/5;
x.labelingPolicy = CPTAxisLabelingPolicyNone;
NSArray *customTickLocations = [NSArray arrayWithObjects: [NSDecimalNumber numberWithInt:1], [NSDecimalNumber numberWithInt: 5], [NSDecimalNumber numberWithInt:9], [NSDecimalNumber numberWithInt:13], nil];
// NSArray *xAxisLabels = [NSArray arrayWithObjects:@"Smoke", @"Nicotine", @"Tar", @"", nil];
// NSUInteger labelLocation = 0;
//
// NSMutableArray *customLabels = [NSMutableArray arrayWithCapacity:[xAxisLabels count]];
// for (NSNumber *tickLocation in customTickLocations)
// {
// CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText: [xAxisLabels objectAtIndex:labelLocation++] textStyle:x.labelTextStyle];
// newLabel.tickLocation = [tickLocation decimalValue];
// newLabel.offset = x.labelOffset + x.majorTickLength;
// newLabel.rotation = M_PI/xAxisLength;
// [customLabels addObject:newLabel];
// [newLabel release];
// }
//
// x.axisLabels = [NSSet setWithArray:customLabels];
CPTXYAxis *y = axisSet.yAxis;
// y.axisLineStyle = nil;
// y.majorTickLineStyle = nil;
// y.minorTickLineStyle = nil;
y.majorIntervalLength = CPTDecimalFromString(@"100");
y.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0");
// y.title = @"Work Status";
// y.titleOffset = 40.0f;
// y.titleLocation = CPTDecimalFromFloat(150.0f);
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) barGraph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0f) length:CPTDecimalFromDouble(15.0f)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0f) length:CPTDecimalFromDouble(1000.0f)];
CPTBarPlot *barPlot = [CPTBarPlot tubularBarPlotWithColor:[CPTColor blueColor] horizontalBars:NO];
barPlot.plotRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0) length:CPTDecimalFromDouble(13)];//xAxisLength
barPlot.barOffset = CPTDecimalFromFloat(1.0f);
barPlot.baseValue = CPTDecimalFromString(@"0");
barPlot.barWidth = CPTDecimalFromFloat(3.0f);
barPlot.cornerRadius = 2.0f;
barPlot.dataSource = self;
[barGraph addPlot:barPlot];
[self.view addSubview:hostingView];
}
iPad棒グラフ:
-(void) drawBarChart
{
NSLog(@"iPAD");
double xAxisLength = [barValuesArray count];
barGraph = [[CPTXYGraph alloc] initWithFrame:CGRectMake(0, 50, 700, 1000)];
barGraph.paddingLeft = 0.0f;
barGraph.paddingRight = 0.0f;
barGraph.paddingTop = 0.0f;
barGraph.paddingBottom = 0.0f;
barGraph.plotAreaFrame.paddingLeft = 60.0;
barGraph.plotAreaFrame.paddingTop = 40.0;
barGraph.plotAreaFrame.paddingRight = 10.0;
barGraph.plotAreaFrame.paddingBottom = 40.0;
if ([selectedName isEqualToString:@"(null)"] || [selectedName isEqualToString:@""] || [selectedName isEqualToString:@"NULL"] || selectedName == @"(null)" || selectedName == NULL || selectedName == @"null" || selectedName == nil)
{
barGraph.title = [namesArray objectAtIndex:0];
}
else
{
barGraph.title = selectedName;
}
hostingView = [[CPTGraphHostingView alloc] initWithFrame:CGRectMake(0, 10, 700, 1000)];
hostingView.hostedGraph = barGraph;
CPTMutableTextStyle *textStyle = [CPTTextStyle textStyle];
textStyle.color = [CPTColor blackColor];
textStyle.fontSize = 16.0f;
textStyle.textAlignment = CPTTextAlignmentCenter;
barGraph.titleTextStyle = textStyle;
barGraph.titleDisplacement = CGPointMake(0.0f, -10.0f);
barGraph.titlePlotAreaFrameAnchor = CPTRectAnchorTop;
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)barGraph.axisSet;
CPTXYAxis *x = axisSet.xAxis;
// x.axisLineStyle = nil;
// x.majorTickLineStyle = nil;
// x.minorTickLineStyle = nil;
x.majorIntervalLength = CPTDecimalFromString(@"70");
x.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0");
x.title = @"Names";
x.titleLocation = CPTDecimalFromFloat(7.5f);
x.titleOffset = 50.0f; //25.0f;
x.labelRotation = M_PI/5;
x.labelingPolicy = CPTAxisLabelingPolicyNone;
NSArray *customTickLocations = [NSArray arrayWithObjects: [NSDecimalNumber numberWithInt:1], [NSDecimalNumber numberWithInt: 5], [NSDecimalNumber numberWithInt:9], [NSDecimalNumber numberWithInt:13], nil];
// NSArray *xAxisLabels = [NSArray arrayWithObjects:@"Smoke", @"Nicotine", @"Tar", @"", nil];
// NSUInteger labelLocation = 0;
//
// NSMutableArray *customLabels = [NSMutableArray arrayWithCapacity:[xAxisLabels count]];
// for (NSNumber *tickLocation in customTickLocations)
// {
// CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText: [xAxisLabels objectAtIndex:labelLocation++] textStyle:x.labelTextStyle];
// newLabel.tickLocation = [tickLocation decimalValue];
// newLabel.offset = x.labelOffset + x.majorTickLength;
// newLabel.rotation = M_PI/xAxisLength;
// [customLabels addObject:newLabel];
// [newLabel release];
// }
//
// x.axisLabels = [NSSet setWithArray:customLabels];
CPTXYAxis *y = axisSet.yAxis;
// y.axisLineStyle = nil;
// y.majorTickLineStyle = nil;
// y.minorTickLineStyle = nil;
y.majorIntervalLength = CPTDecimalFromString(@"100");
y.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0");
// y.title = @"Work Status";
// y.titleOffset = 40.0f;
// y.titleLocation = CPTDecimalFromFloat(150.0f);
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) barGraph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0f) length:CPTDecimalFromDouble(15.0f)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0f) length:CPTDecimalFromDouble(1000.0f)];
CPTBarPlot *barPlot = [CPTBarPlot tubularBarPlotWithColor:[CPTColor blueColor] horizontalBars:NO];
barPlot.plotRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(0.0) length:CPTDecimalFromDouble(13)];//xAxisLength
barPlot.barOffset = CPTDecimalFromFloat(1.0f);
barPlot.baseValue = CPTDecimalFromString(@"0");
barPlot.barWidth = CPTDecimalFromFloat(3.0f);
barPlot.cornerRadius = 2.0f;
barPlot.dataSource = self;
[barGraph addPlot:barPlot];
[self.view addSubview:hostingView];
}