Not seeing colors in PieChart
- Dominant language
- Swift
- Stars
- 28k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
I'm not seeing any colors in my PieChart. This is the code:
```
func showPieChart(){
pieChartView.isHidden = false
tableView.isHidden = true
searchbar.isHidden = true
let transactions = manager.transactions.value
let grouped = transactions.categorise({$0.category})
var entries:[PieChartDataEntry] = []
grouped.forEach{c, ts in
var sum = 0.0
ts.forEach{t in
sum += t.expense ? Double(t.value * -1) : Double(t.value)
}
let entry = PieChartDataEntry(value: sum, label: c.name)
entries.append(entry)
}
entries.sort(by: {$0.0.value > $0.1.value})
entries = Array(entries.prefix(10))
let data = PieChartData()
let ds1 = PieChartDataSet(values: entries, label: "")
ds1.colors = ChartColorTemplates.material()
data.addDataSet(ds1)
let paragraphStyle: NSMutableParagraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
paragraphStyle.lineBreakMode = .byTruncatingTail
paragraphStyle.alignment = .center
let centerText: NSMutableAttributedString = NSMutableAttributedString(string: "Top 10 spending categories".localizedCapitalized)
self.pieChartView.centerAttributedText = centerText
self.pieChartView.data = data
self.pieChartView.holeColor = UIColor.clear
self.pieChartView.animate(xAxisDuration: 0.0, yAxisDuration: 1.0)
}
```
Attached is a screenshot.

Contributor guide
Research direction
Start by reproducing the report from the showPieChart() code and inspect how the PieChartDataSet colors are rendered in the attached screenshot. Determine why the configured colors are not visible, then verify that the pie chart displays distinct colors for its categories.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- data-visualization, mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100