ChartsOrg / ChartsOrg/Charts

Not seeing colors in PieChart

Open
#2,097 5 comments 0 reactions 0 assignees View on GitHub
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.
![bildschirmfoto 2017-01-19 um 21 01 02](https://cloud.githubusercontent.com/assets/9019780/22123045/7209b6d6-de8a-11e6-9dda-b9464ba60337.png)

Contributor guide

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.