Pre loader

Tag: SwiftUI

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1 vote

I work on a SwiftUI project that has integrated SciCharts.

What I’ve noticed is that while there are SwiftUI examples available, they are rather basic and when I replicate the example code over in my project, it does not run as we expect and in some cases does not run at all.

Currently there seems to be issues with the SwiftUI run loop, SwiftUI’s use of structs, and SciCharts use of pointers that make building complex charts within complex user interfaces rather challenging.

I needed to do a lot of work to get the SwiftUI example code to work in my project, and we’re still facing some challenges. Can we expect better SwiftUI support in the future, such as SwiftUI views included in the SDK or if this work has been done can the documentation be linked?

0 votes

Hi, I’ve found that there is no example of using SciChart in SwiftUI, the swift examples are using storyboard.

I’ve tried that, using SciChart in SwiftUI, and it worked. But I have some confusions about axis update and data update.

in SwiftUI, first I create a chartview struct as NSViewRepresentable, and in func makeNSView(context: Context) -> SCIChartSurface{} to initialize the chartview as any supported SciChart view type.

second, in func updateNSView(_ nsView: SCIChartSurface, context: Context){} to update the data and axis.

When updating axis(like visiablerange), every time I need call nsView.xAxes.clear() to remove axis first and then add axis again.

When updating data, every time I need to call nsView.renderableSeries.clear() to clear current plot data first and then call nsView.renderableSeries.add() to update the data.

My confusion is that is this the right way to do that? It seems not quite efficient.

  • Keyu Yan asked 2 years ago
  • last active 2 years ago
Showing 2 results