This project is read-only.

TwoIndependent Y-Axis Sample does not respond appropriately to Zoom and Pan

Jul 19, 2010 at 8:29 PM
Edited Jul 19, 2010 at 8:36 PM

Hello D3,

I am a new user of D3 and trying to understand your TwoIndependent Axis functionality. I am following your TwoIndependentAxis example in Dev sample and I do see two independent Y Axis. But when I pan the graph only one series pans the other series does not. Also when I zoom on the X-Axis only one series reponds the other series does not. I am guessing both the independent Y Axis share the same X-Axis. Zooming on the X-Axis should cause the zoom in both the series. What am I missing here. I have attached a screen shot of what I am trying to convey. When I try and zoom out on the X-Axis the series Torque does not repond to the X-Axis zoom out. What am I missing here. I have your build number 0.3.4703.0

 

Thanks

Kishore

Jul 19, 2010 at 10:30 PM

Kishore,

You can make the sample work as you require by adding the following code: 

private void Window1_Loaded(object sender, RoutedEventArgs e){
...
...         
plotter.Viewport.PropertyChanged += new EventHandler<ExtendedPropertyChangedEventArgs>(Viewport_PropertyChanged);      
}


void Viewport_PropertyChanged(object sender, ExtendedPropertyChangedEventArgs e)
{
	if (e.PropertyName == "Visible")            
	{               
	 if (innerPlotter.Viewport.Visible.Height != 1.0)                     
	innerPlotter.Viewport.Visible = new DataRect(plotter.Viewport.Visible.XMin, innerPlotter.Viewport.Visible.YMin, plotter.Viewport.Visible.Width, innerPlotter.Viewport.Visible.Height);
            }        
}

Grant.

Jul 19, 2010 at 11:12 PM

Hey Grant,

That works !!!.

Are you a dev on this team? or a user of the library?

Kishore

Jul 20, 2010 at 2:52 AM

Kishore,

I'm a user of D3. 

It's a great tool but the lack of documentation can make it difficult to work out how to achieve the desired result.

Grant.

Jul 20, 2010 at 1:26 PM

 

Thank you Grant - this was a major help to me also.
 
David Roh
Aug 4, 2010 at 8:29 PM
Edited Aug 4, 2010 at 9:44 PM

Panning and Zoom in the graph area has a problem on with the secondary Y-Axis.

When I Pan on the graph it Pans both the series on X-Axis only. In regards to the vertical axis only one axis pans and that is the primary Y-Axis which you can see on the picture.

The secondary Y-Axis (on the right) does not pan. It also does not respond to zoom (MouseWheel scroll events on the Graph Area ) as well.

Can some one help me here?

The response from Grantz on Jul 19 at 4:30 PM helps with X-Axis zoom and pan events on both the series but does not help with zoom and pan on the Graph Area with respect to secondary Y-Axis(on the right)

  

 

 

Aug 4, 2010 at 10:48 PM

Kishore,

This will make the inner plotter follow the panning but it won't respond to the mouse wheel.  No doubt you could make this work as well but I've always assumed users would want to independently scale the left & right vertical axes.

 

        void Viewport_PropertyChanged(object sender, Microsoft.Research.DynamicDataDisplay.ExtendedPropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Visible")
            {
                if (innerPlotter.Viewport.Visible.Height != 1.0)
                {
                    DataRect oldRect = (DataRect) e.OldValue;
                    DataRect newRect = (DataRect) e.NewValue;

                    if (plotter.Viewport.PanningState == Viewport2DPanningState.Panning)
                    {
                        double verticalMove = ((newRect.YMin - oldRect.YMin) / newRect.Height) * innerPlotter.Viewport.Visible.Height;
                        innerPlotter.Viewport.Visible = new DataRect(plotter.Viewport.Visible.XMin, innerPlotter.Viewport.Visible.YMin+verticalMove, plotter.Viewport.Visible.Width, innerPlotter.Viewport.Visible.Height);
                    }
                    else
                        innerPlotter.Viewport.Visible = new DataRect(plotter.Viewport.Visible.XMin, innerPlotter.Viewport.Visible.YMin, plotter.Viewport.Visible.Width, innerPlotter.Viewport.Visible.Height);
                }
            }
        }

Grant.

Aug 5, 2010 at 7:03 PM

Cool, yup I got the zoom to work

Thanks

Kishore