Distance between major ticks

Oct 27, 2010 at 4:26 PM

My x and y axes are both measured in feet.  I need a way to match the distance between tick marks on both axes regardless of how much data is there.

For example:

I have a line that runs 5000 feet down the y axis, but only 100 feet of x axis distance.  The default behavior is for the x axis to stretch that 100 feet into the entire viewable area.  This makes for a very distorted view of the data as the x axis shows as much variance as the y axis, when really it should show nearly a straight line.  What I need is a way to make x axis match the number of feet displayed in the y axis.  So if there is 5000 feet on the Y axis, x shows 5000 feet as well, and vice versa.

Oct 27, 2010 at 4:48 PM

You want to set you ViewPort on the plotter in the Viewport property changed method

void window_load()
{
.
.
.
.
plotter.Viewport.PropertyChanged += Viewport_PropertyChanged;

}


  void Viewport_PropertyChanged(object sender, Microsoft.Research.DynamicDataDisplay.ExtendedPropertyChangedEventArgs e)
  {
      
          if (((Microsoft.Research.DynamicDataDisplay.Viewport2D)sender).Visible.Height != 1.0)
            {
                plotter.Viewport.Visible = new DataRect(0,0,5000,5000);
            }
 }

Kishore Vanapalli

 

Oct 28, 2010 at 3:40 PM
Edited Oct 28, 2010 at 3:45 PM
That works if you know that the content bounds will always be the same and if you know that the viewable area you want will always be the same.  For example, zoom doesn't work with this code.  The visible rectangle just gets adjusted to new DataRect(0,0,5000,5000).  I don't think this is the solution.  I tried something that almost works:
crossSectionChart.Viewport.Domain = new DataRect(new Point(xMin - 1000, -10000), new Point((xMin - 1000) + 10000, 10000));
crossSectionChart.Viewport.FitToViewRestrictions.Add(new HWZoomRestriction(10000, -10000));


    public class HWZoomRestriction : ViewportRestriction
    {
        private double? _minW = null;
        private double? _minH = null;

        public HWZoomRestriction(double? width, double? height)
            : base()
        {
            _minW = width;
            _minH = height;
        }

        public double? MinWidth
        {
            get { return _minW; }
            set
            {
                if (_minW != value)
                {
                    _minW = value;
                    RaiseChanged();
                }
            }
        }

        public double? MinHeight
        {
            get { return _minH; }
            set
            {
                if (_minH != value)
                {
                    _minH = value;
                    RaiseChanged();
                }
            }
        }

        public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
        {
            DataRect newRect = new DataRect();
            if (MinWidth.HasValue && proposedDataRect.Width < MinWidth.Value)
            {
                newRect.XMin = previousDataRect.XMin;
                newRect.Width = MinWidth.Value;
            }
            else
            {
                newRect.XMin = proposedDataRect.XMin;
                newRect.Width = proposedDataRect.Width;
            }
            if (MinHeight.HasValue && proposedDataRect.Height < MinHeight.Value)
            {
                newRect.YMin = previousDataRect.YMin;
                newRect.Height = MinHeight.Value;
            }
            else
            {
                newRect.YMin = proposedDataRect.YMin;
                newRect.Height = proposedDataRect.Height;
            }
            return newRect;
        }
    }

If you do a fit to view with this code, the LineGraph isn't fully displayed. I got the HWZoomRestriction class from this message board. How to restrict zoom on the graph The reason for the negative value on the Height is that my Y axis is inverted.

Editor
Nov 7, 2010 at 9:14 AM

Hi!

My name is Mikhail Brinchuk, and I am a developer of DynamicDataDisplay.

I'm searching now a remote job, so if you or your company can offer it to me, I will be very grateful.

If you want to customize DynamicDataDisplay somehow, I can help you to do it.

My CV is here - https://sites.google.com/site/thecentury/

Best regards,

Mikhail.