2

I have a FIFO Real Time chart (pretty much taken from their published Example) of a SciChart graph. As it renders, it starts out completely zoomed in very close and as the line is drawn, it zooms out to accommodate the full size of the line.

        <s:SciChartSurface.XAxis>
            <s:NumericAxis x:Name="axisX" MinHeight="50" AutoRange="Always" AxisTitle="{Binding Path=XAxisTitle}" DrawMinorGridLines="False" DrawMinorTicks="False" TextFormatting="0.##">
                <s:NumericAxis.GrowBy>
                    <s:DoubleRange Max="0.1" Min="0.1" />
                </s:NumericAxis.GrowBy>
            </s:NumericAxis>
        </s:SciChartSurface.XAxis>

However, what I would like is for it to begin zoomed out by a certain amount already - e.g. the X axis would already be displaying from (for example) 0 - 10 and as the line is drawn it proceeds across the screen, only zooming if the line happens to get bigger than the space provided.

I've tried setting the VisibleRangeLimit, but while this does allow me to define the range of the chart area, the zoom doesn't kick in when the curve gets too big (so it literally goes "off the chart")

How can this be accomplished?

komodosp
  • 3,316
  • 2
  • 30
  • 59

1 Answers1

2

The reason for this is the Fifo Example in sciChart WPF uses XAxis AutoRange set to Always to scale the axis to fit the data. When the example starts, even if the Fifo buffer has a capacity of 10,000 points, it has no data in it, hence the axis is scaled small to accommodate the data.

There are two ways around this:

  1. Is to pre-fill your FIFO DataSeries with X=xValue, Y=double.NaN. Given enough values the chart will think it has to draw all these points so the XAxis will scale accordingly

  2. Is to take control of XAxis.VisibleRange yourself (do not use AutoRange). In this case, you need to set XAxis.VisibleRange to a window size to accommodate N points, and as you update data, update the window.

The FAQ 'How to create a StripChart in SciChart' demonstrates technique (2), how to update the visible-range of the XAxis to achieve scrolling behaviour.

Disclosure, I am the tech lead of the SciChart WPF Team

Dr. Andrew Burnett-Thompson
  • 20,980
  • 8
  • 88
  • 178
  • 1
    Thanks for the info. What I did was bind `AutoRange` to a field which changes from `Never` to `Always` when the number of points becomes big enough that I want to start scaling. This is working for me, but you say "do not use AutoRange". Why is this? – komodosp Apr 08 '16 at 14:41
  • You can ignore my suggestion 'do not use autorange' if you do the above. your solution is more simple and elegant. By setting the Axis.VisibleRange to a fixed value, use AutoRange.Never then change to AutoRange once number of points is reached you will get exactly the effect you want! Just be advised if you set AutoRange by MVVM use a TwoWay binding! :) – Dr. Andrew Burnett-Thompson Apr 09 '16 at 09:20