在我的WPF的項目中,我使用Dynamic data display的圖表縮放。 我在某處讀到,如果放大得非常深,線條就會消失(未繪製)。線消失(使用「動態數據顯示」)
有沒有人對這個bug的解決方案?
在我的WPF的項目中,我使用Dynamic data display的圖表縮放。 我在某處讀到,如果放大得非常深,線條就會消失(未繪製)。線消失(使用「動態數據顯示」)
有沒有人對這個bug的解決方案?
雖然不是你的錯誤確切的解決方案,可以防止用戶通過使用縮放制約太深放大。通過這種方式,用戶永遠不會遇到這個問題。您可以找到該錯誤發生的縮放比例,並限制該DataRect的縮放比例。我寫了自己的課程來限制縮放D3,並將爲您提供。
這裏:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
namespace Microsoft.Research.DynamicDataDisplay.ViewportRestrictions {
/// <summary>
/// Represents a restriction, which limits the maximal size of <see cref="Viewport"/>'s Visible property.
/// </summary>
public class ZoomInRestriction : ViewportRestriction {
/// <summary>
/// Initializes a new instance of the <see cref="MaximalSizeRestriction"/> class.
/// </summary>
public ZoomInRestriction() { }
/// <summary>
/// Initializes a new instance of the <see cref="MaximalSizeRestriction"/> class with the given maximal size of Viewport's Visible.
/// </summary>
/// <param name="maxSize">Maximal size of Viewport's Visible.</param>
public ZoomInRestriction(double height, double width) {
Height = height;
Width = width;
}
private double height;
private double width;
public double Height {
get { return height; }
set {
if (height != value) {
height = value;
RaiseChanged();
}
}
}
public double Width {
get { return width; }
set {
if (width != value) {
width = value;
RaiseChanged();
}
}
}
/// <summary>
/// Applies the specified old data rect.
/// </summary>
/// <param name="oldDataRect">The old data rect.</param>
/// <param name="newDataRect">The new data rect.</param>
/// <param name="viewport">The viewport.</param>
/// <returns></returns>
public override DataRect Apply(DataRect oldDataRect, DataRect newDataRect, Viewport2D viewport) {
if ((newDataRect.Width < width || newDataRect.Height < height)) {
return oldDataRect;
}
return newDataRect;
}
}
}
現在你可以使用這個在你的代碼來實現這樣的限制:
plotter.Viewport.Restrictions.Add(new ZoomInRestriction(height, width));
雖然不是以這個bug的解決方案,你至少應該能夠阻止用戶體驗它。
更多細節
在LineGraph.cs
,方法OnRenderCore
參見https://dynamicdatadisplay.codeplex.com/discussions/484160。 從
context.BeginFigure(FilteredPoints.StartPoint, false, false);
替換以下行來
context.BeginFigure(FilteredPoints.StartPoint, true, false);
感謝 - 這是一個「不錯的」 - 但目前不是解決辦法。不管怎麼說,還是要謝謝你! :-) – Stone
謝謝傑森,這太棒了!當放大太遠時,我的圖表會暫時凍結 - 這會阻止這種情況的發生,並將用戶限制爲適用於我們的應用程序的合理值,例如10毫秒。我的標籤和刻度提供商不提供值小於1ms所以也許就是問題所在 - 當軸一片空白,必須會陷入某種級聯和縮小不會一會兒迴應。忙於無所事事! –