ios - .noDataText 未在图表内更新。 swift 2

标签 ios swift ios-charts

我正在使用图表库 (danielgindi/Charts)。

我有一个显示天、周、月和年选项的段。根据选择的内容将显示在图表上。

我有以下代码:

var highestValue : Double = 0.0
@IBAction func segmentChanged(sender: AnyObject) {
    switch durationSegment.selectedSegmentIndex
    {
    case 0:
        segmentSelected = "Day"
        highestValue = 8.0
    case 1:
        segmentSelected = "Week"
        highestValue = 10.0
    case 2:
        segmentSelected = "Month"
        highestValue = 12.0
    case 3:
        segmentSelected = "Year"
        highestValue = 14.0
    default:
        break;
    }

    print("segment selected = \(segmentSelected)")
    displayDurationLabel(segmentSelected, providedStartDate : NSDate())

}


 func setChart(xValues: [String], valuesCandleChart: [Double], durationToBeDisplayed: String) {
    chartView.descriptionText = ""
    print("within setChart, durationToBeDisplayed = \(durationToBeDisplayed)")
    chartView.noDataText = "No spends logged for \(durationToBeDisplayed)" 
chartView.leftAxis.customAxisMax = highestValue
}

当最初调用 ViewController 时,它使用 segmentSelected = "Month"并且图表显示正确的消息,但是当我更改段时,例如“Day”,打印显示正确的输出,但“.noDataText”未按预期更新。

任何帮助将不胜感激:)

最佳答案

调用candleChartView.setNeedsDisplay() 将重绘图表并更新文本

关于ios - .noDataText 未在图表内更新。 swift 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36481686/

相关文章:

ios - 向 Openhab2 和 Swift 发布 API 请求

swift - 快速解析 JSON 抛出 'fatal error: unexpectedly found nil while unwrapping an Optional value'

macos - 自定义 View ,Macos,Swift,让我的 EmptyView = self.moveView(frame : viewRect) viewRect cannot be found

ios - 如何将不相关的数组添加到 iOS-charts 折线图中的数据点标签?

iOS 图表,水平条不准确

ios - Obj-c 为静态库导出 .h 文件 - 不想公开类定义

ios - 添加 cocoapods 后在 Xcode 中导致错误的框架

iphone - 更改iOS6中的蓝色状态栏

ios - 如何在 MPMoviePlayerController 上处理多个 SRT 文件

ios - 提高使用自定义单元格滚动 UITableView 时的性能