Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
if we disable highlight for pie chart data set, we still need to render without a shift.
  • Loading branch information
liuxuan30 authored and SwiftPolar committed Mar 20, 2023
1 parent d2f1619 commit 8acb665
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 8acb665

Please sign in to comment.