Finding data on line chart (SwiftCharts)

126 Views Asked by At

I created a line chart using SwiftCharts. Now I am trying to find the data on the chart. User gonna input numbers, which meets x any y axis and swift should mark the intersection of these two and tell the user where their data on the line chart is. Is it above these lines if yes, above from which and below from which one as a pop up or on a text. Thank you...

@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
    }
0

There are 0 best solutions below