gpt4 book ai didi

ios - 丹尼尔金迪/图表 : get left yAxis width

转载 作者:行者123 更新时间:2023-11-28 23:22:54 24 4
gpt4 key购买 nike

有没有办法得到左边的 yAxis 宽度?我正在绘制自定义标记,并希望避免在左侧 yAxis 上绘制。

这个库的 android 版本有一个解决方案,但由于渲染方法不同,它在 iOS 中不起作用:How to get the width of y-axis label in MPAndroidChart

最佳答案

您可以通过 requiredSize() 方法检索轴宽度。

chartView.leftAxis.requiredSize()

这就是 requiredSize() 方法实际做的事情:

@objc open func requiredSize() -> CGSize
{
let label = getLongestLabel() as NSString
var size = label.size(withAttributes: [NSAttributedString.Key.font: labelFont])
size.width += xOffset * 2.0
size.height += yOffset * 2.0
size.width = max(minWidth, min(size.width, maxWidth > 0.0 ? maxWidth : size.width))
return size
}

仅在设置图表数据后使用此选项,因为图表会自动计算轴上最长标签的宽度。

希望对你有帮助

关于ios - 丹尼尔金迪/图表 : get left yAxis width,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59360042/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com