Chart cursor consumes up to 100 % CPU
Chart cursor consumes up to 100 % CPU
There is a problem with CPU consumption when a chart cursor is enabled.
OnCursorChange event is fired constantly even though mouse cursor does not move.
To reproduce just Enable cursor and move the mouse on the chart area and then leave it there.
I can send a code to reproduce, but I am not sure how to attach it
Thanks
OnCursorChange event is fired constantly even though mouse cursor does not move.
To reproduce just Enable cursor and move the mouse on the chart area and then leave it there.
I can send a code to reproduce, but I am not sure how to attach it
Thanks
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Natalia,
Are you using the latest TeeChart for .NET build release available at our Customer Download Area.
I haven't been able to reproduce this here.
Yes please, send us a project we can run "as-is" to reproduce the problem here at steema.public.attachments available at news://www.steema.net
Are you using the latest TeeChart for .NET build release available at our Customer Download Area.
I haven't been able to reproduce this here.
I can send a code to reproduce, but I am not sure how to attach it
Yes please, send us a project we can run "as-is" to reproduce the problem here at steema.public.attachments available at news://www.steema.net
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 |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Natalia,
I've been able to reproduce the behaviour you report. The problem is the code line above.
Setting FollowMouse to true makes the cursor work because it has to follow mouse movements. That's why the CPU usage increases, just setting this property to false will solve this problem.
I've been able to reproduce the behaviour you report. The problem is the code line above.
Code: Select all
m_cursor.FollowMouse = true;
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 |
Hi Narcis
I have the same problem. But in my application deactivating "FollowMouse" solves the problem with the CPU usage but it makes the CursorTool useless.
I want the current y-value from that x-value, where the mouse currently
is. The only way, i found is using the cursortool and the TChart.MouseMove -Event
If you have an idea for another way, please tell me.
Greetings
Elric
I have the same problem. But in my application deactivating "FollowMouse" solves the problem with the CPU usage but it makes the CursorTool useless.
I want the current y-value from that x-value, where the mouse currently
is. The only way, i found is using the cursortool and the TChart.MouseMove -Event
Code: Select all
mChartLine = New TeeChart.Styles.Line(TChart1.Chart)
Private Sub TChart1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TChart1.MouseMove
Dim i As Int32
Dim x As Double
x = CursorTool1.XValue
' XValues: order by time
For i = 0 To mChartLine.XValues.Count - 1
If x < mChartLine.XValues.Item(i) Then
Label1.Text = FormatTrend(mChartLine.YValues(i - 1))
end if
Next
End Sub
Greetings
Elric
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Elric,
If you don't need the YValue in a label you can use the MarkTips Tool which is specific for this.
Yes, you can do it much easier using the CalcYPosValue method in the mouse event you want like:If you have an idea for another way, please tell me.
Code: Select all
label1.Text=Convert.ToString(tChart1.Series[0].CalcYPosValue(e.X));
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 |
Hi Narcis
Thank you for answering so quickly.
The TChart-Help says about CalcYPosValue-method:
"Returns the pixel Screen Vertical coordinate of the specified Value."
And my test showes me the this, too. What I want is the Y-Value (that I would see on the axes for the current x-value) in the series,not a pixel coordinate. Please look at my code snippet, that gives me the right value, but has the high CPU usage.
Greetings
Elric
Thank you for answering so quickly.
The TChart-Help says about CalcYPosValue-method:
"Returns the pixel Screen Vertical coordinate of the specified Value."
And my test showes me the this, too. What I want is the Y-Value (that I would see on the axes for the current x-value) in the series,not a pixel coordinate. Please look at my code snippet, that gives me the right value, but has the high CPU usage.
Greetings
Elric
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Elric,
Yes, you are right, what you are looking for is:
Yes, you are right, what you are looking for is:
Code: Select all
if (line1.Clicked(e.X,e.Y)!=-1)
label1.Text=Convert.ToString(line1.YValues[line1.Clicked(e.X,e.Y)]);
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 |
Hi Narcis
Its me again
Okay, its getting nearer. I get the right value, but only for 1 series and only, when cursor is near the series. The advantage of the cursortool-code is, that I get the value, no matter where the cursor is AND (for me important) I get the values of all series at the same time. (Look at my code snippet: I have up to 10 "For"-loops, series, Labels).
Sorry for my nerve-racking questions and thank you for helping me furthermore
Greetings
Elric
Its me again
Okay, its getting nearer. I get the right value, but only for 1 series and only, when cursor is near the series. The advantage of the cursortool-code is, that I get the value, no matter where the cursor is AND (for me important) I get the values of all series at the same time. (Look at my code snippet: I have up to 10 "For"-loops, series, Labels).
Sorry for my nerve-racking questions and thank you for helping me furthermore
Greetings
Elric
Okay, I tried something different and it seems to work.
The XValue I calculated myself has the same value as the CursorTool1.XValue. So I can use my original function without the cursortool.
Please look over it, whether I have something forgot or my workaround works only in special cases.
If you have an idea for a more elegant method than my workaround, please tell me.
Thank you again.
Greetings
Elric
Code: Select all
Dim ChartAreaWidth As Int32
Dim ChartAreaXInterval As Double
Dim XIntervalPerPixel As Double
Dim XValue As Double
ChartAreaWidth = (TChart1.Chart.Width - CInt(TChart1.Chart.Panel.MarginLeft + TChart1.Chart.Panel.MarginRight))
ChartAreaXInterval = (TChart1.Axes.Bottom.Maximum - TChart1.Axes.Bottom.Minimum)
XIntervalPerPixel = ChartAreaWidth / ChartAreaXInterval
XValue = (e.X - TChart1.Chart.Panel.MarginLeft) / XIntervalPerPixel + TChart1.Axes.Bottom.Minimum
Please look over it, whether I have something forgot or my workaround works only in special cases.
If you have an idea for a more elegant method than my workaround, please tell me.
Thank you again.
Greetings
Elric
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Elric,
Yes, you can try:
Yes, you can try:
Code: Select all
tChart1.Header.Text="XValue: " + tChart1.Axes.Left.CalcPosPoint(e.Y).ToString()
+ " YValue: " + tChart1.Axes.Bottom.CalcPosPoint(e.X).ToString();
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 |
Hi, Narcis
Yes, you`re great . The value
is exactly the X-Value, what i´m looking for. Now it looks so easy.
Thank you again.
Elric
Yes, you`re great . The value
Code: Select all
tChart1.Axes.Bottom.CalcPosPoint(e.X)
Thank you again.
Elric
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Elric,
You're welcome!
I'm glad to hear finally we found what you needed.
You're welcome!
I'm glad to hear finally we found what you needed.
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 |
Thanks for your reply.
Taking out FollowMouse option definitely helps, but it is not convinient - some our systems have trackball and it is very tricky to drag the cusrsor line.
The real problem is that when you turn cursor on and have FollowMouse true, tChart calls OnCursorChange and MouseMove events even when we DO NOT MOVE THE MOUSE over the chart! Just move the mouse to the chart area and leve it there - you'll still constantly get above events.
This is our main concern.
Thanks,
Natalia.
Taking out FollowMouse option definitely helps, but it is not convinient - some our systems have trackball and it is very tricky to drag the cusrsor line.
The real problem is that when you turn cursor on and have FollowMouse true, tChart calls OnCursorChange and MouseMove events even when we DO NOT MOVE THE MOUSE over the chart! Just move the mouse to the chart area and leve it there - you'll still constantly get above events.
This is our main concern.
Thanks,
Natalia.
Hello Natalie
I have the same problem and I solved it with a workaraound.
Its not elegant, its a temporary solution, but it should work until Steema solves the problem.
Bye
Elric
PS: Sorry, that I had used above your thread for my problem.
I have the same problem and I solved it with a workaraound.
Code: Select all
Dim x_old As Int32
Dim y_old As Int32
Private Sub TChart1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TChart1.MouseMove
If e.X <> x_old Or e.Y <> y_old Then
Me.CursorTool1.FollowMouse = True
Else
Me.CursorTool1.FollowMouse = False
End If
x_old = e.X
y_old = e.Y
End Sub
Bye
Elric
PS: Sorry, that I had used above your thread for my problem.