1

I'm using the chart controls from WinRTXAMLToolkit, to draw a pie chart. The chart is updated on the screen using the values from a few slider controls.

When the sliders values are changed, I call in a function to calculate a formula (say compound interest) based on the sliders' values.

And then I change the ItemsSource of the chart's SeriesDefinitions to point to the new collection of data.

I'm trying to have a 'live' PieChart which updates instantly. The problem is when I keep changing the values of the sliders, there is a 1-2 second delay for the chart to draw itself again - and this makes the slider movement 'freeze' in between for a second.

Is there any way around this problem ? Can I move the chart-updation to a different thread so that the UI thread remains free and doesn't freeze up ?

Arctic Vowel
  • 1,492
  • 1
  • 22
  • 34
  • How many datapoints are there? – TaW Jul 04 '15 at 11:33
  • The PieChart has two sections. There is also a separate chart for a `StackedColumnSeries` in the same `UserControl` which can have 5-10 datapoints depending on user input. Both charts are updated from a `Slider`'s `ValueChanged` event. – Arctic Vowel Jul 04 '15 at 15:06
  • Have you tried running using a profiler? It doesn't make sense that there would be the delay you describe given how few points you mentioned. – WiredPrairie Jul 05 '15 at 00:29
  • @WiredPrairie I searched around but it looks like the Visual Studio profiler is not available for WinRT apps. – Arctic Vowel Jul 06 '15 at 04:59
  • 1
    Here is a description of the profiling options: http://blogs.msdn.com/b/visualstudioalm/archive/2013/07/12/performance-and-diagnostics-hub-in-visual-studio-2013.aspx – WiredPrairie Jul 06 '15 at 10:34
  • @WiredPrairie I didn't know about that - thank you ! – Arctic Vowel Jul 06 '15 at 10:47

2 Answers2

1

Try update it using another thread and run it async.

One way is to insert it into Update fuction, and do:

await Update()

While Update and the method which it called in are async.

BestR
  • 669
  • 2
  • 6
  • 17
  • This is the line that updates the pie chart : `((PieSeries)this.MyChart.Series[0]).ItemsSource = PieList;` and calling it from a `Task` or a different thread raises exceptions. – Arctic Vowel Jul 06 '15 at 04:52
  • You can't update a UI control on a background `Task`, so I am not clear what you're suggesting @AniruddhaVarma. – WiredPrairie Jul 06 '15 at 10:36
1

I think that the problem may be that you're changing the ItemsSource. This is a more intensive operation because a lot of things happen in the background. Could you use an ObservableCollection and update it instead of replacing it?

bogdanbujdea
  • 594
  • 8
  • 22
  • I did that but ran into a COMException as described here : [SO link](http://stackoverflow.com/questions/16730124/winrtxamltoolkit-charting-comexception-when-use-of-inotifypropertychanged) – Arctic Vowel Jul 06 '15 at 04:57