Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noDataText is not working #1644

Closed
Bharati555 opened this issue Oct 11, 2016 · 1 comment
Closed

noDataText is not working #1644

Bharati555 opened this issue Oct 11, 2016 · 1 comment

Comments

@Bharati555
Copy link

i have set the noDataText still its showing the empty white circle and not label
here is my code

override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = LocalizedString("Charts.Title")
piechartView.backgroundColor = self.view.backgroundColor
piechartView.holeColor = self.view.backgroundColor;
piechartView.delegate = self
piechartView.usePercentValuesEnabled = true;
piechartView.holeRadiusPercent = 0.58;
piechartView.transparentCircleRadiusPercent = 0.61;
piechartView.descriptionText = "";
piechartView.drawCenterTextEnabled = true;
piechartView.drawHoleEnabled = true;
piechartView.rotationAngle = 0.0;
piechartView.rotationEnabled = true;
piechartView.centerText = "Housekeeping";
piechartView.noDataText = "No Schedule Data"

}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(true)
    self.setChartValues()
}

func setXValues(_ xValues: NSArray, yValues: NSArray) {

    var yVals1 : [ChartDataEntry]? = [ChartDataEntry]();

    for i in 0 ..< yValues.count {
        yVals1?.append(ChartDataEntry(value: (yValues.object(at: i) as AnyObject).doubleValue, xIndex: i) as ChartDataEntry)
    }

    let dataSet = PieChartDataSet(yVals: yVals1, label: "")

    if xValues.count > 1 {
        dataSet.sliceSpace = 3.0
    }

    dataSet.colors = colors

    let data = PieChartData(xVals: xValues as? [String] , dataSet:dataSet)

    let pFormatter = NumberFormatter();
    pFormatter.numberStyle = NumberFormatter.Style.percent;
    pFormatter.maximumFractionDigits = 1;
    pFormatter.roundingMode = .down
    pFormatter.multiplier = 1.0;
    pFormatter.percentSymbol = " %";
    data.setValueFormatter(pFormatter);
    data.setValueTextColor(UIColor.white)

    piechartView.data = data
    piechartView.highlightValues(nil)

    piechartView.setNeedsDisplay()
}
@liuxuan30
Copy link
Member

you should not set chart data if you don't have data at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants