Point Color and Style Problem

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
tom.k
Newbie
Newbie
Posts: 6
Joined: Fri Feb 06, 2004 5:00 am
Location: Australia

Point Color and Style Problem

Post by tom.k » Wed Jul 06, 2005 6:49 am

Hi All,

My objective is to change a point's style and color if it is above or below a certain value. Having heaps of problems finding anything in the examples or Forums. I am using VB.net and TeeChart.net 2.

The following code produces weird outcomes. The first point is a green square and point 11 is blue when point 10 was supposed to be blue by code. HELP!!!!!!!


Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim points1 As New Steema.TeeChart.Styles.Points(TChart3.Chart)
points1.FillSampleValues(30)
AddHandler points1.GetPointerStyle, AddressOf points1_GetPointerStyle
End Sub
Private Sub points1_GetPointerStyle(ByVal series As Steema.TeeChart.Styles.CustomPoint, ByVal e As Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs)
If e.ValueIndex = 10 Then
series.Pointer.Color = System.Drawing.Color.Blue
Else
series.Pointer.Color = System.Drawing.Color.Red
End If
End Sub

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 Jul 06, 2005 9:58 am

Hi t.k.,

It works fine here using:

Code: Select all

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Points1.FillSampleValues()
    End Sub

    Private Sub Points1_GetPointerStyle(ByVal series As Steema.TeeChart.Styles.CustomPoint, ByVal e As Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs) Handles Points1.GetPointerStyle
        If e.ValueIndex = 10 Then
            series.Pointer.Color = System.Drawing.Color.Blue
        Else
            series.Pointer.Color = System.Drawing.Color.Red
        End If
    End Sub
Steps:

1: Add a chart to a VB.NET WinForm.
2: Add a point series to the chart using Chart Editor (Right-click on the chart and select edit).
3: In the code window, select the Points1 object and in the other combobox select the GetPointerStyle event.
4: Paste in the code for the event

BTW: The blue point should be eleventh one because ValueIndex range goes from 0 to Points1.Count - 1.
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

tom.k
Newbie
Newbie
Posts: 6
Joined: Fri Feb 06, 2004 5:00 am
Location: Australia

Still not working

Post by tom.k » Wed Jul 06, 2005 12:51 pm

Hi,

Thanks for the quick response. I tried to follow your example, but I could not find where to select the Point1 object, I could only see the Line 1 object.

Also how does the first sub below fill the sample values and then call the next sub (where is the chart).

I do understand the valuepoint index, it was just interesting in the original code I posted that when I tried to change the point color and point size for point 10, the color changed for point 11 and the size changed for point 10. Why knows?

Also in the chart it draws an extra point before the zero point and different color?

Thnaks t.k


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Points1.FillSampleValues()
End Sub

Private Sub Points1_GetPointerStyle(ByVal series As Steema.TeeChart.Styles.CustomPoint, ByVal e As Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs) Handles Points1.GetPointerStyle
If e.ValueIndex = 10 Then
series.Pointer.Color = System.Drawing.Color.Blue
Else
series.Pointer.Color = System.Drawing.Color.Red
End If
End Sub

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jul 07, 2005 10:58 am

Hi t.k.,
Thanks for the quick response. I tried to follow your example, but I could not find where to select the Point1 object, I could only see the
Line 1 object.
Point1 object is a Point series object. You can add it using Chart Editor (Right-clicking on a TChart and select edit) clicking on add series and selecting point series.
Also how does the first sub below fill the sample values and then call the next sub (where is the chart).
FillSampleValues is a method to populate series with random or already TeeChart preset values. To call the event, after having added the point series with Chart Editor you'll find Point1 at your form code editor, at the top comboboxes.
I do understand the valuepoint index, it was just interesting in the original code I posted that when I tried to change the point color and

point size for point 10, the color changed for point 11 and the size changed for point 10. Why knows?
ValueIndex is an index for every series points which range goes from 0 to the number of points in a series minus 1. To change point 10 color you

should use e.ValueIndex=9 then. In your code, there's nothing about changing point size however there seems to be a bug here (which I have already added to our deffect list to be fixed for future releases) as the code necessary to get it working is:

Code: Select all

    Private Sub Points1_GetPointerStyle(ByVal series As Steema.TeeChart.Styles.CustomPoint, ByVal e As Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs) Handles Points1.GetPointerStyle
        If e.ValueIndex = 8 Then
            With series.Pointer
                .Color = System.Drawing.Color.Blue
                .HorizSize = 2
                .VertSize = 2
            End With
        ElseIf e.ValueIndex = 9 Then
            With series.Pointer
                .Color = System.Drawing.Color.Red
                .HorizSize = 5
                .VertSize = 5
            End With
        Else
            With series.Pointer
                .Color = System.Drawing.Color.Red
                .HorizSize = 2
                .VertSize = 2
            End With
        End If
    End Sub
Also in the chart it draws an extra point before the zero point and different color?


I cannot reproduce this here. Could you please test if the code above works fine for you. If not, please send us an example we can run "as-is" to reproduce the problem here. You can post your examples at [url]news://www.steema.net/steema.public.attachments[/url] 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
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply