我想绘制一个具有最大Y轴值标签的图形显示在标签滴答与CPATISLISPLICALIN政策自动设置。但是我没有发现任何公共职能允许我这么做。
在检查了CorePlot源代码(autoGenerateMajorTickLocations方法)之后,我想我可以使用CPTDecimalDivide和CPTNiceNum来做一些变通。通过在y轴上增加我的绘图,用计算出的“好数字”间隔来实现我的代码。
var majorInterval = CPTDecimalDivide( Decimal(yAxisLength),
CPTDecimalFromUnsignedInteger(5-1))
majorInterval = CPTNiceNum(majorInterval)
let interval = Int(truncating: majorInterval as NSNumber)
let number = Int(yAxisLength/interval) + 1
yAxisLength = Int(Double(number * interval))
然而,CPTNiceNum不是一个公共方法,所以我想知道有没有更好的方法可以做到这一点?
最佳答案
在图上调用-layoutIfNeeded
以确保轴标签被更新,然后从y轴读取majorTickLocations
集合。您可以在集合中轻松找到最大位置值。
关于ios - 使用CorePlot CPTAxisLabelingPolicyAutomatic设置显示最大y轴,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52383916/