Clicked method of Series always returns -1
Clicked method of Series always returns -1
Hi,
I just upgraded TeeChart for .NET from version 4.1.2012.9283 to 4.1.2017.10191. Replaced the old dll with the new one and made 2 small changes so it builds.
The problem I'm having is that when I move the mouse over a bar chart the pointInd value returned by the following line of code, int pointInd = m_chart[0].Clicked(x, y),
is always -1, so I cannot get a value from return m_chart[0].YValues[pointInd]. The previous version of the TeeChart was returning valid values when the mouse was
over the chart. I am using the returned value to display a tool tip. I tried a workaround by doing m_chart[0].YValues[x], skipping the call to Clicked(x, y), but it's not very good,
returning some values even when the mouse is not over the chart.
Thank you.
I just upgraded TeeChart for .NET from version 4.1.2012.9283 to 4.1.2017.10191. Replaced the old dll with the new one and made 2 small changes so it builds.
The problem I'm having is that when I move the mouse over a bar chart the pointInd value returned by the following line of code, int pointInd = m_chart[0].Clicked(x, y),
is always -1, so I cannot get a value from return m_chart[0].YValues[pointInd]. The previous version of the TeeChart was returning valid values when the mouse was
over the chart. I am using the returned value to display a tool tip. I tried a workaround by doing m_chart[0].YValues[x], skipping the call to Clicked(x, y), but it's not very good,
returning some values even when the mouse is not over the chart.
Thank you.
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Clicked method of Series always returns -1
Hello,
The following code seems to work okay in that version here:
I made a gif showing it working on my machine [link here]:
The following code seems to work okay in that version here:
Code: Select all
Bar series;
private void InitializeChart()
{
series = new Bar(tChart1.Chart);
series.FillSampleValues();
tChart1.MouseMove += TChart1_MouseMove;
}
private void TChart1_MouseMove(object sender, MouseEventArgs e)
{
int index = series.Clicked(e.X, e.Y);
tChart1.Header.Text = index > -1 ? "Bar CLICKED index: " + index : "Bar NOT clicked";
}
private void button2_Click(object sender, EventArgs e)
{
tChart1.ShowEditor();
}
Best Regards,
Christopher Ireland / 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: Clicked method of Series always returns -1
Hi Christopher,
Thank you for your answer. I did investigate more and discovered that actually sometimes the new dll works. So basically what's happening is that for some data it works like before and sometimes the Clicked() method returns -1, so it doesn't work. The older control works always. Any idea why something like that might happen?
Thank you,
Michael
Thank you for your answer. I did investigate more and discovered that actually sometimes the new dll works. So basically what's happening is that for some data it works like before and sometimes the Clicked() method returns -1, so it doesn't work. The older control works always. Any idea why something like that might happen?
Thank you,
Michael
Re: Clicked method of Series always returns -1
Hi Christopher,
I think I found what's happening (not a solution): the chart is being displayed in a form that always has the same size. When there's too much data, Clicked() in the new control always returns -1, whereas in the old one works fine. When I see it doesn't work with the new control, if I make the window wider and try again, it will work when it reaching a certain width (I guess the width depends on how much data is being displayed. I attached a word document with 2 images of the same chart, first one as it's being displayed by default and when it doesn't work, second one made wider where it works.
Any idea what I can do so it works regardless of the size of the window?
Thank you,
Michael
I think I found what's happening (not a solution): the chart is being displayed in a form that always has the same size. When there's too much data, Clicked() in the new control always returns -1, whereas in the old one works fine. When I see it doesn't work with the new control, if I make the window wider and try again, it will work when it reaching a certain width (I guess the width depends on how much data is being displayed. I attached a word document with 2 images of the same chart, first one as it's being displayed by default and when it doesn't work, second one made wider where it works.
Any idea what I can do so it works regardless of the size of the window?
Thank you,
Michael
- Attachments
-
- ChartExamples.jpg (54.24 KiB) Viewed 25821 times
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Clicked method of Series always returns -1
Hello Michael,
I have been able to reproduce your issue here. Unfortunately it is a regression that must have been added to the code about three years ago and happens when the bars are shrunk down to a width of 1 pixel. I have added the issue to our tracker with id=1950 and have already fixed it - if you have the source code I can pass the fix to you, otherwise the fix will become available in a future maintenance release.
I have been able to reproduce your issue here. Unfortunately it is a regression that must have been added to the code about three years ago and happens when the bars are shrunk down to a width of 1 pixel. I have added the issue to our tracker with id=1950 and have already fixed it - if you have the source code I can pass the fix to you, otherwise the fix will become available in a future maintenance release.
Best Regards,
Christopher Ireland / 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: Clicked method of Series always returns -1
Hi Christopher,
I investigated more and I think the reason I have to widen the form in order to make it work is because with the new dll it doesn't put the whole chart in the window whereas with the old one it does (the code doing this is the same). Is there a property or something else that has changed and I need to set in order to have it behave like before and have it work without needing to widen the form window?
Thank you,
Michael
P.S. Attached is an image with the 2 charts using the 2 versions of the dll.
I investigated more and I think the reason I have to widen the form in order to make it work is because with the new dll it doesn't put the whole chart in the window whereas with the old one it does (the code doing this is the same). Is there a property or something else that has changed and I need to set in order to have it behave like before and have it work without needing to widen the form window?
Thank you,
Michael
P.S. Attached is an image with the 2 charts using the 2 versions of the dll.
- Attachments
-
- ChartExample.jpg (199.62 KiB) Viewed 25778 times
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Clicked method of Series always returns -1
Hello Michael,
you can change the default theme back to the one that was default in the earlier version with code such as the following:
you can change the default theme back to the one that was default in the earlier version with code such as the following:
Best Regards,
Christopher Ireland / 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: Clicked method of Series always returns -1
Hi Christopher,
I did the changes you suggested but it didn't help. I guess I will have to wait for a new release you mentioned that will have the fix.
Thank you,
Michael
I did the changes you suggested but it didn't help. I guess I will have to wait for a new release you mentioned that will have the fix.
Thank you,
Michael
Re: Clicked method of Series always returns -1
One more question. When you said if I have the source code what did you mean, to give it to you or that you are going to show me how to fix it?
I have the source code, so if you can pass me the fix that would be great.
Thank you,
Michael
I have the source code, so if you can pass me the fix that would be great.
Thank you,
Michael
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Clicked method of Series always returns -1
Hello Michael,
The fix is in the InternalClicked() method of the Bar class in Bar.cs:
if you use the HorizBar series a similar fix can be made there too.
The fix is in the InternalClicked() method of the Bar class in Bar.cs:
if you use the HorizBar series a similar fix can be made there too.
Best Regards,
Christopher Ireland / 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: Clicked method of Series always returns -1
Hi Christopher,
I made the changes to bar.cs and rebuilt the TeeChart45 project and now when I move the mouse on top of it it works fine, the tool tip I was displaying shows without needing to widen the form window. The only thing different is that it's still not showing all of it, the display is the same like before. The chart with the old dll shows the time until 1x (1am), the new one until 11:20pm.
Thank you,
Michael
I made the changes to bar.cs and rebuilt the TeeChart45 project and now when I move the mouse on top of it it works fine, the tool tip I was displaying shows without needing to widen the form window. The only thing different is that it's still not showing all of it, the display is the same like before. The chart with the old dll shows the time until 1x (1am), the new one until 11:20pm.
Thank you,
Michael
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Clicked method of Series always returns -1
Hello Michael,
Okay, good - I'll need you create a Minimal, Complete, and Verifiable example (here) with which I can reproduce with precision your issue here. Would you please be do kind as to make one for me and post it here?
Okay, good - I'll need you create a Minimal, Complete, and Verifiable example (here) with which I can reproduce with precision your issue here. Would you please be do kind as to make one for me and post it here?
Best Regards,
Christopher Ireland / 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: Clicked method of Series always returns -1
Hi Christopher,
I will try to do it; will see how important is in our application.'
I have a question: why with the old dll it's showing more horizontal lines (2, 4, 6, etc) whereas the new one shows less (5, 10, 15, 20)?
Thank you,
Michael
I will try to do it; will see how important is in our application.'
I have a question: why with the old dll it's showing more horizontal lines (2, 4, 6, etc) whereas the new one shows less (5, 10, 15, 20)?
Thank you,
Michael
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Clicked method of Series always returns -1
Hello Michael,
Try this code with your two dlls:
Here, with the latest dll and with one from 2013, I obtain the following:
in this scenario I cannot detect any difference in the increment between the labels on the left axis.
Try this code with your two dlls:
Code: Select all
TChart tChart1;
Bar series;
private void CreateChart(bool usetheme = true)
{
tChart1 = new TChart(usetheme);
tChart1.Dock = DockStyle.Fill;
splitContainer1.Panel2.Controls.Add(tChart1);
}
private void InitializeChart()
{
Func<string> Version = () =>
{
string version = typeof(Chart).Assembly.GetName().Version.ToString();
if (version.Length == 13)
version = version.Insert(9, "0");
return version;
};
CreateChart(false);
tChart1.Aspect.View3D = false;
series = new Bar(tChart1.Chart);
Random rnd = new Random();
for (int i = 0; i < 10; i++)
{
series.Add(rnd.Next(500, 600));
}
tChart1.Header.Text = Version();
}
in this scenario I cannot detect any difference in the increment between the labels on the left axis.
Best Regards,
Christopher Ireland / 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: Clicked method of Series always returns -1
Hi Christopher,
My old dll is from 2012, not 2013. Is there a way to control the labels of the left axis?
Thank you,
Michael
My old dll is from 2012, not 2013. Is there a way to control the labels of the left axis?
Thank you,
Michael