Page 1 of 1

Exception with Pie Chart with no data

Posted: Wed Nov 05, 2008 1:17 pm
by 9092401
Hi
I have a pie chart with a MarksTip and with one series however there is no data in the series ( Chart.Series[0].Count == 0 ) . When displaying it
I get the title with nothing displayed in the graph area. That is OK.
HOWEVER When the mouse is on the empty graph area I get an exception . I removed the marks tip from my code but then got a second exception .
See both exceptions below

EXCEPTION With MarksTip

System.NullReferenceException: Object reference not set to an instance of an object.
at Steema.TeeChart.Styles.Pie.CalcClickedPie(Int32 x, Int32 y)
at Steema.TeeChart.Styles.Pie.Clicked(Int32 x, Int32 y)
at Steema.TeeChart.Tools.MarksTip.FindClickedSeries(Int32 x, Int32 y, Int32& index)
at Steema.TeeChart.Tools.MarksTip.MouseEvent(MouseEventKinds kind, MouseEventArgs e, Cursor& c)
at Steema.TeeChart.Chart.BroadcastMouseEvent(MouseEventKinds kind, MouseEventArgs e, Cursor& c)
at Steema.TeeChart.Chart.BroadcastMouseEvent(MouseEventKinds kind, MouseEventArgs e)
at Steema.TeeChart.TChart.OnMouseMove(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseMove(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



EXCEPTION without MarksTip

reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at Steema.TeeChart.Styles.Pie.CalcClickedPie(Int32 x, Int32 y)
at Steema.TeeChart.Styles.Pie.Clicked(Int32 x, Int32 y)
at Steema.TeeChart.Styles.Series.CheckMouse(Cursor& c, Int32 x, Int32 y)
at Steema.TeeChart.Chart.CheckMouseSeries(Cursor& c, Int32 X, Int32 Y)
at Steema.TeeChart.Chart.DoMouseMove(Int32 x, Int32 y, Cursor& c)
at Steema.TeeChart.TChart.OnMouseMove(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseMove(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Please help me avoid getting an exception when mouse hovers over graph area.

Thanks.

Posted: Wed Nov 05, 2008 2:02 pm
by narcis
Hi qcrnd,

I'm not able to reproduce those issues here using v3's 3rd November release and this code:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Pie pie1 = new Steema.TeeChart.Styles.Pie(tChart1.Chart);

			//Steema.TeeChart.Tools.MarksTip marksTip1 = new Steema.TeeChart.Tools.MarksTip(tChart1.Chart);
			//marksTip1.Series = pie1;
		}
Which TeeChart version are you using? Could you please modify code snippet above so that I can reproduce the problem here?

Thanks in advance.

Posted: Wed Nov 05, 2008 3:58 pm
by 9092401
Hi Narcis
Our chart registers to different events If you try in your code to add Event Handlers for example
Chart.Series[0].MouseEnter += OnPieSeriesMouseEnter;
Chart.Series[0].MouseLeave += OnPieSeriesMouseLeave;
You should get the error.
The callbacks arent called , the error happens before they are called.

We are using V2.

Posted: Wed Nov 05, 2008 4:04 pm
by narcis
Hi qcrnd,

Thanks for the info.

I could not reproduce the issue here using code snippet below with latest v2 and v3 releases. Does code below work fine for you? Could you please check if latest version solves the problem at your end¿

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Pie pie1 = new Steema.TeeChart.Styles.Pie(tChart1.Chart);

			//Steema.TeeChart.Tools.MarksTip marksTip1 = new Steema.TeeChart.Tools.MarksTip(tChart1.Chart);
			//marksTip1.Series = pie1;

			pie1.MouseEnter += new EventHandler(pie1_MouseEnter);
			pie1.MouseLeave += new EventHandler(pie1_MouseLeave);
		}

		void pie1_MouseLeave(object sender, EventArgs e)
		{
			this.Text = "entered";
		}

		void pie1_MouseEnter(object sender, EventArgs e)
		{
			this.Text = "left";
		}
Thanks in advance.

Posted: Thu Nov 06, 2008 6:40 am
by 9092401
Hi Narcis

Here is the version which is written in our license file. We currently cannot risk changing the version since we are in the final QA stages.

Steema.TeeChart.TChart, TeeChart, Version=2.0.2306.26232,

In our application I made a test like your code

void OnTestChart()
{
Form f = new Form();
f.Size = new Size(500, 500);
TChart tChart1 = new Steema.TeeChart.TChart();
tChart1.Dock = DockStyle.Fill;
Steema.TeeChart.Styles.Pie pie1 = new Steema.TeeChart.Styles.Pie(tChart1.Chart);
pie1.MouseEnter += new EventHandler(pie1_MouseEnter);
pie1.MouseLeave += new EventHandler(pie1_MouseLeave);
tChart1.Parent = f;
f.ShowDialog();
}

And I got an exception as soon as the mouse entered the form.

Can you see if you fixed anything between our version and the later ones.?

Another issue with empty Pie chart.

Posted: Thu Nov 06, 2008 8:41 am
by 9092401
I also found that in this case on a pie series with no data if I register to Chart.ClickSeries and click on the chart I get an exception as well

Posted: Thu Nov 06, 2008 8:51 am
by narcis
Hi qcrnd,

You can find v2 release notes here. However, I can't see any issue like yours being mentioned. If you send us a simple project we can run "as-is" to reproduce the problem here we can test it works fine using latest v2 release.

You can post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

As a workaround you can try unassign events if series has no values:

Code: Select all

			if (pie1.Count == 0)
			{
				pie1.MouseEnter -= new EventHandler(pie1_MouseEnter);
				pie1.MouseLeave -= new EventHandler(pie1_MouseLeave);
			}
			else
			{
				pie1.MouseEnter += new EventHandler(pie1_MouseEnter);
				pie1.MouseLeave += new EventHandler(pie1_MouseLeave);
			}


Thanks in advance.

Hi

Posted: Thu Nov 06, 2008 10:21 am
by 9092401
Yes I have already dont this workaround although I am not so happy with it.
Its funny that it doesnt happen with your v2 .
Are we using the same v2

In anycase I will try later on or maybe next week to create a project and upload becuase the project I am working in is huge.

Thanks.

Posted: Thu Nov 06, 2008 10:30 am
by narcis
Hi qcrnd,

No, I'm using latest v2 build available which is 2.0.3203.23271/2 published on 8th October 2008. The version you are using is from May 2006. Since May 2007, current TeeChart for .NET version is number 3 and not much development is being done in v2 at the present moment, just sporadic bug fixes. Anyway many bug fixes have been done in v2 during this period (almost 2 years and a half).

Posted: Tue Nov 11, 2008 12:45 pm
by 9092401
Hi
As requested I have uploaded a project which reproduces the problem onto your upload site (PieUnhandledException.zip).
our version is 2.0.2306.26232

Posted: Tue Nov 11, 2008 1:46 pm
by narcis
Hi qcrnd,

Thanks for the example project but I'm not able to reproduce the issue here. Could you please try uninstalling your current v2 version, download and install the last build available at the client area and check if this solves the problem for you?

Thanks in advance.

Posted: Tue Nov 11, 2008 3:00 pm
by 9092401
Hi Narcis
I tried accessing the download site and couldnt find any new version 2. I only found a few things dated 2004. TChart Ax pro 6 or something.
can you please give instructions
Thanks.

Posted: Tue Nov 11, 2008 4:56 pm
by narcis
Hi qcrnd,

In that case please contact our Sales Dept at sales at steema dot com with your customer and license details. They'll provide product keys you may not find.

Thanks in advance.

Posted: Thu Nov 13, 2008 1:32 pm
by 9092401
Hi Narcis
I just checked version 3 , this issue doesnt happen so I guess you fixed it somewhere along the line
Thanks for the help.