Marker Values > Maximum [Horiz. Bar Chart]

TeeChart for ActiveX, COM and ASP
Post Reply
Raphael
Newbie
Newbie
Posts: 4
Joined: Tue Dec 27, 2005 12:00 am

Marker Values > Maximum [Horiz. Bar Chart]

Post by Raphael » Tue Dec 27, 2005 3:22 pm

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

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 Dec 28, 2005 9:29 am

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
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