LineChart 避免绘制 0 值
LineChart avoid plotting of 0 values
我正在使用 https://github.com/danielgindi/Charts 库。我试图从图表中删除 0 个值,但无法找到特定的解决方案,我们将不胜感激。
yAxis 的值类型为 Double
当前显示的图表:
更新折线图如我所愿
var dataEntries: [ChartDataEntry] = []
for i in 0..<forX.count {
let dataEntry = ChartDataEntry(x: Double(i), y: forY[i])
print(dataEntry)
dataEntries.append(dataEntry)
}
let lineChartDataSet = LineChartDataSet(entries: dataEntries, label: "")
let lineChartData = LineChartData(dataSet: lineChartDataSet)
chart.data = lineChartData
只是不要将它添加到您的数据条目中
for i in 0..<forX.count {
if forY[i] != 0 {
let dataEntry = ChartDataEntry(x: Double(i), y: forY[i])
print(dataEntry)
dataEntries.append(dataEntry)
}
}
我正在使用 https://github.com/danielgindi/Charts 库。我试图从图表中删除 0 个值,但无法找到特定的解决方案,我们将不胜感激。
yAxis 的值类型为 Double
当前显示的图表:
更新折线图如我所愿
var dataEntries: [ChartDataEntry] = []
for i in 0..<forX.count {
let dataEntry = ChartDataEntry(x: Double(i), y: forY[i])
print(dataEntry)
dataEntries.append(dataEntry)
}
let lineChartDataSet = LineChartDataSet(entries: dataEntries, label: "")
let lineChartData = LineChartData(dataSet: lineChartDataSet)
chart.data = lineChartData
只是不要将它添加到您的数据条目中
for i in 0..<forX.count {
if forY[i] != 0 {
let dataEntry = ChartDataEntry(x: Double(i), y: forY[i])
print(dataEntry)
dataEntries.append(dataEntry)
}
}