1

I've been looking through the new (and really great!) SciChart Tutorial, and I've run into an issue. I'm trying to use the ViewportManager API to make a realtime-updating chart zoomable and scrollable. However this bit of code is not working:

// Don't Scroll if user is Zooming
if (ParentSurface.ZoomState == ZoomStates.UserZooming) {
    return currentVisibleRange;
}

I'm getting errors, for both ZoomState and ZoomStates, letting me know that ISciChartSurface does not contain a definition for ZoomState. As far as I can tell ZoomStates should be an enum in SciChart.Charting.Visuals, however I can't find it in the Assembly Explorer. Is it somehow missing from my installation of SciChart? Or have I - as per usual - made some really stupid mistake? What can I do about this? Thanks!

Info: SciChart version 4.1.1.8645

Full class code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SciChart.Charting.ViewportManagers;
using SciChart.Charting.Visuals;
using SciChart.Charting.Visuals.Axes;
using SciChart.Data.Model;



namespace SciCharter {
    /// <summary>
    /// Applies a scrolling window to the chart unless the user is zooming or panning
    /// </summary>
    public class ScrollingViewportManager : DefaultViewportManager {
        private readonly double _windowSize;
        public ISciChartSurface ParentSurface { get; set; }

        public ScrollingViewportManager(double windowSize) {
            _windowSize = windowSize;
        }

        public override void AttachSciChartSurface(ISciChartSurface scs) {
            base.AttachSciChartSurface(scs);
            this.ParentSurface = scs;
        }

        protected override IRange OnCalculateNewXRange(IAxis xAxis) {
            // The Current XAxis Visible Range
            var currentVisibleRange = xAxis.VisibleRange.AsDoubleRange();

            // Don't Scroll if user is Zooming
            if (ParentSurface.ZoomState == ZoomStates.UserZooming) {
                return currentVisibleRange;
            }

            var maxXRange = xAxis.GetMaximumRange().AsDoubleRange();
            double xMax = Math.Max(maxXRange.Max, currentVisibleRange.Max);

            // Scroll showing latest window range
            return new DoubleRange(xMax - _windowSize, xMax);

        }
    }
}
4

1 回答 1

1

在文章SciChart WPF: New set of tutorials now online中说:

教程包括... WPF 图表教程 06 – 添加实时更新(15 分钟)使用 SciChart v4.2 中的一些功能,该功能现在处于 QA 阶段,仅在夜间构建提要中可用。

SciChart WPF Nightly Builds 可从私人 nuget 源获得。可以在此处找到有关如何访问它们的完整说明。

希望这可以帮助!

于 2016-11-18T08:01:49.857 回答