我有一个图表区域,我可以选择在其中绘制不同的属性。每个属性都定义了自己的 y 轴范围。下图显示了四舍五入到最近单位的 y 轴标签(看起来不干净)。
我该怎么做才能根据所绘制的数据将 y 轴标签四舍五入到最接近的百万分之一、千分之一或百分之一?
我还认为我可以将 y 轴的下限和上限设置为那些四舍五入的数字,这样我以后就可以设置一个偶数增量,从而为我提供那些更好看的标签。我怎样才能得到这些四舍五入的限制?
我现在正在做的设置这些限制如下:
//Look up the absolute minimum and absolute maximum values
NSNumber * min = [allArraysDrawn valueForKeyPath:@"@min.intValue"];
NSNumber * max = [allArraysDrawn valueForKeyPath:@"@max.intValue"];
//Define the limits of the plot area with a cushion both above the max value and below the min value
float yAxisMin = [min floatValue] - (([max floatValue] - [min floatValue]) * 0.05);
float yAxisMax = [max floatValue] + (([max floatValue] - [min floatValue]) * 0.05);
有任何想法吗?谢谢!