SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
In Scichart 2, we had some code that added some annotations in the SCIAnimation completion block. Here’s a snippet. We need the self.renderAnnotations()
to happen AFTER the chart data range is set, because we only draw annotations that will fit within the individual bar stack elements.
SCIUpdateSuspender.usingWithSuspendable(sciChartSurface) { if hasBarData { self.sciChartSurface?.renderableSeries.add(columnCollection) let animation = SCIWaveRenderableSeriesAnimation(duration: 1, curveAnimation: .easeOut) animation.completionHandler = { self.renderAnnotations() self.configurationButtons?.forEach { $0.isUserInteractionEnabled = true } } columnCollection.addAnimation(animation) }
Here’s the current rewrite to run under Scichart 4. With this code, yAxisLeft.visibleRange
has not been updated to the correct data range when renderAnnotations()
is called.
Uncommenting the 3 animator-related lines near the bottom doesn’t make a difference, and my listener function is never called.
I’ve also tried wrapping the renderAnnotations() call in a DispatchQueue.main.asyncAfter() call. That sometimes works, and sometimes results in renderAnnotations() not being called at all.
How do I get renderAnnotations() (and the following line looping on configurationButtons) to run, reliably, after the axis range setup is complete?
How do I get my wave animation back?
SCIUpdateSuspender.usingWith(sciChartSurface) { if hasBarData { self.sciChartSurface?.renderableSeries.add(columnCollection) self.renderAnnotations() self.configurationButtons?.forEach { $0.isUserInteractionEnabled = true } // let animator = SCIAnimations.createWaveAnimator(for: columnCollection) // animator.add(self) // animator.start() }
Hi, there.
You can do it like this:
1) Create animator:
let animator = SCIAnimations.createWaveAnimator(for: rSeries)
2) Create SeriesAnimatorListener class that conforms to ISCIAnimatorListener protocol:
class SeriesAnimatorListener: NSObject, ISCIAnimatorListener {
func onAnimationEnd(_ animation: SCIValueAnimator!) {
print("onAnimationEnd")
}
func onAnimationStart(_ animation: SCIValueAnimator!) {
print("onAnimationStart")
}
func onAnimationUpdate(_ animation: SCIValueAnimator!) {
print("onAnimationUpdate")
}
func onAnimationCancel(_ animation: SCIValueAnimator!) {
print("onAnimationCancel")
}
}
3) Create an instance of your listener and add it to the animator:
let listener = SeriesAnimatorListener()
animator.add(listener)
4) Run you animation:
animator.cancel()
animator.start(withDuration: 2)
You should have print statements in the console.
let us know if that helped.
Please login first to submit.