maxvisibleseriesvalue

TeeChart for ActiveX, COM and ASP
Post Reply
qanta
Newbie
Newbie
Posts: 7
Joined: Mon Apr 18, 2005 4:00 am

maxvisibleseriesvalue

Post by qanta » Wed Apr 20, 2005 1:30 pm

Hello,

I am trying to use the maxvisibleseriesvalue to calculate a max and min for the chart axis based only on the visible series.

When I call the function, for example:
ymax=tchart1.axis.right.maxvisibleseriesvalue(true,0)

I get an error:
Run-time error '-2147418113 (8000ffff)

range check error.

Is there a different way to do this?

(I am using activex v7 and the series are line plots with XY coords)

thanks

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 Apr 20, 2005 1:56 pm

Hello qanta,
Is there a different way to do this?
Yes, the default axes settings already behaves like that. You just have to leave them setted to Automatic as in the code below or using the chart editor (right-click on the chart and select edit).

Code: Select all

    TChart1.Axis.Left.Automatic = True
or

Code: Select all

    TChart1.Axis.Left.AutomaticMaximum = True
    TChart1.Axis.Left.AutomaticMinimum = 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
Image Image Image Image Image Image
Instructions - How to post in this forum

qanta
Newbie
Newbie
Posts: 7
Joined: Mon Apr 18, 2005 4:00 am

Post by qanta » Wed Apr 20, 2005 2:02 pm

Hi, thanks for the reply (that was quick!)

I have turned the automatic scaling off, because I like to add 10% of space above and below the max and min points in graph. So I am trying to find the max and min visible values in the graph in order to do this.

Am I using the wrong parameters for maxvisibleseriesvalue? (the help file says the second parameter is ignored if the 1st is set to true)

thanks

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 Apr 20, 2005 2:33 pm

Hi qanta,
Hi, thanks for the reply (that was quick!)


You're welcome 8)!
I have turned the automatic scaling off, because I like to add 10% of space above and below the max and min points in graph. So I am trying to find the max and min visible values in the graph in order to do this.
Ah, ok, now I understand what you want. Then you'd better use axes offset properties like in the code snippet below. First turn axes to automatic again, then you have to force chart drawing (using InternalRepaint method) to apply correctly axes offset from the beginning. Finally you can implement the offsetting in the OnAfterDraw event as:

Code: Select all

Private Sub Form_Load()
    For i = 0 To TChart1.SeriesCount - 1
        TChart1.Series(i).FillSampleValues 10
    Next i
    
    TChart1.Environment.InternalRepaint
End Sub

Private Sub TChart1_OnAfterDraw()
    Dim offset As Double

    offset = (TChart1.Axis.Left.Maximum - TChart1.Axis.Left.Minimum) * 0.1

    TChart1.Axis.Left.MinimumOffset = offset
    TChart1.Axis.Left.MaximumOffset = offset
End Sub
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

qanta
Newbie
Newbie
Posts: 7
Joined: Mon Apr 18, 2005 4:00 am

Post by qanta » Wed Apr 20, 2005 3:20 pm

great, that's a really good method :)

btw. I was able to find the max and mins with this function:

tchart1.series(0).valuelists.items(1).maximum

and then rotating through all the visible series.


but your method is certainly better, and more efficient :D

Post Reply