gpt4 book ai didi

ios - iOS图表更改网格线颜色

转载 作者:行者123 更新时间:2023-12-01 21:59:47 25 4
gpt4 key购买 nike

我做了一个小应用程序,通过iWatch测量心率。该图表按预期工作,显示了当前的心律,但是我在设计中遇到了几个问题。您可以在下面快速找到我的图表的图像及其设置。

ios Chart

         //chart set up
self.chtChart.delegate = self as? ChartViewDelegate
self.chtChart.noDataTextColor = UIColor.white
self.chtChart.noDataText = "Press Start button to display the chart"

let set_a: LineChartDataSet = LineChartDataSet(entries:[ChartDataEntry(x: Double(Int(0)), y: self.valueHR)], label: "BPM")
set_a.drawCirclesEnabled = false
set_a.setColor(UIColor.systemPink)
set_a.drawValuesEnabled = false
set_a.lineWidth = 5.0

//remove vertical grid and labels
self.chtChart.xAxis.drawGridLinesEnabled = false
self.chtChart.rightAxis.drawLabelsEnabled = false
self.chtChart.xAxis.drawLabelsEnabled = false

//change label 'BPM' color
self.chtChart.legend.textColor = UIColor.white
//change left numbers (bpm values)
self.chtChart.leftAxis.labelTextColor = UIColor.white
//change right border line color
self.chtChart.rightAxis.axisLineColor = UIColor.white
//change left border line to white
self.chtChart.leftAxis.axisLineColor = UIColor.white

//change values from decimal to int on left axis
let fmt = NumberFormatter()
fmt.numberStyle = .decimal
fmt.maximumFractionDigits = 0
fmt.groupingSeparator = ","
fmt.decimalSeparator = "."
self.chtChart.leftAxis.valueFormatter = DefaultAxisValueFormatter.init(formatter: fmt)

self.chtChart.data = LineChartData(dataSets: [set_a])

如您所见,我的图表没有底部边框,我也无法更改图表内部的网格线的颜色(我想将其更改为白色)。我尝试了以下命令,但未更改任何内容:
self.chtChart.xAxis.axisLineColor = UIColor.white
self.chtChart.borderColor = UIColor.white
self.chtChart.xAxis.gridColor = UIColor.white

最佳答案

我浏览了所有可能的属性,发现添加了以下行:
self.chtChart.xAxis.axisLineColor = UIColor.white
self.chtChart.rightAxis.gridColor = UIColor.white

解决了底部边框的问题,并将网格线的颜色更改为白色。

编辑:底线问题仍然似乎是一个问题。它不会显示在屏幕上。

Edit2:一次添加所有边框并设置其颜色似乎可以解决此问题:
self.chtChart.drawBordersEnabled = true
self.chtChart.borderColor = UIColor.white

关于ios - iOS图表更改网格线颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60351583/

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