Skip to content

Commit

Permalink
Merge pull request #3996 from danielgindi/3975
Browse files Browse the repository at this point in the history
fix #3975 (pie chart highlight disabled will lead to empty slice)
  • Loading branch information
liuxuan30 authored Aug 9, 2019
2 parents 8a98ee2 + 5b59440 commit dd1bb78
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
7 changes: 1 addition & 6 deletions Source/Charts/Renderers/PieChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -728,11 +728,6 @@ open class PieChartRenderer: DataRenderer

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

if !set.isHighlightEnabled
{
continue
}

let entryCount = set.entryCount
var visibleAngleCount = 0
for j in 0 ..< entryCount
Expand All @@ -758,7 +753,7 @@ open class PieChartRenderer: DataRenderer
let sliceAngle = drawAngles[index]
var innerRadius = userInnerRadius

let shift = set.selectionShift
let shift = set.isHighlightEnabled ? set.selectionShift : 0.0
let highlightedRadius = radius + shift

let accountForSliceSpacing = sliceSpace > 0.0 && sliceAngle <= 180.0
Expand Down
14 changes: 14 additions & 0 deletions Tests/Charts/PieChartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,18 @@ class PieChartTests: FBSnapshotTestCase
chart.drawCenterTextEnabled = false
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testHighlightDisabled()
{
chart.data?.dataSets[0].highlightEnabled = false
chart.highlightValue(x: 1.0, dataSetIndex: 0, callDelegate: false)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}

func testHighlightEnabled()
{
// by default, it's enabled
chart.highlightValue(x: 1.0, dataSetIndex: 0, callDelegate: false)
ChartsSnapshotVerifyView(chart, identifier: Snapshot.identifier(UIScreen.main.bounds.size), overallTolerance: Snapshot.tolerance)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dd1bb78

Please sign in to comment.