Swift BEMSimpleLineGraphView x轴标签未显示

时间:2016-02-12 07:29:29

标签: ios xcode swift

使用BEMSimpleLineGraphView,未显示x轴标签。 当我制作图形的frame.height 200时,它显示出来了。

我几乎没有搜索,但我不能特意搜索。

请给我一些建议

charView

import UIKit

class ChartView: UIView {

var graphView: BEMSimpleLineGraphView!

override func awakeFromNib() {
    graphView = BEMSimpleLineGraphView(frame: CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height - 200))

    graphView.enableReferenceAxisFrame = true
    graphView.enableReferenceXAxisLines = true
    graphView.enableXAxisLabel = true
    graphView.enableBezierCurve = true
    graphView.autoScaleYAxis = true
    graphView.animationGraphEntranceTime = 3

    self.addSubview(graphView)
  }

}

视图模型

class ChartViewModel: NSObject, BEMSimpleLineGraphDelegate, BEMSimpleLineGraphDataSource {

let reviewSheetManager: ReviewSheetManager = ReviewSheetManager.sharedInstance

func numberOfPointsInLineGraph(graph: BEMSimpleLineGraphView) -> NSInteger {

    return reviewSheetManager.reviewSheetArray.count + 1
}

func lineGraph(graph: BEMSimpleLineGraphView, valueForPointAtIndex index: NSInteger) -> CGFloat {
    if index == 0 {
        return 0
    } else {
        return CGFloat(reviewSheetManager.sumReviewPoint(reviewSheetManager.reviewSheetArray[index - 1]))
    }
}

func lineGraph(graph: BEMSimpleLineGraphView, labelOnXAxisForIndex index: Int) -> String! {
    return "\(index) 回目"
  }

}

↓frame.height - 200 enter image description here

↓view.frame enter image description here

0 个答案:

没有答案