I realise this is probably easy but I am pressed for time here so any help appreciated.
If I have a chart that has 200 points along the x-axis
It has a series that starts at point 20
Therefore I have an x-axis from 1 to 200 and a series yvalues array from 1 to 80.
Now if I move the mouse (can't use cursor for this!) I need to translate the actual x position to the relative series value at that x-axis point.
Surely there is an easy way to do this?
Thanks
Ross
Mouse X to Series Value
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Ross,
Yes, you can implement something like the following code in the MouseMove event.
Yes, you can implement something like the following code in the MouseMove event.
Code: Select all
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
With TChart1.Header.Text
.Clear
.Add CStr(TChart1.Axis.Bottom.CalcPosPoint(X))
End With
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 |
Instructions - How to post in this forum |
Doesn't help
Actually that part I can already do, ie. convert the mouse position to the relative x-axis index.
My series starts at point 20 on the x-axis. Therefore if I convert the mouse position to the x-axis index - let's say 40 - I can't use that to get the correct series value ie; .series(0).yvalues.value(xaxis) as there is an offset of 20.
Please let me know if this is not making sense.
Thanks
Ross
My series starts at point 20 on the x-axis. Therefore if I convert the mouse position to the x-axis index - let's say 40 - I can't use that to get the correct series value ie; .series(0).yvalues.value(xaxis) as there is an offset of 20.
Please let me know if this is not making sense.
Thanks
Ross
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Ross,
I don't understand which is your problem. Could you please send us an example we can run "as-is" to reproduce the problem here or a screen-shot so that we can see the problem?
You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.
Thanks in advance.
I don't understand which is your problem. Could you please send us an example we can run "as-is" to reproduce the problem here or a screen-shot so that we can see the problem?
You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.
Thanks in advance.
Best Regards,
Narcís Calvet / 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 |
x-axis to series value
Hi Narcis
Was having a problem posting but a very simple example will illustrate my point.
Add a Tchart, a Command button and two text boxes to a form then paste the following code:
Private Sub Command1_Click()
With TChart1
.RemoveAllSeries
.AddSeries scLine
.Series(0).FillSampleValues 100
.AddSeries scLine
.Series(1).SetFunction tfMovavg
.Series(1).FunctionType.Period = 20
.Series(1).DataSource = .Series(0)
End With
End Sub
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim xActual As Integer
With TChart1
.Header.Text.Clear
xActual = .Axis.Bottom.CalcPosPoint(X)
.Header.Text.Add CStr(xActual)
If .SeriesCount > 1 Then
Text1.Text = .Series(0).YValues.Value(Val(xActual))
Text2.Text = .Series(1).YValues.Value(Val(xActual))
End If
End With
End Sub
Note that Text2.text values are out for the function it doesn't start at the left most point. How do I get it's correct value at the mouse cursor location?
Thanks
Ross
Was having a problem posting but a very simple example will illustrate my point.
Add a Tchart, a Command button and two text boxes to a form then paste the following code:
Private Sub Command1_Click()
With TChart1
.RemoveAllSeries
.AddSeries scLine
.Series(0).FillSampleValues 100
.AddSeries scLine
.Series(1).SetFunction tfMovavg
.Series(1).FunctionType.Period = 20
.Series(1).DataSource = .Series(0)
End With
End Sub
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim xActual As Integer
With TChart1
.Header.Text.Clear
xActual = .Axis.Bottom.CalcPosPoint(X)
.Header.Text.Add CStr(xActual)
If .SeriesCount > 1 Then
Text1.Text = .Series(0).YValues.Value(Val(xActual))
Text2.Text = .Series(1).YValues.Value(Val(xActual))
End If
End With
End Sub
Note that Text2.text values are out for the function it doesn't start at the left most point. How do I get it's correct value at the mouse cursor location?
Thanks
Ross
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Ross,
You could implement the MouseMove event like this:
You could implement the MouseMove event like this:
Code: Select all
Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim xActual As Integer
With TChart1
.Header.Text.Clear
xActual = .Axis.Bottom.CalcPosPoint(X)
.Header.Text.Add CStr(xActual)
If .SeriesCount > 1 Then
Text1.Text = .Series(0).YValues.Value(Val(xActual))
If xActual >= .Series(1).FunctionType.Period Then
Text2.Text = .Series(1).YValues.Value(Val(xActual - .Series(1).FunctionType.Period))
Else
Text2.Text = ""
End If
End If
End With
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 |
Instructions - How to post in this forum |