gpt4 book ai didi

ios - 如何更新 IOS 图表中的限制线,danielgindi/Charts

转载 作者:搜寻专家 更新时间:2023-10-31 22:54:36 24 4
gpt4 key购买 nike

所以我添加了一些限制线。

func addLimitLines() {
let stopLoss = ChartLimitLine(limit: Double(1.70) , label: "stop loss")
stopLoss.lineWidth = 0.5
stopLoss.lineColor = .blue
stopLoss.lineDashLengths = [8.0]
chartView.rightAxis.addLimitLine(stopLoss)

let takeProfit = ChartLimitLine(limit: Double(1.68), label: "take profit")
takeProfit.lineWidth = 0.5
takeProfit.lineColor = .blue
takeProfit.lineDashLengths = [8.0]
chartView.rightAxis.addLimitLine(takeProfit)
chartView.reloadInputViews()
}

@IBAction func stopLossChange(_ sender: UISlider) {
//slider action for updating the stoploss limitline
}

@IBAction func takeProfitChange(_ sender: UISlider) {
//slider action for updating the takeprofit limitline
}

现在我想在移动 slider 时更新限制线值。 enter image description here

最佳答案

虽然在Android Charts 版本我们有 invalidate() 刷新 chartView 但在 iOS 中我看不到它可用。在 iOS 中,我使用 animate 方法更新数据,我相信你也可以按如下方式实现这一点,

@IBAction func stopLossChange(_ sender: UISlider) {
self.updateLineLimit(Double(sender.value), label: "stop loss")
}

@IBAction func takeProfitChange(_ sender: UISlider) {
self.updateLineLimit(Double(sender.value), label: "take profit")
}

private func updateLineLimit(_ value: Double, label: String) {
if let line = chartView.rightAxis.limitLines.filter({ $0.label == label }).first {
line.limit = value
chartView.animate(yAxisDuration: 0.00001)
}
}

关于ios - 如何更新 IOS 图表中的限制线,danielgindi/Charts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51259158/

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