如何仅通过自动传递 yMin 和 yMax 图表来创建动态 y 轴并显示非常清晰。
例如,我的数据是 Y 轴 99.7, 99.3, 99.2, 99.0 ,100 。
所以我希望 y 轴最小值从 99 开始到 100,增量为 0.1,图表将显示得非常清晰。
我的代码片段如下 // 4 - 配置 y 轴
y_monthly.title = lbl_M_HasDelay.text;
y_monthly.labelAlignment = CPTAlignmentCenter;
y_monthly.titleTextStyle = axisTitleStyle;
y_monthly.titleOffset = -30.0f;
y_monthly.axisLineStyle = axisLineStyle;
y_monthly.majorGridLineStyle = gridLineStyle;
y_monthly.labelingPolicy = CPTAxisLabelingPolicyNone;
y_monthly.labelTextStyle = axisTextStyle;
y_monthly.labelOffset = 16.0f;
y_monthly.majorTickLineStyle = axisLineStyle;
y_monthly.majorTickLength = 4.0f;
y_monthly.minorTickLength = 2.0f;
y_monthly.tickDirection = CPTSignPositive;
NSMutableSet *yLabels = [NSMutableSet set];
NSMutableSet *yMajorLocations = [NSMutableSet set];
NSMutableSet *yMinorLocations = [NSMutableSet set];
float minorIncrement=month_MaxY1/10;
float majorIncrement = minorIncrement*2;
float yMax = month_MaxY1;
for (float j = minorIncrement; j <= yMax; j += minorIncrement)
{
float mod = fmodf(j, majorIncrement);
if (mod == 0) {
CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[NSString stringWithFormat:@""]textStyle:y_monthly.labelTextStyle];
[label setAlignment:CPTAlignmentTop];
NSDecimal location = CPTDecimalFromFloat(j);
label.tickLocation = location;
label.offset = -y_monthly.majorTickLength - y_monthly.labelOffset;
if (label) {
[yLabels addObject:label];
}
[yMajorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:location]];
} else {
[yMinorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:CPTDecimalFromFloat(j)]];
}
}
y_monthly.axisLabels = yLabels;
y_monthly.majorTickLocations = yMajorLocations;
y_monthly.minorTickLocations = yMinorLocations;
其中month_MaxY1 =100,而month_MinY1 =90.0。请帮我