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);
}
}
}