We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Create SfChart asynchronously

Thread ID:

Created:

Updated:

Platform:

Replies:

128475 Jan 25,2017 03:58 AM Feb 16,2017 08:18 AM WPF 5
loading
Tags: SfChart
Victor Dienstbier
Asked On January 25, 2017 03:58 AM

Hi!

I really need your help, please:

I am trying to create a SfChart on a WPF window. Sometimes I have to load a lot of data in the chart which takes some seconds. In order not to block the UI I'd like to creat the Chart in an async Method and show it on the UI afterwards...

Is this anyhow possible? Because after creating a new SfChart Object in the async Mathod it tells me that the chart is an UI-Thread.

Is there anything I can do to improve the speed or not blocking the Tread?


Thank you very much!


Victor

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On January 26, 2017 07:58 AM

Hi Victor, 
  
Thanks for contacting Syncfusion Support. 
  
We are unable to reproduce the reported problem at our end. We have prepared a demo sample based on your requirement and it can be downloaded from below link, 
  
Sample: Chart128475 
  
If you are still able to reproduce the reported problem, please revert us by modifying the provided sample. It would be helpful for us to serve you better. 
  
Regards, 
Devi 


  
  
  


Victor Dienstbier
Replied On February 7, 2017 07:48 AM

Hi Devi!

Thank you very much for your help!

I tried to solve the problem with your example, but it's not quite the answer...

I'm downloading data from a SQL Server with different measurements. For example I'd like to compare 10 different measurements. For each measurement I have an entry in the Observable Collection. No I'm adding one by one each measurment to a new SplineSeries.

That is what I'm doing:

private async void DiagrammQHErstellenAsync()

{

await Task.Run(() => DiagrammQH());

}


private void DiagrammQH()

{


//QH Diagramm




chrtKennlinie = diaQH;



chrtKennlinie.Header = "Förderhöhe";


//QH Diagramm




chrtKennlinieUebersichtCode = diaQHUebersicht;



chrtKennlinieUebersichtCode.Header = "Förderhöhe";


//X-Achsen


//Förderhöhe


chrtKennlinie.PrimaryAxis = new NumericalAxis()




{



Header = "Volumenstrom [l/s]",




Minimum = 0,



ShowTrackBallInfo = true




};



//Y-Achsen


//Förderhöhe


NumericalAxis Axis1 = new NumericalAxis()




{



Header = "Förderhöhe [m]",




Minimum = 0,



ShowTrackBallInfo = true




};


chrtKennlinie.SecondaryAxis = Axis1;


 



//Alle Serien aus Diagramm entfernen




chrtKennlinie.Series.Clear();



foreach (Pumpenmessdaten.MessungenSammlung Item in Vergleichsmessungen)




{



                   

                   

//SERIES


SplineSeries seriesQH = new SplineSeries()




{


IsSeriesVisible = Item.DatenMessung.IsChecked,


ItemsSource = Item.Messwerte,



XBindingPath = "QBerechnet",


YBindingPath = "HtotBerechnet",


ShowTooltip = true,


EnableAnimation = true,







AdornmentsInfo = new ChartAdornmentInfo()




{



Symbol = ChartSymbol.Ellipse,




SymbolWidth = 5,


SymbolHeight = 5


}


};


seriesQH.YAxis = Axis1;



//Adding Series to the Chart Series Collection




chrtKennlinie.Series.Add(seriesQH);







//Behavior


ChartCrossHairBehavior crossHairQH = new ChartCrossHairBehavior()




{



HorizontalAxisLabelAlignment = ChartAlignment.Center,


VerticalAxisLabelAlignment = ChartAlignment.Center




};



ChartZoomPanBehavior zoomPanBehaviorQH = new ChartZoomPanBehavior()




{



EnableZoomingToolBar = true,


HorizontalPosition = HorizontalAlignment.Right,


VerticalPosition = VerticalAlignment.Top,


ToolBarBackground = new SolidColorBrush(Colors.Transparent),


EnableMouseWheelZooming = true,


EnablePanning = true,


EnableSelectionZooming = true,


ZoomRelativeToCursor = true,


ResetOnDoubleTap = true,




MaximumZoomLevel = 10,



EnablePinchZooming = true




};


chrtKennlinie.Behaviors.Add(crossHairQH);


chrtKennlinie.Behaviors.Add(zoomPanBehaviorQH);


           


}


I hope you understand my problem now a little bit better :-)


Thank you very much for your help!




Devi Aruna Maharasi Murugan [Syncfusion]
Replied On February 8, 2017 11:59 AM

Hi Victor, 
  
Thanks for your update. 
  
We suggest you to set the datas alone using async method instead of creating chart in async method. We have prepared a demo sample based on your requirement and it can be downloaded from below link, 
  
Sample: AsyncSample 
  
Regards, 
Devi 





Victor Dienstbier
Replied On February 15, 2017 04:02 AM

Hi Devi!

Thanks again for your reply! I tried to approach the solution with your example, but it still takes a lot of time depending on the amount of Series I add to the diagramm.

In your example you create all needed data asyncrounously. I'm doing the same. I get the data from the SQL Server async and afterwards adding each measure to a new Series. Getting all data takes maybe a second for 1000 meaures. Adding them so the chart is what takes the time.

Is the an option where I don't need to do a foreach loop to add all the Series one by one?


Thank you very much! I also added a Screenshot with an example view of data. The creation took about a minute...

Attachment: ExampleView_5092960a.zip

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On February 16, 2017 08:18 AM

Hi Victor, 
  
Thanks for your update. 
  
Query 1:  it still takes a lot of time depending on the amount of Series I add 
  
We suspect that, the delay due to rendering the normal chart series in UI. We can reduce the loading delay (rendering time) of chart series by using FastSeries instead of normal series. 
We have prepared a demo sample with 100 FastLineSeries for your reference and it can be downloaded from below link, 
  
Query 2: Is there an option where I don't need to do a foreach loop to add all the Series one by one? 
  
Since you need to create a separate instance for each series based on each measurement (as you mentioned in your previous update), we don’t have any other option than the foreach loop or for loop to add the series. 
  
Regards, 
Devi 





CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;