Graph data not refreshing after applying Axis Restrictions

Oct 14, 2015 at 8:44 AM
I am trying to impose restriction on X Axis of a line graph and after I do so, the graph stops refreshing.
Here is how I have included the graph in a user control:
            <d3:LineGraph DataSource="{Binding Model.GraphData}" Stroke="Blue"
                          StrokeThickness="2" Name="graph"></d3:LineGraph>
In the code behind of user control, I have applied the axis restrictions based on a couple of dependency properties which are set on run time based on user input. Here is an extract from the code:
private static void OnXMinPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((ucLineGraph)d).myXMin = (double)e.NewValue;
            ApplyRestrictions(d);
        }

        private static void OnXMaxPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((ucLineGraph)d).myXMax = (double)e.NewValue + 1;
            ApplyRestrictions(d);
        }
        private static void ApplyRestrictions(DependencyObject d)
        {
            ((ucLineGraph)d).plotter.Viewport.Restrictions.Clear();
            ((ucLineGraph)d).plotter.Viewport.AutoFitToView = false;
            ViewportAxesRangeRestriction restr = new ViewportAxesRangeRestriction();
            restr.XRange = new DisplayRange(((ucLineGraph)d).myXMin, ((ucLineGraph)d).myXMax);
            ((ucLineGraph)d).plotter.Viewport.Restrictions.Add(restr);
        }
#region Custom Classes to apply Viewport Restrictions
    public class DisplayRange
    {
        public double Start { get; set; }
        public double End { get; set; }

        public DisplayRange(double start, double end)
        {
            Start = start;
            End = end;
        }
    }

    public class ViewportAxesRangeRestriction : IViewportRestriction
    {
        public DisplayRange XRange = null;
        public DisplayRange YRange = null;

        public Rect Apply(Rect oldVisible, Rect newVisible, Viewport2D viewport)
        {
            if (XRange != null && (XRange.Start < XRange.End))
            {
                newVisible.X = XRange.Start;
                newVisible.Width = XRange.End - XRange.Start;
            }

            if (YRange != null)
            {
                newVisible.Y = YRange.Start;
                newVisible.Height = YRange.End - YRange.Start;
            }

            return newVisible;
        }

        public event EventHandler Changed;
    }
    #endregion
I have tried setting the AutoFitToView property to both true an false but in vein.

Can someone please help me with this and guide me what should I be doing to enable auto refresh of the graph. If I remove this restriction, the graph works fine.

PS: I have already implemented the the Property change notification in my model as follows:
public EnumerableDataSource<WavelengthScanResult> GraphData
        {
            get
            {
                return this._graphData ?? (this._graphData = new EnumerableDataSource<WavelengthScanResult>(SampleCollection));
            }
            set
            {
                if (value != null)
                {
                    this._graphData = value;
                    NotifyPropertyChanged("GraphData");
                }
            }
        }
protected void NotifyPropertyChanged(string propInfo)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propInfo));
            }
        }
Many thanks in advance for taking time out to read through my problem and giving it a thought!