Reputation: 13
Am using Pie chart in, Charts ios library. I want to know, how can i select first slice by default when it Pie chart loads.
I found this chartView.highlightValue(x: 45, dataSetIndex: 0)
. But this code is not working.
My pie chart has two slices with PieChartDataEntry
. I want first one to be selected by default.
let entries = (0..<count).map { (i) -> PieChartDataEntry in
if i == 0 {
return PieChartDataEntry(value: 45,
label: "")
} else {
return PieChartDataEntry(value: 55,
label: "")
}
}
Upvotes: 1
Views: 770
Reputation: 1710
If you want the first slice to be selected, set the x
to be 0
. Note that x
here is the index
of your data and dataSetIndex
is always 0
for PieCharts
chartView.highlightValue(x: 0, dataSetIndex: 0)
Upvotes: 1