[ASK] Center position of axis

Apr 19, 2010 at 4:24 AM

Hi All,

First of all thanks to D3 teams for the great chart library.

I am new to this library. Is it possible to show X/Y axis centralize (just like hand draw cartesian coordinate) instead of show the axis at the border (left-right or top-buttom) of the control ?

If yes anyone could tell me how to implement that ?

 

Regards,

Jun

 

 

Editor
Apr 19, 2010 at 11:06 PM

Hi Jun,

Thank you for your thanks.) Currently everything connected to WPF is made by single person - me, but other people are working on colormaps on warped grids, and 3d visualization.

Now we do not ptovide such kind of functionality, but somebody in this 'Discussions' forum has made it, so please use search and find him and his solution.

In the future we maybe will provide our own solution.

Best regards,

Mikhail.

Apr 20, 2010 at 7:07 AM

Hi Mikhail, Thanks for quick reply.

I got it and it works fine for me now.

 

Regards,

 

Jun

Editor
Apr 20, 2010 at 7:09 AM

Hi Jun, 

Can you please post a link to that discussion so that users of codeplex could easier find this solution?

Best regards,

Mikhail.

Apr 20, 2010 at 7:25 AM

Sure.

The reference is here : http://dynamicdatadisplay.codeplex.com/Thread/View.aspx?ThreadId=71608

But we need minor modification of the original reference to make it works with latest version on source code.

Here the code  :

private void OnViewportPropertyChanged(object sender, ExtendedPropertyChangedEventArgs e)
        {            
            Viewport2D viewport = (Viewport2D)sender;

            DataRect visible = viewport.Visible;

            DataRect dataRect = visible.ViewportToData(viewport.Transform);
            bool forceUpdate = dataRect != prevDataRect;
            prevDataRect = dataRect;

            Range<T> range = CreateRangeFromRect(dataRect);

            using (axisControl.OpenUpdateRegion(false))
            {
                axisControl.Range = range;
                axisControl.Transform = viewport.Transform;

                if (axisControl.AxisTiedToOrigin)
                {

                    //bcz: allow the axes anchored to the left and right to float with the Origin
                    if (axisControl.Placement == AxisPlacement.Left)
                    {                       
                        double min = visible.ToRect().Left;
                        double max = visible.ToRect().Right;

                        if (max > 0 && min < 0)
                        {
                            double xorigin = (0 - min) / (max - min) * viewport.Output.Width;
                            axisControl.RenderTransform = new TranslateTransform(xorigin, 0);
                            axisControl.ShowZeros = false;
                        }
                        else
                            axisControl.ShowZeros = true;
                        if (min > 0)
                            axisControl.RenderTransform = new TranslateTransform(0, 0);
                        if (max < 0)
                            axisControl.RenderTransform = new TranslateTransform(viewport.Output.Width, 0);
                    }
                    if (axisControl.Placement == AxisPlacement.Bottom)
                    {
                        double min = visible.ToRect().Bottom;
                        double max = visible.ToRect().Top;
                        if (max < 0 && min > 0)
                        {
                            double yorigin = (0 - min) / (max - min) *
                                viewport.Output.Height;
                            axisControl.RenderTransform = new TranslateTransform(0, -viewport.Output.Height + yorigin);
                            axisControl.ShowZeros = false;
                        }
                        else
                            axisControl.ShowZeros = true;
                        if (max > 0)
                            axisControl.RenderTransform = new TranslateTransform(0, 0);
                        if (min < 0)
                            axisControl.RenderTransform = new TranslateTransform(0, -viewport.Output.Height);
                    }
                }
            }
        }

 

Please let me know if you have better solution.

Oh yeah FYI I compile from 29055 nightly build.

 

Regards,

 

Junaidi

Editor
Apr 21, 2010 at 12:54 PM

Hi Junaidi,

Can you please add this issue to our 'Issue Tracker'?

I decided (after years of using codeplex) to start using it to manage incoming feature requests and issues.

Best regards,

Mikhail.

Apr 22, 2010 at 3:15 AM

Hi Mikhail,

Sure, that would be great.

 

Regards,

Jun