如何在iOS图表中轻松突出显示动画

如何在iOS图表中轻松突出显示动画,ios,swift,animation,ios-charts,Ios,Swift,Animation,Ios Charts,高亮显示PieChartView(从)的某个部分时,默认情况下,高亮显示的选择将跳出而不显示动画。有没有办法缓解标准效果和高亮效果之间的动画效果 标准外观: 突出显示的外观 所选数据段的大小由数据集的selectionShift属性控制。值0表示选择元素时不会对其进行更改 可以随时间更改此值,由内置的animator函数控制 要在选择饼图的一段时触发动画师,请实现图表视图代理的chartValueSelected(chartView:ChartViewBase,entry:ChartDataE

高亮显示PieChartView(从)的某个部分时,默认情况下,高亮显示的选择将跳出而不显示动画。有没有办法缓解标准效果和高亮效果之间的动画效果

标准外观:

突出显示的外观


所选数据段的大小由数据集的
selectionShift
属性控制。值
0
表示选择元素时不会对其进行更改

可以随时间更改此值,由内置的animator函数控制

要在选择饼图的一段时触发动画师,请实现图表视图代理的
chartValueSelected(chartView:ChartViewBase,entry:ChartDataEntry,highlight:highlight)
功能

例如:

override func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) {

    let animator = Animator()

    animator.updateBlock = {
        // Usually the phase is a value between 0.0 and 1.0
        // Multiply it so you get the final phaseShift you want
        let phaseShift = 10 * animator.phaseX

        let dataSet = chartView.data?.dataSets.first as? PieChartDataSet
        // Set the selectionShift property to actually change the selection over time
        dataSet?.selectionShift = CGFloat(phaseShift)

        // In order to see the animation, trigger a redraw every time the selectionShift property was changed
        chartView.setNeedsDisplay()
    }

    // Start the animation by triggering the animate function with any timing function you like
    animator.animate(xAxisDuration: 0.3, easingOption: ChartEasingOption.easeInCubic)
}