Page 1 of 1

Marker Values > Maximum [Horiz. Bar Chart]

Posted: Tue Dec 27, 2005 3:22 pm
by 9529743
Hello,

I am new to TeeChart (great tool!) and have a problem, which is maybe not very difficult, but i should have fixed it until tomorrow, so I hope you can help me.

I have a horizontal Bar Chart with a YAxis minimum value of 50 and a maximum value of 130. This is fix!

Sometimes it can happen, that a value is bigger than 130 or smaller than 50, then no value is showed on the graph (what is correct)

I want to show this values, but something failed, when I tried it.

The last code i tried was the following:


Visual Basic Code:

Code: Select all

        If tc.series(i).ValueLists.Items(1).value(ii) > 130 Then
                    
            saveValue = tc.series(i).ValueLists.Items(1).value(ii)
            
            tc.series(i).ValueLists.Items(1).value(ii) = 125
            tc.Environment.InternalRepaint
            
            xValue = tc.series(i).Marks.Positions.Position(ii).LeftTop.X
            yValue = tc.series(i).Marks.Positions.Position(ii).LeftTop.Y
                   
            tc.series(i).ValueLists.Items(1).value(ii) = saveValue
            
            tc.series(i).Marks.Positions.Position(ii).Custom = True
            tc.series(i).Marks.Positions.Position(ii).LeftTop.Y = yValue
            tc.series(i).Marks.Positions.Position(ii).LeftTop.X = xValue
End if
If a value is bigger than 130, i change the value temporarely to a smaller value, to get a good position. Then i save the position into local variables and restore the original value. Then i set the new positions through my saved position values.

I can't get a good result! Is there a better way to do this?

TIA!

Raphael Keller
WigaSoft AG
CH-St.Gallen

Posted: Wed Dec 28, 2005 9:29 am
by narcis
Hi Raphael,

Yes, the properly way to do it is as shown in the snippet below which works fine. You need to call TChart.Environment.InternalRepaint before retrieving marks positions and reposition them.

Also, to avoid doing all that temporary values thing I'd suggest you to calculate the positions using CalcXPosValue and CalcYPosValue methods as shown below.

Code: Select all

Private Sub Form_Load()
    TeeCommander1.Chart = tc
    
    For i = 0 To tc.SeriesCount - 1
        With tc.Series(i)
            For j = 0 To 20
                'We populate the series with random values ranging from 50 to 150
                .Add ((150 - 50 + 1) * Rnd + 50), "", clTeeColor
            Next j
            
            For ii = 0 To .Count - 1
                If .YValues.Value(ii) > 130 Then
                    tc.Environment.InternalRepaint
                    yValue = .CalcYPosValue(125)
                    .Marks.Positions.Position(ii).Custom = True
                    .Marks.Positions.Position(ii).LeftTop.Y = yValue
                    .Marks.Arrow.Visible = False
                    '.Marks.Clip = True
                End If
            Next ii
        End With
    Next i
    
    tc.Repaint
End Sub