如果条形值为 0.0,如何隐藏标记视图。在使用 iOS 图表的条形图中

Div*_*ati 3 ios swift ios-charts

我正在使用 iOS 图表添加标记。我只想在值不为零时打开标记。我们可以使用 iOS 图表库来做到这一点。

Div*_*ati 7

首先设置 barChartView 的委托,然后在 chartValueSelected 函数中编写此代码

  func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight){
    if entry.y == 0.0{
        barChartView.highlightValue(nil, callDelegate: false)
    }

}
Run Code Online (Sandbox Code Playgroud)

在您需要隐藏标记的任何地方添加此代码

 barChartView.highlightValue(nil, callDelegate: false)
Run Code Online (Sandbox Code Playgroud)