我使用 SwiftCharts 创建了一个折线图。现在我试图在图表上找到数据。用户要输入满足x任意y轴的数字,swift应该标记这两者的交点,并告诉用户他们的数据在折线图上的位置。如果是的话,是否在这些行之上,在哪个之上和之下来自哪个作为弹出窗口或文本。谢谢...
@IBAction func displayChart(_ sender: Any) {
let chartConfig = ChartConfigXY(
xAxisConfig: ChartAxisConfig(from: 0, to:192 , by: 24),
yAxisConfig: ChartAxisConfig(from: 0, to: 22, by: 1)
)
let frame = CGRect(x: 10, y: 100, width: self.view.frame.width-50, height: 550)
let chart = LineChart(frame: frame, chartConfig: chartConfig, xTitle: "Postnatal Age Hours", yTitle: "Total Bilirubin mg/dl" ,
lines: [
(chartPoints:[(0, 4.0), (12, 6.0), (24, 8.0), (36, 9.5), (48, 11.0), (60, 12.5), (72, 13.5), (84, 14.0), (96, 14.5), (108, 14.9), (120, 15.0), (132, 15.0), (144, 15.0), (156, 15.0), (168, 15.0)], color: UIColor.red),
(chartPoints:[(0, 5.0), (12, 7.5), (24, 10.0), (36, 11.8), (48, 13.0), (60, 14.5), (72, 15.1), (84, 16.4), (96, 17.1), (108, 18.0), (120, 18.0), (120, 18.0), (132, 18.0), (144, 18.0), (156, 18.0), (168, 18.0)], color : UIColor.blue),
(chartPoints:[(0, 6.5), (12, 9.0), (24, 11.5), (36, 13.5), (48, 15.0), (60, 16.5), (72, 17.5), (84, 19.0), (96, 20.0), (108, 20.5), (120, 21.0), (132, 21.0), (144, 21.0), (156, 21.0), (168, 21.0)], color: UIColor.green)
])
self.view.addSubview(chart.view)
self.pttChartView = chart
}