Ios .noDataText未在图表中更新。斯威夫特2

Ios .noDataText未在图表中更新。斯威夫特2,ios,swift,ios-charts,Ios,Swift,Ios Charts,我正在使用图表库(danielgindi/Charts) 我有一个显示日、周、月和年选项的段。根据所选内容,将在图表上显示 我有以下代码: var highestValue : Double = 0.0 @IBAction func segmentChanged(sender: AnyObject) { switch durationSegment.selectedSegmentIndex { case 0: segmentSelected = "Day"

我正在使用图表库(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”,打印显示正确的输出,但是“.NodeText”没有按预期更新


任何帮助都将不胜感激:)

调用
candleChartView。setNeedsDisplay()
将重新绘制图表并更新文本
  • 在setChart函数中,在结束调用时:
  • chartView.notifyDataSetChanged()

    • 调用setChart函数调用后立即:
    chartView.legend.resetCustom()文件


    我在setChart函数的末尾调用了这个函数,但是它没有按预期工作。它也不会更新customAxisMax。它似乎是后面部分的1次单击,例如,当我单击“天”然后单击“周”时,它显示为8.0,然后当我单击“返回到天”时,它将更改为10.0