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

Missing entries in PieChartDataEntry legends. #3240

Closed
jojonarte opened this issue Feb 5, 2018 · 1 comment
Closed

Missing entries in PieChartDataEntry legends. #3240

jojonarte opened this issue Feb 5, 2018 · 1 comment

Comments

@jojonarte
Copy link

I have 6 dataentries into the pie chart but not all of them is shown in the legends. 6th PieChartDataEntry is not shown in the legends.

Here is a snippet of what I coded.

func preparePieChart() {
       let entry1 = PieChartDataEntry(value: Double(0), label: "Critical Deficiency")
       let entry2 = PieChartDataEntry(value: Double(1), label: "Open Items")
       let entry3 = PieChartDataEntry(value: Double(28), label: "Outstanding Open Items")
       let entry4 = PieChartDataEntry(value: Double(0), label: "Unable to Observe")
       let entry5 = PieChartDataEntry(value: Double(7), label: "Completed/In Progress")
       let entry6 = PieChartDataEntry(value: Double(1), label: "Closed Items")
       
       let dataSet = PieChartDataSet(values: [entry1, entry2, entry3, entry4, entry5, entry6], label: "")
       // remove numbers in pie chart
       dataSet.drawValuesEnabled = false
       
       let data = PieChartData(dataSet: dataSet)
       pieChart.data = data
       pieChart.chartDescription?.text = ""
       
       // Color
       dataSet.colors = ChartColorTemplates.colorful()
       //dataSet.valueColors = [UIColor.black]
       pieChart.holeColor = UIColor.clear
       pieChart.drawHoleEnabled = false
       pieChart.chartDescription?.textColor = UIColor.black
       pieChart.legend.textColor = UIColor.black
       
       pieChart.chartDescription?.xOffset = pieChart.frame.width
       pieChart.chartDescription?.yOffset = pieChart.frame.height * (2/3)
       pieChart.chartDescription?.textAlign = NSTextAlignment.left
       
       pieChart.drawEntryLabelsEnabled = false
       
       
       let legend = pieChart.legend
       legend.horizontalAlignment = .center
       legend.verticalAlignment = .bottom
       legend.orientation = .horizontal
       legend.drawInside = false
       legend.enabled = true
       pieChart.animate(xAxisDuration: 2.0, yAxisDuration: 2.0)
//        pieChart.xAxis.labelPosition = .top
       // Refresh chart with new data
       pieChart.notifyDataSetChanged()
   }

screen shot 2018-02-05 at 2 59 27 pm

@liuxuan30
Copy link
Member

would you mind debugging a little?

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