SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

0
0

Hello,

how can i implement a vertically stacked y axis chart like in your example (WPF Chart Vertically Stacked YAxis) with MVVM and a varying number of y axes. Your example has a fixed number of y axes and the needed YAxesPanel is directly implemented in your xaml code. What is the best way to achieve the same result with a varying number of y axis?

Best regards
Alexander

Version
5.3.0.11954
  • You must to post comments
0
0

Hi

I posted a similiar question some time before you.
My solution might not be ideal, but it is almost working for me. Since I’m developing the code for a customer, I’m not allowed to post code by NDA, but I can give you the theoretical approach.


  1. specify the number of YAxes in VM
  2. use this to build the grid inside ItemPanelTemplate and bind with DynamicResource (see example in link below)
  3. to do so, use class from this blog and adopt as needed. I build a specialized class for my use-case
  4. bind to the SizeChangedEvent of RenderSurface
  5. Iterate the axes from YAxes, calculate height per axis and set it.
  6. inside the same loop don’t forget to set the row by using Grid.SetRow(axis, rowIndex)

This approach is from my point of view not the most performing, but the only I was able to discover from the docs.

The last task which I’m facing, is to get the height of the chart portion of the RenderSurface, as the height given in SizeChanged is of the full height including YAxis and other stuff drawn.
Maybe someone from SciChart can help out on this last task as my customer has a support subscription or do I have to open a support ticket?

Hope this helps you to solve your task

Cheers

Martin

  • You must to post comments
0
0

Hello Martin,

thank you for your help. As you say in your description your approach is not the most performing. So it might be not the ideal way for me since performance is one of the key points in my current project. I would also like to hear from SciChart how this should be done in MVVM.

Best regards
Alexander

  • You must to post comments
0
0

Hi,

this is my solution. It’s clear to me that it breaks MVVM since the ViewModel has a reference to the SciChartSurface. However if you need to call SuspendUpdates() in your ViewModel you need the reference anyway (see: https://www.scichart.com/questions/wpf/suspend-updates-in-mvvm-scenario). This is in my opinion the best way to do it. At least i found no better way.

Best regards
Alexander

  • You must to post comments
0
0

Hi Alexander

I was unprecise in my explanation – it is not very performing, when drawing the first time.
After that it has only a little impact when sizing.

If the window is not changed, it has absolutely no measureable influence on the performance.

I wonder why nobody from SciChart support is taking part in this discussion, as I don’t believe it is a task which is only affecting us both…
Or we are doing something extremly special with our charts 🙂

Cheers

Martin

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.

SciChart WPF v6 BETA released! Note pricing/licensing changes are coming. Contact us to beat the rise!Read more
+