ios - 使用 Swift 5.0 隐藏 HIChart 饼图的数据标签

标签 ios swift highcharts

我在 iOS-Swift 5.0 中使用 HICharts 库创建饼图

我不需要数据标签。只想要底部的传说。所以我尝试使用以下代码隐藏它。

   let plotoptions = HIPlotOptions()  //Line 1
   plotoptions.pie = HIPie()         //Line 2
   plotoptions.pie.allowPointSelect =  NSNumber(value: true) //Line 3
   plotoptions.pie.cursor = "pointer"  //Line 4 
   plotoptions.pie.dataLabels = HIDataLabels()   //Line 5
   plotoptions.pie.dataLabels.enabled = NSNumber(value: false) //Line 6
   plotoptions.pie.showInLegend = true  //Line 7

但是我得到一个错误-

1. Cannot assign value of type 'HIDataLabels' to type '[HIDataLabelsOptionsObject]?'  at line number 5

2. Value of type '[HIDataLabelsOptionsObject]?' has no member 'enabled' at line number 6

我提到了https://www.highcharts.com/ios/demo/pie-legend这是用 Objective C 写的。

最佳答案

编辑:最新的 HICharts API (8.0.0) 中有一些更改删除了 HIDataLabelsOptionsObject(),请参阅下面代码中的更新答案。

下面是我如何让它工作的。事实证明,您不需要 allowPointSelect、cursor 或 showInLegend 标志(尽管您可能希望保留 showInLegend 标志,因为您希望在图表上显示图例)来使其工作。我真的不知道 allowPointSelect 或 cursor 的作用,因为您仍然可以点击图表并查看详细信息。

plotoptions.pie = HIPie()
let dataLabel = HIDataLabels() // Older versions of API - HIDataLabelsOptionsObject()
dataLabel.enabled = false
plotoptions.pie.dataLabels = [dataLabel]

关于ios - 使用 Swift 5.0 隐藏 HIChart 饼图的数据标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56740243/

相关文章:

php - 如果数组为空 PHP - Highcharts

javascript - Highcharts 点单击事件返回 "hover"状态而不是 "select"状态

objective-c - MKPinAnnotationView 自定义图像替换为具有动画效果的图钉

ios - AVPlayer 抛出 : "Internal error: restarting too far ahead"

swift - becomeFirstResponder 和 estimatedRowHeight 不兼容

ios - Swift:为什么闭包函数调用迟了

javascript - Highcharts : different units per Y axis

ios - 如何更改特定数组中的 NSMutableArray

ios - 我怎样才能实现像这样的 UITableViewCell 边距(图片)?

ios - Firebase 观察方法不会返回并继续