简体   繁体   English

最小轴范围的SciChart实时缩放

[英]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. 我有一张SciChart图的FIFO实时图表(几乎取自其发表的示例)。 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. 但是,我希望它已经开始缩小了一定的量-例如,X轴已经从(例如)0-10开始显示,并且随着绘制该线,它在屏幕上继续前进,只有在这条线正好大于提供的空间。

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") 我尝试设置VisibleRangeLimit ,但是虽然这确实允许我定义图表区域的范围,但是当曲线太大时缩放不会VisibleRangeLimit (因此它实际上“偏离了图表”)

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. 原因是sciChart中Fifo示例WPF使用XAxis AutoRange设置为Always来缩放轴以适合数据。 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. 该示例开始时,即使Fifo缓冲区的容量为10,000点,也没有数据,因此该轴将按比例缩小以容纳数据。

There are two ways around this: 有两种解决方法:

  1. Is to pre-fill your FIFO DataSeries with X=xValue, Y=double.NaN. 将用X = xValue,Y = double.NaN预填充FIFO DataSeries。 Given enough values the chart will think it has to draw all these points so the XAxis will scale accordingly 给定足够的值,图表将认为必须绘制所有这些点,以便XAxis可以相应地缩放

  2. Is to take control of XAxis.VisibleRange yourself (do not use AutoRange). 是自己控制XAxis.VisibleRange(请勿使用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. 在这种情况下,您需要将XAxis.VisibleRange设置为窗口大小以容纳N点,并且在更新数据时更新窗口。

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. FAQ' 如何在SciChart中创建StripChart '演示了技巧(2),如何更新XAxis的可见范围以实现滚动行为。

Disclosure, I am the tech lead of the SciChart WPF Team 披露,我是SciChart WPF团队的技术负责人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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