Custom Y axises are not resizing after zooming

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Avijit
Newbie
Newbie
Posts: 72
Joined: Tue Sep 15, 2009 12:00 am

Custom Y axises are not resizing after zooming

Post by Avijit » Wed Dec 02, 2009 11:13 am

Hi,

I am having one problem with custom axis resizing.
I have 10 Fastline series with 10 custom y axises.
Position of the Custom axises are something like written below -

_CustomAxis1.StartPosition = 0;
_CustomAxis1.EndPosition = 10;

_CustomAxis2.StartPosition = 11;
_CustomAxis2.EndPosition = 20;

_CustomAxis3.StartPosition = 21;
_CustomAxis3.EndPosition = 30;

And so on....

Each series is associated with one different custom axis so that there is no data overlap.
Now by default all the custom axises are visible. But when i am zooming in - Only 2 or 3 fastline serieses are visible but all other serieses are outside the visible area. I am using the SetMinMax of the custom axis for zooming in. After that i have called the AdjustMinMax fuction to resize the visible custom axises. But the custom axises are not getting resized.
In my application -
Allow.Zoom = false
Axis.Automatic = false

Please let me know how can i solve that problem.

Regards,
Avijit

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Custom Y axises are not resizing after zooming

Post by Sandra » Thu Dec 03, 2009 9:08 am

Hello Avijit,

I recommend use Events Mouseup and MouseDown for update the customAxes. Please see next code and check if it solves your problem.

You need similar code in MouseUp Event:

Code: Select all

       
        void tChart1_MouseUp(object sender, MouseEventArgs e)
        {//Ajust chart axes.        
          
                if((e.X>StartX) && (e.Y >StartY))
                {
                    for(int i=0;i<tChart1.Axes.Custom.Count;i++)
                    {
                  tChart1.Axes.Custom[i].SetMinMax(tChart1.Axes.Custom[i].CalcPosPoint(e.Y),tChart1.Axes.Custom[i].CalcPosPoint(StartY));
                  tChart1.Axes.Bottom.SetMinMax(tChart1.Axes.Bottom.CalcPosPoint(StartX),tChart1.Axes.Bottom.CalcPosPoint(e.X));
                    }
                }
                else
                {
                    for(int i=0; i<tChart1.Axes.Custom.Count;i++)
                    tChart1.Axes.Custom[i].Automatic=true;
                }
        
            }
     
You need similar code in MouseDown Event:

Code: Select all

void  tChart1_MouseDown(object sender, MouseEventArgs e)
        {//and set StartX and StartY values when MouseButton== Left.
            if(e.Button==MouseButtons.Left)
            {
                StartX = e.X;
                StartY = e.Y;
            }
}

If not solve your problem please you could send us a simple project, because we can reproduce here and try to help you with the problem. On the other hand you could say witch version of TeeChart .Net you are using?


I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Avijit
Newbie
Newbie
Posts: 72
Joined: Tue Sep 15, 2009 12:00 am

Re: Custom Y axises are not resizing after zooming

Post by Avijit » Thu Dec 03, 2009 1:57 pm

Hi Sandra,
I am presently doing the same as you suggested.
Problem i am finding is -
Even after calling the SetMinMax fuction the size of the axis is same.
I am checking the size using - IAxisSize parameter.
Means, the custom y axis positions are still showing as -
CustomY -
StartPosition - 0
EndPosition - 10

CustomY1 -
StartPosition - 11
EndPosition - 20

and so on...

I want to change the position of those custom y axis based on the visibility. For example - If after zooming out of 10 data series - only 2 data series is visible fully(in y axis not in x axis) and a 3rd data series is visible partially (in y axis).Then only 2 custom axis + a portion of the third custom axis should take the whole chart height. Start and end of those custom axises should be something like that -

CustomY -
StartPosition - 0
EndPosition - 40

CustomY1 -
StartPosition - 41
EndPosition - 80

CustomY2 - (this axis is visible partially)
StartPosition - 81
EndPosition - 100


I am using the below version of TeeChart -
Version=4.0.2009.28594

Regards,
Avijit

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Custom Y axises are not resizing after zooming

Post by Sandra » Fri Dec 04, 2009 10:25 am

Hello Avijit,

I made a simple example using UnDoneZoom Event and Zoomed Event. You could do something like the following code:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private Steema.TeeChart.Axis axis1;
        private Steema.TeeChart.Axis axis2;
        private Steema.TeeChart.Axis axis3;
        private Steema.TeeChart.Styles.Line lineSeries1;
        private Steema.TeeChart.Styles.Line lineSeries2;
        private Steema.TeeChart.Styles.Line lineSeries3;
        private Steema.TeeChart.Styles.Line lineSeries4;
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            lineSeries1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            lineSeries2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            lineSeries3 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            lineSeries4 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            axis1 = new Steema.TeeChart.Axis();
            axis2 = new Steema.TeeChart.Axis();
            axis3 = new Steema.TeeChart.Axis();
            lineSeries1.FillSampleValues(10);
            lineSeries2.FillSampleValues(10);
            lineSeries3.FillSampleValues(10);
            lineSeries4.FillSampleValues(10);
            lineSeries1.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Left;
            lineSeries2.CustomVertAxis = axis1;
            lineSeries3.CustomVertAxis = axis2;
            lineSeries4.CustomVertAxis = axis3;
            tChart1.Axes.Custom.Add(axis1);
            tChart1.Axes.Custom.Add(axis2);
            tChart1.Axes.Custom.Add(axis3);
            CustomAxesPosition();
            tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
            tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
         
         }

        void tChart1_Zoomed(object sender, EventArgs e)
        {
            axis1.Visible = false;
            axis3.Visible = false;
            lineSeries2.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Left;
            lineSeries3.CustomVertAxis = axis2;
            tChart1.Axes.Left.StartPosition = 0;
            tChart1.Axes.Left.EndPosition = 50;
            axis2.StartPosition = 50;
            axis2.EndPosition = 100;
        }

        void tChart1_UndoneZoom(object sender, EventArgs e)
        {
            lineSeries2.CustomVertAxis = axis1;
            lineSeries4.CustomVertAxis = axis3;
            axis1.Visible = true;
            axis3.Visible = true;
            CustomAxesPosition();
        }
        private void CustomAxesPosition()
        {
            //-----------Custom axes 0-----------------//
            tChart1.Axes.Left.StartPosition = 0;
            tChart1.Axes.Left.EndPosition = 25;
            tChart1.Axes.Left.AxisPen.Color = Color.Red;
            //-----------Custom axes 1----------------//
            axis1.StartPosition = 25;
            axis1.EndPosition = 50;
            axis1.AxisPen.Color = Color.Black;
            //----------Custom axes 2---------------//
            axis2.StartPosition = 50;
            axis2.EndPosition = 75;
            axis2.AxisPen.Color = Color.Purple;
            //----------Custom axes 3--------------//
            axis3.StartPosition = 75;
            axis3.EndPosition = 100;
            axis3.AxisPen.Color = Color.Orange;
           
        }
Please, check next code works as you want.

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Avijit
Newbie
Newbie
Posts: 72
Joined: Tue Sep 15, 2009 12:00 am

Re: Custom Y axises are not resizing after zooming

Post by Avijit » Mon Dec 07, 2009 10:54 am

Hi Sandra,
Problem is i am not using the normal TeeChart zoom.
So, undonezoom and zoomed events are not fired in my application.
Also, i think i am not able to make you understand my problem clearly.

How can I identify what all axis should be visible and what all should not after calling the SetMinMax function? And how can i decide on the size (here Size means the Start position and the End Posotion) of the visible custom axises after zooming? In my application, the custom axises should be resized dynamically.

Regards,
Avijit

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Re: Custom Y axises are not resizing after zooming

Post by Christopher » Mon Dec 07, 2009 12:03 pm

Hello Avijit,
Avijit wrote:Problem is i am not using the normal TeeChart zoom.
This makes it a little more difficult to help you without looking at a small code example we can use to reproduce the problem here.
Avijit wrote:How can I identify what all axis should be visible and what all should not after calling the SetMinMax function? And how can i decide on the size (here Size means the Start position and the End Posotion) of the visible custom axises after zooming? In my application, the custom axises should be resized dynamically.


I think the best thing you could do is to create a new project and use the minimum amount of code necessary to reproduce your issue. You can then upload this project as an attachment to this forum and we can have a look at it to try and help you.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Avijit
Newbie
Newbie
Posts: 72
Joined: Tue Sep 15, 2009 12:00 am

Re: Custom Y axises are not resizing after zooming

Post by Avijit » Tue Dec 08, 2009 8:57 am

Hi Christopher,
I have made a small example so that you can understand the problem.
Below are few screen shots of the application.

Before zooming - (Look at the custom axises at the left side)
BeforeZoom.JPG
BeforeZoom.JPG (54.18 KiB) Viewed 15892 times
After zooming - (Number of custom axis visible is still 10. although only one series is visible.)
AfterZoom.JPG
AfterZoom.JPG (35.87 KiB) Viewed 15894 times
One more -


Project is attached here -
NoResize.zip
(27.21 KiB) Downloaded 754 times
Regards,
Avijit

Avijit
Newbie
Newbie
Posts: 72
Joined: Tue Sep 15, 2009 12:00 am

Re: Custom Y axises are not resizing after zooming

Post by Avijit » Tue Dec 08, 2009 9:09 am

Hi,
One more screeshot below -
Here also - all the custom axises are in the same position even though the series associated with few of the custom axises are not visible (Out of visible area).
OneMoreAfterZoom.JPG
OneMoreAfterZoom.JPG (39.84 KiB) Viewed 15887 times
What we need is - the custom axises should be resized based on the series data values.
If the series is fully visible then the custom axis should be there with proper size. If only one series is visible then the custom axis associated with that series should be the only axis visible and should take the whole area. Means the start and end position should be - 0 and 100.
Similarly, now if 2 data serieses are visible and some portion of a third data series is visible then the custom axis size that is associated with the data series that is partially visible should not be of the same size as other axises.
In that case the custom axises size should be based on the data series visibility.
Hope i am able to make you understand.

Regards,
Avijit

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Custom Y axises are not resizing after zooming

Post by Sandra » Thu Dec 10, 2009 10:28 am

Hello Avijit,

I could reproduce your problem. I think it occurs when you do SetMinMax(), because position of FastLine Series don't paint correctly. Do you need to do SetMinMax() necessarily?
Because, looking at your code, I see that really you don’t need use SetMinMax() function, because labels don't appears and axes resizing although you don't do SetMinMax(). Therefore, if you don't need to do SetMinMax() I suggested remove it. But if I was wrong, please let me know, because we will try find a solution using SetMinMax () function.
On the other hand, please could you check if you are removing the events lines are drawing correctly?

I hope will help.
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Avijit
Newbie
Newbie
Posts: 72
Joined: Tue Sep 15, 2009 12:00 am

Re: Custom Y axises are not resizing after zooming

Post by Avijit » Fri Dec 11, 2009 7:50 am

Hi Sandra,
Do you need to do SetMinMax() necessarily?
Yes. I require this SetMinMax() function call for zooming in and resizing the Custom Axises. And resizing of Custom axises are also very important because - the size and screen location of the custom axises determines the size of few objects that i am drawing inside the control. The objects size is directly related to the size of the custom axises.
On the other hand, please could you check if you are removing the events lines are drawing correctly?
Sorry i did not understood that part.

Regards,
Avijit

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Custom Y axises are not resizing after zooming

Post by Sandra » Mon Dec 14, 2009 12:07 pm

Hello Avijit,

I rewrite your code and I think that I have found a solution that do as you want. Please, you could check that code I have added in this post works correctly ans alse works as you want.If you do not understand something, please you tell us.


I hope will helps.

Thanks,
Attachments
NoResize1.zip
(11.04 KiB) Downloaded 711 times
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply