Page 1 of 1

maxvisibleseriesvalue

Posted: Wed Apr 20, 2005 1:30 pm
by 9526659
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

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

Posted: Wed Apr 20, 2005 2:02 pm
by 9526659
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

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

Posted: Wed Apr 20, 2005 3:20 pm
by 9526659
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