Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit dd1bb78

Browse files
authored
Merge pull request ChartsOrg#3996 from danielgindi/3975
fix ChartsOrg#3975 (pie chart highlight disabled will lead to empty slice)
2 parents 8a98ee2 + 5b59440 commit dd1bb78

File tree

6 files changed

+15
-6
lines changed

6 files changed

+15
-6
lines changed

Source/Charts/Renderers/PieChartRenderer.swift

+1-6
Original file line numberDiff line numberDiff line change
@@ -728,11 +728,6 @@ open class PieChartRenderer: DataRenderer
728728

729729
guard let set = data.getDataSetByIndex(indices[i].dataSetIndex) as? IPieChartDataSet else { continue }
730730

731-
if !set.isHighlightEnabled
732-
{
733-
continue
734-
}
735-
736731
let entryCount = set.entryCount
737732
var visibleAngleCount = 0
738733
for j in 0 ..< entryCount
@@ -758,7 +753,7 @@ open class PieChartRenderer: DataRenderer
758753
let sliceAngle = drawAngles[index]
759754
var innerRadius = userInnerRadius
760755

761-
let shift = set.selectionShift
756+
let shift = set.isHighlightEnabled ? set.selectionShift : 0.0
762757
let highlightedRadius = radius + shift
763758

764759
let accountForSliceSpacing = sliceSpace > 0.0 && sliceAngle <= 180.0

Tests/Charts/PieChartTests.swift

+14
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,18 @@ class PieChartTests: FBSnapshotTestCase
7070
chart.drawCenterTextEnabled = false
7171
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
7272
}
73+
74+
func testHighlightDisabled()
75+
{
76+
chart.data?.dataSets[0].highlightEnabled = false
77+
chart.highlightValue(x: 1.0, dataSetIndex: 0, callDelegate: false)
78+
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
79+
}
80+
81+
func testHighlightEnabled()
82+
{
83+
// by default, it's enabled
84+
chart.highlightValue(x: 1.0, dataSetIndex: 0, callDelegate: false)
85+
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
86+
}
7387
}
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)