IOS で coreplot を使用しています。同じグラフに散布図と棒グラフを表示しています。それらが表示されると、棒グラフが画面の上部に表示されるため、背後にある散布図が実際には見えません。散布図を前景に配置したいと思います。
どうやってやるの?
以下のコードを参照してください。どんな助けでも大歓迎です
// Create barChart from theme
barChart = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme]; //
[barChart applyTheme:theme];
theHostingView.hostedGraph = barChart;
// Border
barChart.plotAreaFrame.borderLineStyle = nil;
barChart.plotAreaFrame.cornerRadius = 0.0f;
// Paddings
barChart.paddingLeft = 0.0f;
barChart.paddingRight = 0.0f;
barChart.paddingTop = 0.0f;
barChart.paddingBottom = 0.0f;
// Offset pour placer les coordoonees du graph
barChart.plotAreaFrame.paddingLeft = 70.0;
barChart.plotAreaFrame.paddingTop = 20.0;
barChart.plotAreaFrame.paddingRight = 15.0;
barChart.plotAreaFrame.paddingBottom = 35.0;
// Graph title
[self configureTitle];
// Add plot space for horizontal bar charts
_plotSpace = (CPTXYPlotSpace *)barChart.defaultPlotSpace;
float minAxis = 0.0;
if ([_theKPI.unit isEqualToString:@"%"]) {
float intervalSize = ((_maxValue - minAxis)/100.0)/4;
minAxis = _minValue - intervalSize;
if (minAxis <= 0) {
minAxis = 0.0;
}
_plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(minAxis/100.0) length:CPTDecimalFromFloat((_maxValue - minAxis)/100.0)];
} else {
if (_minValue >= 0) {
_plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(_maxValue)];
} else {
_plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(_minValue)];
}
}
CPTXYAxis* xAxis = [[CPTXYAxis alloc] initWithFrame:CGRectZero];
CPTXYAxis* yAxis = [[CPTXYAxis alloc] initWithFrame:CGRectZero];
xAxis.plotSpace = _plotSpace;
yAxis.plotSpace = _plotSpace;
[self configureXAxis:xAxis min:minAxis plotSpace:_plotSpace];
[self configureYAxis:yAxis min:minAxis];
CPTXYPlotSpace* secondPlotSpace = [[CPTXYPlotSpace alloc] init];
secondPlotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(50.0)];
[self configurePlotSpace:secondPlotSpace];
[barChart addPlotSpace:secondPlotSpace];
CPTXYAxis* yRightAxis = [[CPTXYAxis alloc] initWithFrame:CGRectZero];
yRightAxis.plotSpace = secondPlotSpace;
[self configureYRightAxis:yRightAxis];
barChart.axisSet.axes = [NSArray arrayWithObjects:xAxis, yAxis, yRightAxis, nil];
// Configure the Scatter Plot
_plot = [[CPTScatterPlot alloc] init];
_plot.dataSource = self;
_plot.identifier = @"mainplot";
CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];
lineStyle.lineColor = [CPTColor whiteColor];
lineStyle.lineWidth = 3.0f;
_plot.dataLineStyle = lineStyle;
CPTPlotSymbol* greenCirclePlotSymbol = [CPTPlotSymbol ellipsePlotSymbol];
greenCirclePlotSymbol.fill = [CPTFill fillWithColor:[CPTColor blueColor]];
greenCirclePlotSymbol.size = CGSizeMake(5.0, 5.0);
_plot.plotSymbol = greenCirclePlotSymbol;
// Configure the Bar Plot
_barPlot = [CPTBarPlot tubularBarPlotWithColor:[CPTColor blueColor] horizontalBars:NO];
_barPlot.baseValue = CPTDecimalFromString(@"0");
_barPlot.dataSource = self;
_barPlot.delegate = self;
_barPlot.barOffset = CPTDecimalFromFloat(-0.25f);
_barPlot.identifier = @"Bar Plot 1";
[barChart addPlot:_plot toPlotSpace:secondPlotSpace];
[barChart addPlot:_barPlot];
セブ。