So, I updated my project and modules for working with Swift 2.0 and Xcode 7. But now my PieChart no longer works as expected. My pies start from 0 degrees, which means that they all start in the same place one above the other.
Data is added in the same way as before, and if I select it, I see that they are all there, but do not come from their respective places.
Code to add mine pieChartData
:
var dataEntries: [ChartDataEntry] = []
var dataPoints: [String] = []
for var i = 0; i < expensesHistory.count; i++ {
let dataEntry = ChartDataEntry(value: expensesHistory[i].amount, xIndex: i)
dataEntries.append(dataEntry)
dataPoints.append(expensesHistory[i].category.rawValue)
}
let pieChartDataSet = PieChartDataSet(yVals: dataEntries)
let pieChartData = PieChartData(xVals: dataPoints, dataSet: pieChartDataSet)
pieChartView.data = pieChartData
var colors = [UIColor]()
colors.append(Colors.blueColor())
pieChartDataSet.colors = colors
pieChartDataSet.drawValuesEnabled = false
pieChartDataSet.sliceSpace = 4.0
The data is loaded and added correctly, in different records (7), but all 7 pies start in the same place ... therefore, they do not lead to a circle at all. Any ideas?
UPDATE # 1
ChartsDemo Swift, , , , , , , DataSet. PieChartDataSet.drawValuesEnabled = true
PieChartView.legend.enabled = true
, 1 1 DataSet
. , xVals
yVals
1 , , . , , .
PieChartView
, , , , , , , PieChartView
1 , 1 , .
ChartsDemo Swift, , Swift 2.0 ( ).
private func setPieChartData() {
let mult = UInt32(100)
let count = Int(4)
let parties = [
"Party A", "Party B", "Party C", "Party D", "Party E", "Party F",
"Party G", "Party H", "Party I", "Party J", "Party K", "Party L",
"Party M", "Party N", "Party O", "Party P", "Party Q", "Party R",
"Party S", "Party T", "Party U", "Party V", "Party W", "Party X",
"Party Y", "Party Z"
]
var yVals1 = [ChartDataEntry]()
for var i = 0; i < count; i++
{
let chartDataEntry = ChartDataEntry(value: Double((arc4random_uniform(mult) + mult/5)), xIndex: i)
yVals1.append(chartDataEntry)
}
var xVals = [String?]()
for var i = 0; i < count; i++
{
xVals.append(parties[i % parties.count])
}
let dataSet = PieChartDataSet(yVals: yVals1, label: "Election Results")
dataSet.sliceSpace = 3.0
var testColors = [UIColor]()
testColors.append(Colors.blueColor())
let data = PieChartData(xVals: xVals, dataSet: dataSet)
pieChartView.data = data
dataSet.colors = testColors
dataSet.drawValuesEnabled = true
dataSet.sliceSpace = 4.0
}
, iOS-, Swift 2.0, , . , . , , , , PieChartView
.
# 2
, , . , .
:
- Xcode 7.
- CocoaPods.
- , CocoaPods, , , "pod install" , .
- ChartsIssue.xcworkspace , ChartsIssue.xcproj