Adjust Right Axes based on data

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
glikoz
Newbie
Newbie
Posts: 34
Joined: Mon May 05, 2003 4:00 am

Post by glikoz » Tue Mar 07, 2006 12:28 pm

this.Zoom.Direction = ZoomDirections.Horizontal

How could you use Zoom.y0 to calculate maximum value of moving average ?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 07, 2006 2:03 pm

Hi glikoz,

Then you can use something like:

Code: Select all

		private void Form1_Load(object sender, System.EventArgs e)
		{
			this.candle1.FillSampleValues();
			this.volume1.FillSampleValues();
			
			line1.Marks.Visible=true;

			tChart1.Zoom.Direction=Steema.TeeChart.ZoomDirections.Horizontal;
		}

		private void tChart1_Zoomed(object sender, System.EventArgs e)
		{
			Point p=Control.MousePosition;
			
			axis1.SetMinMax(Math.Min(volume1.GetVertAxis.CalcPosPoint(p.Y),line1.GetVertAxis.CalcPosPoint(p.Y)),
				Math.Max(volume1.GetVertAxis.CalcPosPoint(Y0),line1.GetVertAxis.CalcPosPoint(Y0)));
		}

		private void tChart1_UndoneZoom(object sender, System.EventArgs e)
		{
			axis1.Automatic=true;
		}
	
		private int Y0;

		private void tChart1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			Y0=e.Y;
		}
Best Regards,
Narcís Calvet / 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

glikoz
Newbie
Newbie
Posts: 34
Joined: Mon May 05, 2003 4:00 am

Post by glikoz » Tue Mar 07, 2006 2:46 pm

Vertical position of Mouse is not important for Horizontal Zoom .When developer chooses Horizontal it means that
"We ignore vertical position of mouse and all of the area will be zoomed between horizontal projection .."

When user wants to zoom between two dates we show him/her what he/she could see between two date ! it is done easily by this.Axes.Bottom.SetMinMax ..But adjusting scale is not easy ..
To calculate Min-Max points in the choosen interval
you have to access every point of all lines...Problem is starting at this point ..We have firstIndex,LastIndex for BottomAxes ..And i could use them for Volume Function (Volume[startIndex])
but i couldnt use this approach for MovingAverage (Because there is phase diffrence between them ) .So i research another approach ..
For example ;For a line:
Is there any function like that

Line.GetYValue(object XValue) ...

Best regards ...
Last edited by glikoz on Tue Mar 07, 2006 2:56 pm, edited 1 time in total.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 07, 2006 2:51 pm

Hi glikoz,
Vertical position of Mouse is not important for Horizontal Zoom .When developer chooses Horizontal it means that
"We ignore vertical position of mouse and all of the area will be zoomed between horizontal projection .."
The vertical position is important to know the zoomed area and thus properly scale the vertical custom axis.

Code: Select all

Is there any function like that 

Line.GetYValue(object XValue) ... 
Yes, try using CalcYPosValue method which returns the pixel screen vertical coordinate of the specified value:

Code: Select all

line1.CalcYPosValue(double value)
Best Regards,
Narcís Calvet / 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

glikoz
Newbie
Newbie
Posts: 34
Joined: Mon May 05, 2003 4:00 am

Post by glikoz » Tue Mar 07, 2006 3:17 pm

I mean that function (no pixels) :
Line.GetYValueOfLine(object XValueOfLine) ...
I try to communicate again (last one :) ) from starting point

1- Open TeeChart Examples.csproj...
2- Go Function_CCI.cs
3- Add this code to constructor of form (public Function_CCI())

Code: Select all

this.tChart1.Zoom.Direction = teema.TeeChart.ZoomDirections.Horizontal;
4-RunProject ..
5- Goto Function_CCI Form (Welcome !\Functions\Financial\CCI (Commodity Channel Index))
6- Make zoom diffrent points of Chart ...
7- Are min and max points changing or stable for custom vertical axes ?
Right answer is stable..For some zooms there are big spaces ..We try to get rid of them ,we try to adjust scale,we try to set min and max values for every custom vertical axis...

Best Regards

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 07, 2006 3:38 pm

Hi glikoz,
I mean that function (no pixels) :
Line.GetYValueOfLine(object XValueOfLine) ...
Sorry but I don't understand what do you exactly mean with that. Could you please be more specific?
Right answer is stable..For some zooms there are big spaces ..We try to get rid of them ,we try to adjust scale,we try to set min and max values for every custom vertical axis...
This is what the code using the MouseDown event I posted earlier today does. Have you tried that code? If you want I can send you the complete project to your forums profile e-mail address.
Best Regards,
Narcís Calvet / 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

glikoz
Newbie
Newbie
Posts: 34
Joined: Mon May 05, 2003 4:00 am

Post by glikoz » Tue Mar 07, 2006 4:58 pm

Narcis i can understand all of your suggestions but they dont solve my problem ..Please could you follow tutorial in my last post ?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Mar 08, 2006 9:03 am

Hi glikoz,

I already did that and I see what you reported but precisely, the code I posted, solves that problem. I'm going to send you the full project. Can you please test it if its ok for you or please modify it so that we can reproduce your problems here?
Best Regards,
Narcís Calvet / 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

glikoz
Newbie
Newbie
Posts: 34
Joined: Mon May 05, 2003 4:00 am

Post by glikoz » Wed Mar 08, 2006 4:25 pm

Thx Narcis ...I got it ..I will post problem as complete solution to you until Friday ..I will send project to you as VS 2005 project ..I hope its not a problem for you ..

Best Regards ..

glikoz
Newbie
Newbie
Posts: 34
Joined: Mon May 05, 2003 4:00 am

It couldnt solve

Post by glikoz » Fri Mar 10, 2006 12:20 pm

I want to talk about program you sent ..
Please First Set MovingAverage's period property to 9.
it is first looking to graphic :
Image

And we are zooming as you can see below :(Please attention ..Mouse's vertical position)
Image

What do we expect ?For 1st vertical axis , we have to look maximum values for MovingAverage and Volume ..Maximum value is 20 for Volume; it is 35,24 for Moving Average..So maximum value is Max (20,35.24)=35.24 Is it clear up to now ?

What about minimum value for this interval ..

Min( Min (35.24,32.34,30.26), Min(20,20,15)) =15
Is it clear again ? Sooooooo What do we expect ?
We expect graphic between 15-35.24 .....
But!!!! I said from beginning "You Couldnt Use Mouse Position!!!"
Image


I couldnt use Moving Average's period property also because i will have more complicated function (My custom function library)....
What is your advice for this situation ..

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Mar 20, 2006 2:58 pm

Hi glikoz,

Could you please send us an example we can run "as-is" so that we can reproduce this problem here?

Thanks in advance.
Best Regards,
Narcís Calvet / 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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Mar 23, 2006 2:43 pm

Hi glikoz,

We (Christopher Ireland and I) have been looking further at the issue. The problem is not the automatic scaling, is in zooming a custom axis an the visible indexes involved.

We came up with the code below which is the best custom axis zoom aproximation we found.

One think to be commented here is that this code also considers the point previous and the point posterior to the onew in the visible range. To ease that we implemented the code which is in the region between the asterisc comments.

Another valid approach for that would be using ClipRegions as shown in the All Features\Welcome !\Axes\Opaque zones example at TeeChart features demo, available at TeeChart's program group.

If necessary I can send you the complete project for the code below.

Code: Select all

		private void Form1_Load(object sender, System.EventArgs e)
		{
			this.candle1.FillSampleValues();
			this.volume1.FillSampleValues();
			line1.Marks.Visible=true;
			axis1.Automatic=false;
			Bitmap bmp = tChart1.Bitmap;
			ResizeAxis();

			tChart1.Zoom.Direction=Steema.TeeChart.ZoomDirections.Horizontal;
		}

		private void tChart1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			once = true;
		}

		private void tChart1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if(once) 
			{
				once = false;
				Bitmap bmp = tChart1.Bitmap;
			}
			ResizeAxis();
						
		}

		private int ind0=0, ind1=0;
		double max=0, min=10000;
		bool once= false;

		private void ResizeAxis() 
		{
			ind0 = line1.FirstVisibleIndex;
			ind1 = line1.LastVisibleIndex;
			max=0;
			min=line1.YValues.Maximum;
			
			for(int i =ind0; i <= ind1; ++i) 
			{
				if(line1.YValues[i] > max) 
					max = line1.YValues[i];
				if(line1.YValues[i] < min)
					min = line1.YValues[i];
			}		
			label1.Text = min.ToString();

			//********************
			if((ind0 - 1) >= 0) 
			{
				if(line1.YValues[ind0 - 1] > max)
					max = line1.YValues[ind0 - 1];
				else if(line1.YValues[ind0 - 1] < min)
					min = line1.YValues[ind0 - 1];
			}

			if((ind1 + 1) < line1.Count) 
			{
				if(line1.YValues[ind1 + 1] > max)
					max = line1.YValues[ind1 + 1];
				else if(line1.YValues[ind1 + 1] < min)
					min = line1.YValues[ind1 + 1];
			}
			//********************
			axis1.SetMinMax(min, max);
		}
Best Regards,
Narcís Calvet / 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