In my WPF-project I'm using Dynamic data display for charting. I read somewhere that it's a common bug that lines disappear (are not drawn) if you zoom in very deeply.
Has anybody a solution for this bug?
In my WPF-project I'm using Dynamic data display for charting. I read somewhere that it's a common bug that lines disappear (are not drawn) if you zoom in very deeply.
Has anybody a solution for this bug?
While not an exact solution to your bug, you can prevent a user by zooming in too deep by using a zoom restriction. That way a user will never experience this bug by zooming in that deep. You can find at what zoom this bug is occuring, and restrict the zoom at that DataRect. I wrote my own class to restrict Zooming in D3 and will provide it for you.
Here:
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;
}
}
}
Now you can use this in your code to implement the restriction like this :
plotter.Viewport.Restrictions.Add(new ZoomInRestriction(height, width));
While not being the exact solution to the bug, you should at least be able to prevent a user from experiencing it.
See https://dynamicdatadisplay.codeplex.com/discussions/484160 for more details
In LineGraph.cs
, method OnRenderCore
.
Replace the following line from
context.BeginFigure(FilteredPoints.StartPoint, false, false);
to
context.BeginFigure(FilteredPoints.StartPoint, true, false);