Adjust Right Axes based on data
Adjust Right Axes based on data
This is probably a much asked question but I was unable to find the answer I needed. My question is this:
I have a stock chart with 300 points. I programatically control how many items are viewable in the chart based on a horizontal scroll bar. However, the right axis is always scaled to the Y min/max of the candle series. How can I programatically change the high of the right axis to be the high of the visible data, and the low to be the low of the visible data.
I know I could calculate where i am in the data (ie points 40-60) and calculate the min and max by iterating through the points, but this would be too slow for a scroll bar type function. Is there anything available to have the right axis automatically adjust to the data visible in the graph?
If nothing is available in the .Net version, what about if I use the ActiveX?
Thanks
- jeff
I have a stock chart with 300 points. I programatically control how many items are viewable in the chart based on a horizontal scroll bar. However, the right axis is always scaled to the Y min/max of the candle series. How can I programatically change the high of the right axis to be the high of the visible data, and the low to be the low of the visible data.
I know I could calculate where i am in the data (ie points 40-60) and calculate the min and max by iterating through the points, but this would be too slow for a scroll bar type function. Is there anything available to have the right axis automatically adjust to the data visible in the graph?
If nothing is available in the .Net version, what about if I use the ActiveX?
Thanks
- jeff
Hi.
I'm sorry, there is no "automatic" way to solve this problem. You'll have to manually calculate visible points minimum and maximum and then set right axis scale according to these values. The following code should do the trick:
This example will be included in next TeeChart .NET maintenance release.
I'm sorry, there is no "automatic" way to solve this problem. You'll have to manually calculate visible points minimum and maximum and then set right axis scale according to these values. The following code should do the trick:
Code: Select all
private void FindMinMax(ValueList v, int firstPoint, int lastPoint, out double min, out double max)
{
min = v.Value[firstPoint];
max = v.Value[lastPoint];
for (int t=firstPoint; t<=lastPoint; t++)
{
if (v.Value[t] < min) min = v.Value[t];
else if (v.Value[t] > max) max = v.Value[t];
}
}
private void AdjustAxisScale(Series s, int firstPoint, int lastPoint, bool vertical)
{
double min, max;
if (vertical)
{
FindMinMax(s.YValues,firstPoint,lastPoint,out min, out max);
s.GetVertAxis.Automatic = false;
s.GetVertAxis.SetMinMax(min,max);
}
else
{
FindMinMax(s.XValues,firstPoint,lastPoint, out min, out max);
s.GetHorizAxis.Automatic = false;
s.GetHorizAxis.SetMinMax(min,max);
}
}
private void button1_Click(object sender, System.EventArgs e)
{
tChart1.Page.Previous();
if (checkBox1.Checked) AdjustAxisScale(candle1,candle1.FirstVisibleIndex,candle1.LastVisibleIndex,true);
else candle1.GetVertAxis.Automatic = true;
}
private void button2_Click(object sender, System.EventArgs e)
{
tChart1.Page.Next();
if (checkBox1.Checked) AdjustAxisScale(candle1,candle1.FirstVisibleIndex,candle1.LastVisibleIndex,true);
else candle1.GetVertAxis.Automatic = true;
}
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
What about the activex control?
What if I use the activex control? Is it easier in that version since the .NET version does not seem quite as robust yet. I noticed something about a VisibleMax or MaxVisible property ???? Could I do it better in that control?
- jeff
- jeff
Still need an answer here
I still need to know the answer to this question:
What if I use the activex control? Is it easier in that version since the .NET version does not seem quite as robust yet. I noticed something about a VisibleMax or MaxVisible property ???? Could I do it better in that control?
- jeff
What if I use the activex control? Is it easier in that version since the .NET version does not seem quite as robust yet. I noticed something about a VisibleMax or MaxVisible property ???? Could I do it better in that control?
- jeff
Re: What about the activex control?
Hmm... I think in the end you'll still have to use the same approach and manually calculate visible points minimum and maximum value and then adnjust vertical axis scale according to these two limits (use the same approach, but slightly different code).6926932 wrote:What if I use the activex control? Is it easier in that version since the .NET version does not seem quite as robust yet. I noticed something about a VisibleMax or MaxVisible property ???? Could -
jeff
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
Is there any improvement about this subject?
my chart has custom vertical axes and many series (related with custom axes)
I try to adjust minimum and maximum values for every Custom Vertical Axis.But each vertical custom axis has got own series (series,function more than one )..
Its very hard to adjust all series,functions related custom vertical axes(Because for example ;Moving Average begins after n day from base series )
So are automatic minimum and automatic maximum abilities ready?
And whats your suggestion about this situation (mine)
Thx..
I try to adjust minimum and maximum values for every Custom Vertical Axis.But each vertical custom axis has got own series (series,function more than one )..
Its very hard to adjust all series,functions related custom vertical axes(Because for example ;Moving Average begins after n day from base series )
So are automatic minimum and automatic maximum abilities ready?
And whats your suggestion about this situation (mine)
Thx..
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi glikoz,
Yes, custom axes work automatically and that's the approach I would use. Please notice that Marjan's reply is from October 2004. Since then, a lot of things have been done in TeeChart for .NET and in June 2005 TeeChart for .NET v2 was released.
Yes, custom axes work automatically and that's the approach I would use. Please notice that Marjan's reply is from October 2004. Since then, a lot of things have been done in TeeChart for .NET and in June 2005 TeeChart for .NET v2 was released.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Please open
Welcome !\Functions\Financial\CCI (Commodity Channel Index)
Then zoom in ...
Altough,
Its behaviour is different ...Always about 200 is maximum value of tChart1.Axes.Custom[0] 's ...
I have same problem as i show..
is it not enough to set axis's automatic property to true ?
Welcome !\Functions\Financial\CCI (Commodity Channel Index)
Then zoom in ...
Altough,
Code: Select all
tChart1.Axes.Custom[0].Automatic=true
I have same problem as i show..
is it not enough to set axis's automatic property to true ?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi glikoz,
Ok, custom axes don't zoom automatically you need to implement it as told here. This is a Delphi example but you shouldn't have any problem porting it to C#.
Ok, custom axes don't zoom automatically you need to implement it as told here. This is a Delphi example but you shouldn't have any problem porting it to C#.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
in my application ...
Its about "scaling" to Datas....
If user zooms between two dates i draw custom axis for CCI graphic between CCImax(at this interval)- CCImin(at this interval) values apart from where zoom begin (vertically) ...
Could i explain ? If we look history
I hope i could explain ...
Thx.
Code: Select all
this.Zoom.Direction = ZoomDirections.Horizontal;
If user zooms between two dates i draw custom axis for CCI graphic between CCImax(at this interval)- CCImin(at this interval) values apart from where zoom begin (vertically) ...
Could i explain ? If we look history
I have a candle and three functions ; some functions start at 8. day (i couldnt easily calculate max,min values for verticalaxis)I have a stock chart with 300 points. I programatically control how many items are viewable in the chart based on a horizontal scroll bar. However, the right axis is always scaled to the Y min/max of the candle series. How can I programatically change the high of the right axis to be the high of the visible data, and the low to be the low of the visible data.
I know I could calculate where i am in the data (ie points 40-60) and calculate the min and max by iterating through the points, but this would be too slow for a scroll bar type function. Is there anything available to have the right axis automatically adjust to the data visible in the graph?
I hope i could explain ...
Thx.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi glikoz,
If the automatic scaling is not what youe wants then you'll have to do something similar to what Marjan suggested on his first reply. Also, don't forget that, as I told in my previous post, code has to be implemented to get custom axes to zoom.
If that's not clear enough or that's not what are you really looking for, could you please send us an example we can run "as-is" to reproduce the problem here?
You can post your files at news://www.steema.net/steema.public.attachments newsgroup.
If the automatic scaling is not what youe wants then you'll have to do something similar to what Marjan suggested on his first reply. Also, don't forget that, as I told in my previous post, code has to be implemented to get custom axes to zoom.
If that's not clear enough or that's not what are you really looking for, could you please send us an example we can run "as-is" to reproduce the problem here?
You can post your files at news://www.steema.net/steema.public.attachments newsgroup.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
I couldnt implement
Maybe picture could tell us everything ...
We have one main series(candle) and two functions (related with main series)..One of the function is Our Custom Volume Function the other is Custom Moving Average (of Volume Function)..Because of the nature of Moving Average , it doesnt start from starting point of Chart (period)..
So i couldnt use these variables(startIndex,endIndex) for MovingAverage:
These values are usable for Candle series(Main series) and Volume series ,but not for Moving Average...I couldnt access starting and ending point of MovingAverage ...
This code is useless too :
I will calculate Maximum and minimum values for every CustomVerticalAxis by means of related Series(Functions')
Thx for best aids..
We have one main series(candle) and two functions (related with main series)..One of the function is Our Custom Volume Function the other is Custom Moving Average (of Volume Function)..Because of the nature of Moving Average , it doesnt start from starting point of Chart (period)..
So i couldnt use these variables(startIndex,endIndex) for MovingAverage:
Code: Select all
void RChart_Zoomed(object sender, EventArgs e)
{
int startIndex = Convert.ToInt32(this.Axes.Bottom.CalcPosPoint(this.Zoom.x0));
int endIndex = Convert.ToInt32(this.Axes.Bottom.CalcPosPoint(this.Zoom.x1));
}
This code is useless too :
Code: Select all
void RChart_Zoomed(object sender, EventArgs e)
{
//Application.DoEvents();
int a=MovingAverage.CustomPoint.FirstVisibleIndex;
}
Thx for best aids..
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi glikoz,
Sorry but I still don't understand what are you exactly trying to achieve. Could you please extend on that or modify the image you posted drawing what would you like to get?
Thanks in advance.
Sorry but I still don't understand what are you exactly trying to achieve. Could you please extend on that or modify the image you posted drawing what would you like to get?
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 |
Instructions - How to post in this forum |
I try to make "Adjust Scaling " same as in this topic, but it is more complex because of Many Functions
For our sample graph ;
For sample zoom;
First Custom Vertical Axis's maximum must be equal about 43000
Firts Custom Vertical Axis's minimum must be equal 0
15.1.1998 is first value of 2nd Function (Moving Average)
I have to collect
12,13,14,15,16,19,20 th values of Volume and
15,16,19,20 th values of Moving Average
and calculate min and max values fromthis collection ...
I can access Volume Values by help of MouseClick :
But i couldnt use same approach for MovingAverage BECAUSE :
MovingAverageFunction.CustomPoint[0].X not equal VolumeFunction.CustomPoint[0].X
For our sample graph ;
For sample zoom;
First Custom Vertical Axis's maximum must be equal about 43000
Firts Custom Vertical Axis's minimum must be equal 0
15.1.1998 is first value of 2nd Function (Moving Average)
I have to collect
12,13,14,15,16,19,20 th values of Volume and
15,16,19,20 th values of Moving Average
and calculate min and max values fromthis collection ...
I can access Volume Values by help of MouseClick :
Code: Select all
private void RChart_Zoomed(object sender, EventArgs e)
{
int startIndex = Convert.ToInt32(this.Axes.Bottom.CalcPosPoint(this.Zoom.x0));
int endIndex = Convert.ToInt32(this.Axes.Bottom.CalcPosPoint(this.Zoom.x1));
int MaxVolume=0;
for (int i=startIndex;i<=endIndex;i++){
if (VolumeFunction.CustomPoint[0].Y>MaxVolume)
MaxValue=VolumeFunction.CustomPoint[0].Y;
}
}
MovingAverageFunction.CustomPoint[0].X not equal VolumeFunction.CustomPoint[0].X
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi glikoz,
It works fine for me here using:
Where line1 is the moving average function series.
It works fine for me here using:
Code: Select all
private void Form1_Load(object sender, System.EventArgs e)
{
this.candle1.FillSampleValues();
this.volume1.FillSampleValues();
}
private void tChart1_Zoomed(object sender, System.EventArgs e)
{
axis1.SetMinMax(Math.Min(volume1.GetVertAxis.CalcPosPoint(tChart1.Zoom.y1),line1.GetVertAxis.CalcPosPoint(tChart1.Zoom.y1)),
Math.Max(volume1.GetVertAxis.CalcPosPoint(tChart1.Zoom.y0),line1.GetVertAxis.CalcPosPoint(tChart1.Zoom.y0)));
}
private void tChart1_UndoneZoom(object sender, System.EventArgs e)
{
axis1.Automatic=true;
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |