我想将当前显示的数据范围。 读文件,看来我应该能够使用moveViewToX
功能视图的左侧移动到指定的x值。
我做了有1查看带有按钮的测试代码。 该曲线图显示正确时在模拟器视图负载。 当点击该按钮时,它调用moveViewToX
。 然而,没有任何反应,当我点击该按钮(打印文本打印按钮被点击时要安慰,图形视图保持不变)。
import Charts
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//Setup Test Chart
self.lineChartView.data = LineChartData(dataSet: lineChartDataSet())
}
fileprivate func lineChartDataSet() -> LineChartDataSet {
var dataEntries = [ChartDataEntry]()
dataEntries.append(ChartDataEntry(x: 1, y: 2))
dataEntries.append(ChartDataEntry(x: 3, y: 5))
dataEntries.append(ChartDataEntry(x: 5, y: 10))
dataEntries.append(ChartDataEntry(x: 6, y: 2))
dataEntries.append(ChartDataEntry(x: 10, y: 15))
dataEntries.append(ChartDataEntry(x: 12, y: 7))
dataEntries.append(ChartDataEntry(x: 20, y: 10))
dataEntries.append(ChartDataEntry(x: 30, y: 15))
return LineChartDataSet(values: dataEntries, label: "Test Data")
}
@IBAction func buttonClick(_ sender: UIButton) {
print("Button clicked")
self.lineChartView.moveViewToX(5)
}
@IBOutlet weak var lineChartView: LineChartView!
}