Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #3975 (pie chart highlight disabled will lead to empty slice) #3996

Merged
merged 1 commit into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.