1

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?

Stone
  • 235
  • 1
  • 3
  • 9

2 Answers2

3

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.

Jason Higgins
  • 1,516
  • 1
  • 17
  • 37
  • Thanks - it's a "nice to have" - but currently not the solution. Thanks anyway! :-) – Stone Jan 17 '13 at 10:05
  • 1
    Thanks Jason this is great! My charts were temporarily freezing when zooming in too far - this stops that situation occurring and restricts the user to sensible values for our application like 10ms. My label and tick providers don't provide for values less than 1ms so perhaps therein lies the problem - when the axis goes blank it must get caught in some kind of cascade and zooming out will not respond for a while. Busy doing nothing! – The Lonely Coder Sep 10 '15 at 14:14
1

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);
AdrianHHH
  • 13,492
  • 16
  • 50
  • 87
Slash
  • 11
  • 1