简体   繁体   中英

SciChart Realtime zoom with minimum axis range

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 - eg 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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM