我一直在寻找新的(真的很棒!)SciChart Tutorial,我遇到了一个问题。我正在尝试使用ViewportManager API使实时更新图表可缩放和可滚动。但是这段代码不起作用:
// Don't Scroll if user is Zooming
if (ParentSurface.ZoomState == ZoomStates.UserZooming) {
return currentVisibleRange;
}
我收到ZoomState和ZoomStates的错误,让我知道ISciChartSurface不包含ZoomState的定义。据我所知,ZoomStates应该是SciChart.Charting.Visuals中的枚举,但是我无法在Assembly Explorer中找到它。我在安装SciChart时是否遗漏了某些东西?或者我 - 按照惯例 - 犯了一些非常愚蠢的错误?我该怎么办?谢谢!
的信息: SciChart版本4.1.1.8645
全班代码:
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);
}
}
}
答案 0 :(得分:1)
在文章SciChart WPF: New set of tutorials now online中,它说:
教程包含 ... WPF Chart Tutorial 06 – Adding Realtime Updates(15分钟)使用了SciChart v4.2中的一些功能,这些功能现在在QA中,仅在每晚构建源中可用。
SciChart WPF Nightly Builds可从私人nuget Feed获得。可以找到有关如何访问它们的完整说明here。
希望这有帮助!