Search code examples
c#wpfscichart

SciChart AxesPanelTemplate with dynamic grid


my task is to draw a flexible number of digital signal realtime-data in SciChart. Due to the nature of this signals they are between 0..1. I want to have them stacked as in the SciChart example found at https://www.scichart.com/example/wpf-chart-example-vertically-stacked-yaxis/. But with a dynamic grid template inside the YAxesPanelTemplate. What ever I try, there are no YAxes drawn.

I'm using a GridExtension which is very close to the one found here: https://rachel53461.wordpress.com/2011/09/17/wpf-grids-rowcolumn-count-properties/ refernced from this answer https://rachel53461.wordpress.com/2011/09/17/wpf-grids-rowcolumn-count-properties/

Any help is highly appreciated

Cheers

Martin


Solution

  • 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 my 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 Iterate the axes from YAxes,calculate height per axis and set it.
    5. 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 SciChart 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 (@Dr. ABT - just maybe) can help out on this last task?

    Hope this helps someone else too.

    Cheers

    Martin