Hi
On my chart I have a line series representing share prices over time. I add a second series of points representing events (such as financial results released for example).
The points plot on the price line.
As the whole chart is dynamically created/modified by user I have procedures to add series as necessary. In those procedures I add handlers for the MouseEnter and MouseLeave events. The events fire correctly and call my own event handling procedures, however;
When the mouse pointer enters a point drawn on top of the line, the MouseEnter event returns the underlying line series, not the point series as expected.
Is there some way to resolve this?
I am working in VB.NET (2005) with version 3.5.3630.19311 of the control.
MouseEnter event
Re: MouseEnter event
Hello rossmc,
Could you please send us a simple project, because we can reproduce your problem exactly here and try to find a solution for you?
Thanks,
Could you please send us a simple project, because we can reproduce your problem exactly here and try to find a solution for you?
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: MouseEnter event
Here we go, very basic.
1) Run app and click on Add Line button. Mouse over line and form caption changes to 'LineTag'.
2) Click on Add Point (Offset). A point is added. Mousing over point changes caption to 'PointTagGreen'.
3) Click on Add Point. A point is added over the line. Mousing over this point invokes the handler for the line beneath it?
1) Run app and click on Add Line button. Mouse over line and form caption changes to 'LineTag'.
2) Click on Add Point (Offset). A point is added. Mousing over point changes caption to 'PointTagGreen'.
3) Click on Add Point. A point is added over the line. Mousing over this point invokes the handler for the line beneath it?
- Attachments
-
- WindowsApplication8.zip
- (10.22 KiB) Downloaded 509 times
Re: MouseEnter event
Hello rossmc,
On the other hand, could you please, explain us exactly what are you doing, because we can try to help you to find a good solution for it?
Thanks,
Thank you for your example. I could reproduce it here, but when I was tested your example I realized that MouseEnter works for all the series and tags show. So I think what happens is that when there are many series in same point, MouseEnter happens for each series, but only is showed the tag of the last series where the MouseEnter Event has entered, because are overwritten. I have modified your code, because you can see it:3) Click on Add Point. A point is added over the line. Mousing over this point invokes the handler for the line beneath it?
Code: Select all
Imports Steema.TeeChart
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TChart1.Series.RemoveAllSeries()
Dim l As New Styles.Line(TChart1.Chart)
With l
'Title and Key (we store the key in the line tag so we can - in code - relate the chart line with the object that represents it in the mytdo.
.Title = "A Line"
.Tag = "LineTag"
'Pen colour, width and style
.Color = Color.Blue
.LinePen.Width = 1
.LinePen.Style = Drawing2D.DashStyle.Solid
'Axes properties
.HorizAxis = Styles.HorizontalAxis.Bottom
.VertAxis = Styles.VerticalAxis.Left
'Visible cursor on mouse over
.Cursor = Cursors.Hand
'Line events
AddHandler .MouseEnter, AddressOf series_MouseEnter
'Data
For point As Integer = 0 To 10
.Add(point, 2)
Next
End With
TChart1.Axes.Bottom.SetMinMax(0, 10)
End Sub
Private Sub series1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)
ListBox1.Items.Add(DirectCast(sender, Steema.TeeChart.Styles.Series).Tag.ToString)
End Sub
Private Sub series2_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)
ListBox1.Items.Add(DirectCast(sender, Steema.TeeChart.Styles.Series).Tag.ToString)
End Sub
Private Sub series_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)
ListBox1.Items.Add(DirectCast(sender, Steema.TeeChart.Styles.Series).Tag.ToString)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim s As New Styles.Points(TChart1.Chart)
With s
'UI
.Title = "A Green Point"
.Tag = "PointTagGreen"
'Point format
.Pointer.Style = Styles.PointerStyles.Circle
.Pointer.Color = Color.Green
.Pointer.VertSize = 5
.Pointer.HorizSize = 5
'Axes
.HorizAxis = Styles.HorizontalAxis.Bottom
.VertAxis = Styles.VerticalAxis.Left
'Cursor type when over series
.Cursor = Cursors.Hand
.Add(3, 2)
AddHandler .MouseEnter, AddressOf series1_MouseEnter
'AddHandler .MouseLeave, AddressOf s1_MouseLeave
End With
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim s As New Styles.Points(TChart1.Chart)
With s
'UI
.Title = "A red Point"
.Tag = "PointTagRed"
'Point format
.Pointer.Style = Styles.PointerStyles.Circle
.Pointer.Color = Color.Red
.Pointer.VertSize = 5
.Pointer.HorizSize = 5
'Axes
.HorizAxis = Styles.HorizontalAxis.Bottom
.VertAxis = Styles.VerticalAxis.Left
'Cursor type when over series
.Cursor = Cursors.Hand
.Add(4, 2)
AddHandler .MouseEnter, AddressOf series2_MouseEnter
End With
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TChart1.Aspect.View3D = False
End Sub
End Class
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: MouseEnter event
Thanks for reply. Even knowing that I don't think I can solve the problem.
I have a chart with many series representing very different data sets. For example a price line, and a point series representing news events. There could also be series representing various functions and overlays etc etc. For all of these different 'types' I need custom tooltips. Not just different text, but complex interactive tooltips with mixed text/images, sometimes listboxes, and more.
I can create my own tooltip windows and handle the required code, however, I need to know when the mouse enters a particular series, and which series it is, as accurately as possible. Hence the MouseEnter code I was trying, which works unless there are multiple series on the same point.
Since it is easy enough to track where (X,Y) co-ordinates the mouse pointer is at anytime, is there a way to determine what - if anything - is under the mouse pointer at a particular set of co-ordinates?
Another way to perhaps get this done is to use the markstip tool, but suppress it at the .GetText event so I can rather show my own tooltip window.
Many thanks
I have a chart with many series representing very different data sets. For example a price line, and a point series representing news events. There could also be series representing various functions and overlays etc etc. For all of these different 'types' I need custom tooltips. Not just different text, but complex interactive tooltips with mixed text/images, sometimes listboxes, and more.
I can create my own tooltip windows and handle the required code, however, I need to know when the mouse enters a particular series, and which series it is, as accurately as possible. Hence the MouseEnter code I was trying, which works unless there are multiple series on the same point.
Since it is easy enough to track where (X,Y) co-ordinates the mouse pointer is at anytime, is there a way to determine what - if anything - is under the mouse pointer at a particular set of co-ordinates?
Another way to perhaps get this done is to use the markstip tool, but suppress it at the .GetText event so I can rather show my own tooltip window.
Many thanks
Re: MouseEnter event
Hello rossmc,
I suggested you two options that I think can help you solve your problem:
First: I think you can use Series Click event, for select series, but if there are two or more series in the same point you only can select the last series are you added.
Second: I think this is the best solution for you. In this case you work using MouseMoveEvent and method Clicked of series as do in next code:
In this example you need decided which criteria are you would use for selected the series, you want to be the last to be selected, because should decide whether the loop is ascendant or descendant.
I hope will helps.
Thanks,
I suggested you two options that I think can help you solve your problem:
First: I think you can use Series Click event, for select series, but if there are two or more series in the same point you only can select the last series are you added.
Code: Select all
Imports Steema.TeeChart
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TChart1.Series.RemoveAllSeries()
Dim l As New Styles.Line(TChart1.Chart)
With l
'Title and Key (we store the key in the line tag so we can - in code - relate the chart line with the object that represents it in the mytdo.
.Title = "A Line"
.Tag = "LineTag"
'Pen colour, width and style
.Color = Color.Blue
.LinePen.Width = 1
.LinePen.Style = Drawing2D.DashStyle.Solid
'Axes properties
.HorizAxis = Styles.HorizontalAxis.Bottom
.VertAxis = Styles.VerticalAxis.Left
'Visible cursor on mouse over
.Cursor = Cursors.Hand
'Line events
AddHandler .Click, AddressOf series_Click
'Data
For point As Integer = 0 To 10
.Add(point, 2)
Next
End With
'TChart1.Axes.Left.SetMinMax(2, 16)
TChart1.Axes.Bottom.SetMinMax(0, 10)
End Sub
Private Sub series1_Click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
ListBox1.Items.Add(DirectCast(sender, Steema.TeeChart.Styles.Series).Tag.ToString)
End Sub
Private Sub series2_Click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
ListBox1.Items.Add(DirectCast(sender, Steema.TeeChart.Styles.Series).Tag.ToString)
End Sub
Private Sub series_Click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
ListBox1.Items.Add(DirectCast(sender, Steema.TeeChart.Styles.Series).Tag.ToString)
End Sub
Private Sub series_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs)
'not important
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim s As New Styles.Points(TChart1.Chart)
With s
'UI
.Title = "A Green Point"
.Tag = "PointTagGreen"
'Point format
.Pointer.Style = Styles.PointerStyles.Circle
.Pointer.Color = Color.Green
.Pointer.VertSize = 5
.Pointer.HorizSize = 5
'Axes
.HorizAxis = Styles.HorizontalAxis.Bottom
.VertAxis = Styles.VerticalAxis.Left
'Cursor type when over series
.Cursor = Cursors.Hand
.Add(4, 2)
AddHandler .Click, AddressOf series1_Click
End With
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim s As New Styles.Points(TChart1.Chart)
With s
'UI
.Title = "A red Point"
.Tag = "PointTagRed"
'Point format
.Pointer.Style = Styles.PointerStyles.Circle
.Pointer.Color = Color.Red
.Pointer.VertSize = 5
.Pointer.HorizSize = 5
'Axes
.HorizAxis = Styles.HorizontalAxis.Bottom
.VertAxis = Styles.VerticalAxis.Left
'Cursor type when over series
.Cursor = Cursors.Hand
.Add(4, 2)
AddHandler .Click, AddressOf series2_Click
End With
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TChart1.Aspect.View3D = False
End Sub
Code: Select all
Imports Steema.TeeChart
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TChart1.Series.RemoveAllSeries()
Dim l As New Styles.Line(TChart1.Chart)
With l
'Title and Key (we store the key in the line tag so we can - in code - relate the chart line with the object that represents it in the mytdo.
.Title = "A Line"
.Tag = "LineTag"
'Pen colour, width and style
.Color = Color.Blue
.LinePen.Width = 1
.LinePen.Style = Drawing2D.DashStyle.Solid
'Axes properties
.HorizAxis = Styles.HorizontalAxis.Bottom
.VertAxis = Styles.VerticalAxis.Left
'Visible cursor on mouse over
.Cursor = Cursors.Hand
'Line events
'Data
For point As Integer = 0 To 10
.Add(point, 2)
Next
End With
'TChart1.Axes.Left.SetMinMax(2, 16)
TChart1.Axes.Bottom.SetMinMax(0, 10)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim s As New Styles.Points(TChart1.Chart)
With s
'UI
.Title = "A Green Point"
.Tag = "PointTagGreen"
'Point format
.Pointer.Style = Styles.PointerStyles.Circle
.Pointer.Color = Color.Green
.Pointer.VertSize = 5
.Pointer.HorizSize = 5
'Axes
.HorizAxis = Styles.HorizontalAxis.Bottom
.VertAxis = Styles.VerticalAxis.Left
'Cursor type when over series
.Cursor = Cursors.Hand
.Add(4, 2)
End With
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim s As New Styles.Points(TChart1.Chart)
With s
'UI
.Title = "A red Point"
.Tag = "PointTagRed"
'Point format
.Pointer.Style = Styles.PointerStyles.Circle
.Pointer.Color = Color.Red
.Pointer.VertSize = 5
.Pointer.HorizSize = 5
'Axes
.HorizAxis = Styles.HorizontalAxis.Bottom
.VertAxis = Styles.VerticalAxis.Left
'Cursor type when over series
.Cursor = Cursors.Hand
.Add(4, 2)
End With
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TChart1.Aspect.View3D = False
AddHandler TChart1.MouseMove, AddressOf TChart1_MouseMove
End Sub
Private Sub TChart1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim i As Integer
For i = 0 To TChart1.Series.Count - 1
If (Not TChart1(i).Clicked(e.X, e.Y) = -1) Then
ListBox1.Items.Add(DirectCast(TChart1(i), Steema.TeeChart.Styles.Series).Tag.ToString)
End If
Next
End Sub
End Class
I hope will helps.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: MouseEnter event
Thanks for the help Sandra. I am going to try option two as ideally I would like to know exactly how many, and what type, of series are under a particular point (if multiple).
I already started a little bit of a hack for this by still using just the mouseenter event, but loading the series keys into an array and then processing the array from 0 to array.length. On mouseleave event I then clear the array.
I'll post my solution in the event anyone else is interested.
I already started a little bit of a hack for this by still using just the mouseenter event, but loading the series keys into an array and then processing the array from 0 to array.length. On mouseleave event I then clear the array.
I'll post my solution in the event anyone else is interested.