Clicked method of Series always returns -1

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Michael
Newbie
Newbie
Posts: 14
Joined: Tue Dec 13, 2016 12:00 am

Clicked method of Series always returns -1

Post by Michael » Thu Nov 23, 2017 8:46 pm

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.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Clicked method of Series always returns -1

Post by Christopher » Fri Nov 24, 2017 9:13 am

Hello,

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();
		}
I made a gif showing it working on my machine [link here]:

Image
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

Michael
Newbie
Newbie
Posts: 14
Joined: Tue Dec 13, 2016 12:00 am

Re: Clicked method of Series always returns -1

Post by Michael » Fri Nov 24, 2017 6:02 pm

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

Michael
Newbie
Newbie
Posts: 14
Joined: Tue Dec 13, 2016 12:00 am

Re: Clicked method of Series always returns -1

Post by Michael » Fri Nov 24, 2017 7:07 pm

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
Attachments
ChartExamples.jpg
ChartExamples.jpg (54.24 KiB) Viewed 25966 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Clicked method of Series always returns -1

Post by Christopher » Mon Nov 27, 2017 3:04 pm

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.
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

Michael
Newbie
Newbie
Posts: 14
Joined: Tue Dec 13, 2016 12:00 am

Re: Clicked method of Series always returns -1

Post by Michael » Mon Nov 27, 2017 3:52 pm

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.
Attachments
ChartExample.jpg
ChartExample.jpg (199.62 KiB) Viewed 25923 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Clicked method of Series always returns -1

Post by Christopher » Mon Nov 27, 2017 4:14 pm

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:
devenv_2017-11-27_17-12-08.png
devenv_2017-11-27_17-12-08.png (4.86 KiB) Viewed 25927 times
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

Michael
Newbie
Newbie
Posts: 14
Joined: Tue Dec 13, 2016 12:00 am

Re: Clicked method of Series always returns -1

Post by Michael » Mon Nov 27, 2017 5:16 pm

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

Michael
Newbie
Newbie
Posts: 14
Joined: Tue Dec 13, 2016 12:00 am

Re: Clicked method of Series always returns -1

Post by Michael » Mon Nov 27, 2017 5:20 pm

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

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Clicked method of Series always returns -1

Post by Christopher » Mon Nov 27, 2017 5:48 pm

Hello Michael,

The fix is in the InternalClicked() method of the Bar class in Bar.cs:
devenv_2017-11-27_18-46-44.png
devenv_2017-11-27_18-46-44.png (33.41 KiB) Viewed 25915 times
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

Michael
Newbie
Newbie
Posts: 14
Joined: Tue Dec 13, 2016 12:00 am

Re: Clicked method of Series always returns -1

Post by Michael » Mon Nov 27, 2017 6:51 pm

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

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Clicked method of Series always returns -1

Post by Christopher » Mon Nov 27, 2017 7:28 pm

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?
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

Michael
Newbie
Newbie
Posts: 14
Joined: Tue Dec 13, 2016 12:00 am

Re: Clicked method of Series always returns -1

Post by Michael » Mon Nov 27, 2017 9:25 pm

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

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Clicked method of Series always returns -1

Post by Christopher » Tue Nov 28, 2017 9:36 am

Hello Michael,

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();
    }
Here, with the latest dll and with one from 2013, I obtain the following:
TChart636474555232061884.png
TChart636474555232061884.png (21.8 KiB) Viewed 25895 times
TChart636474554976674654.png
TChart636474554976674654.png (22.17 KiB) Viewed 25897 times
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

Michael
Newbie
Newbie
Posts: 14
Joined: Tue Dec 13, 2016 12:00 am

Re: Clicked method of Series always returns -1

Post by Michael » Tue Nov 28, 2017 4:08 pm

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

Post Reply