我正在尝试制作带有核心图的条形图。我无法正确缩放 y 轴或正确位置的刻度线。我最大的问题是,如果我设置:
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) graph.defaultPlotSpace;
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDEcimalFromFloat(0) length:CPTDecimalFromFloat(max_value);
并且 max_value 高于 10 需要不合理的时间来加载图表。例如,我需要 max_value 大约为 1000 以显示所有值的顶部,但是当我将其设置为 1000 时,加载屏幕需要超过 15 秒。但是,如果我将其设置为 10,我的条形图会占据整个屏幕,而您看不到顶部。
这是处理此问题的代码的其余部分。任何意见,将不胜感激。
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) graph.defaultPlotSpace;
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0)
length:CPTDecimalFromFloat(1000)];
[plotSpace scaleToFitPlots:[NSArray arrayWithObjects:_liftOffPlot,_sideLeanPlot,_forwardLeanPlot,_crossLegsPlot,nil]];
graph.plotAreaFrame.borderLineStyle = nil;
axisSet.yAxis.title = @"times completed";
axisSet.yAxis.titleTextStyle = axisTitleStyle;
axisSet.yAxis.titleOffset = -25.0f;
axisSet.yAxis.axisLineStyle = nil;
axisSet.yAxis.labelingPolicy = CPTAxisLabelingPolicyAutomatic;
axisSet.yAxis.preferredNumberOfMajorTicks = 10;
axisSet.yAxis.minorTicksPerInterval = 1;
axisSet.yAxis.minorTickLocations = nil;
axisSet.yAxis.majorTickLocations = nil;
axisSet.yAxis.title = @"times completed";
axisSet.yAxis.titleTextStyle = axisTitleStyle;
axisSet.yAxis.titleOffset = -25.0f;
axisSet.yAxis.axisLineStyle = nil;
axisSet.yAxis.majorIntervalLength = CPTDecimalFromString(@"100");
axisSet.yAxis.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0");
axisSet.yAxis.visibleRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromInt(0) length:CPTDecimalFromInt(1000)];
axisSet.yAxis.gridLinesRange = axisSet.yAxis.visibleRange;