ColorGrid and negative values

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
roamer
Newbie
Newbie
Posts: 7
Joined: Fri Nov 15, 2002 12:00 am
Location: Brisbane, Australia
Contact:

ColorGrid and negative values

Post by roamer » Mon Jun 06, 2005 5:58 am

Hi,

I'm having trouble with the ColorGrid series when there are negative values in the data (specifically when there are negative X values, unsure about negative Z values). The ColorGrid works just as I would expect it to behave at all other times. If there's a negative value in the data, an exception is thrown (listed below). The following shows the way in which I initialize the ColorGrid (note that I'm setting IrregularGrid to true because otherwise the ColorGrid doesn't seem to work at all). An important thing to note is that this exception can be reproduced simply by using the feature demo that ships with TeeChart, selecting the ColorGrid demo and setting the Data Source to a text file with some sample data in it. If the first column contains negative numbers, then the exception occurs.

ColorGrid chartSeries = new ColorGrid(theChart.Chart);
chartSeries.StartColor = System.Drawing.Color.Red;
chartSeries.EndColor = System.Drawing.Color.White;
chartSeries.IrregularGrid = true;
chartSeries.DataSource = series.Data;
chartSeries.XValues.DataMember = "XValue";
chartSeries.YValues.DataMember = "YValue";
chartSeries.ZValues.DataMember = "ZValue";
chartSeries.Marks.Visible = true;

The DataSource is a DataTable with columns XValue, YValue and ZValue.

And this is the exception I receive if there are one or more negative values in the X values.

System.IndexOutOfRangeException: Index was outside the bounds of the array. at Steema.TeeChart.Styles.ValueList.get_Item(Int32 index) at Steema.TeeChart.Styles.ColorGrid.GetZStep() at Steema.TeeChart.Styles.ColorGrid.MaxZValue() at Steema.TeeChart.Styles.ColorGrid.MaxYValue() at Steema.TeeChart.Chart.InternalMinMax(Axis aAxis, Boolean isMin, Boolean isX) at Steema.TeeChart.Axis.CalcMinMax(Double& min, Double& max) at Steema.TeeChart.Axis.AdjustMaxMin() at Steema.TeeChart.Axes.AdjustMaxMin() at Steema.TeeChart.Chart.CalcAxisRect() at Steema.TeeChart.Chart.InternalDraw(Graphics g) at Steema.TeeChart.TChart.Draw(Graphics g) at Steema.TeeChart.TChart.OnPaint(PaintEventArgs pe) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at globalroam.deSideV2.Startup.Main(String[] args) in C:\Documents and Settings\ricky\My Documents\projects\globalroam\deSideV2\Startup.cs:line 106

Are there any workarounds for this problem?

Regards,
Ricky

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Jun 06, 2005 12:22 pm

Hi Ricky,

It works fine here using latest TeeChart version available at our Customer Download Area (Build 1.1.1879.21176) and populating series with negative X values as shown here:

Code: Select all

		private void Form1_Load(object sender, System.EventArgs e)
		{
			Random randObj=new Random(100);

			for (int i=-5; i<5; i++)
				for (int j=0; j<10; j++)
					this.colorGrid1.Add(i,randObj.Next(),j);
		}
Which TeeChart version are you using? If you are still experiencing problems could you please send us an example application we can run "as-is" to reproduce the problem here? You can post your examples at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

roamer
Newbie
Newbie
Posts: 7
Joined: Fri Nov 15, 2002 12:00 am
Location: Brisbane, Australia
Contact:

Post by roamer » Tue Jun 07, 2005 2:21 am

Hi,
I'm using the same version of TeeChart as you (Build 1.1.1879.21176). I'll keep playing for a while. I don't know whether this problem shows itself if the data are added one by one. It could be that the problem only occurs when the DataSource is set to a DataTable. Note that if I change the chart type from ColorGrid to, say, a Surface, the exception does not get thrown and everything works as one would expect.

Ricky

roamer
Newbie
Newbie
Posts: 7
Joined: Fri Nov 15, 2002 12:00 am
Location: Brisbane, Australia
Contact:

Post by roamer » Tue Jun 07, 2005 5:23 am

Hi,

here's an example of some data that will crash the ColorGrid. To see this for yourself, save the following data series to a text file, open the TeeChart feature demo, go to ColorGrid and click Edit. Make sure Irregular grid is checked, and Color mode is set to Range. Then go to the Data Source tab and change the data source to a file. Select the file where you copied the below data. Ensure that Comma is selected as the field separator. The demo should throw an exception saying that the index was outside the bounds of the array. I concede that the problem doesn't appear to have to do with negative values. In the data below, the first column are the X values (horizontal axis), the second column are the Y values (color axis) and the third column are the Z values (vertical axis).

Ricky

-160,0,0
-160,0,10
-160,0,20
-160,0.5,30
-160,0,40
-160,0,50
-160,0,60
-160,0,70
-160,0,80
-160,0,90
-160,0,100
-150,0,0
-150,0,10
-150,0,20
-150,0,30
-150,0,40
-150,0,50
-150,0,60
-150,0,70
-150,0,80
-150,0,90
-150,0,100
-140,0,0
-140,0,10
-140,0,20
-140,0,30
-140,0,40
-140,0,50
-140,0,60
-140,0,70
-140,0,80
-140,0,90
-140,0,100
-130,0,0
-130,0,10
-130,0,20
-130,0,30
-130,0,40
-130,0,50
-130,0,60
-130,0,70
-130,0,80
-130,0,90
-130,0,100
-120,0,0
-120,0,10
-120,0,20
-120,0,30
-120,0,40
-120,0,50
-120,0,60
-120,0,70
-120,0,80
-120,0,90
-120,0,100
-110,0,0
-110,0,10
-110,0,20
-110,0,30
-110,0,40
-110,0,50
-110,0,60
-110,0,70
-110,0,80
-110,0,90
-110,0,100
-100,0,0
-100,0,10
-100,0,20
-100,0,30
-100,0,40
-100,0,50
-100,0,60
-100,0,70
-100,0,80
-100,0,90
-100,0,100
-90,0,0
-90,0,10
-90,0,20
-90,0,30
-90,0,40
-90,0,50
-90,0,60
-90,0,70
-90,0,80
-90,0,90
-90,0,100
-80,0,0
-80,0,10
-80,0,20
-80,0,30
-80,0,40
-80,0,50
-80,0,60
-80,0,70
-80,0,80
-80,0,90
-80,0,100
-70,0,0
-70,0,10
-70,0,20
-70,0,30
-70,0,40
-70,0,50
-70,0,60
-70,0,70
-70,0,80
-70,0,90
-70,0,100
-60,0,0
-60,0,10
-60,0,20
-60,0,30
-60,0,40
-60,0,50
-60,0,60
-60,0,70
-60,0,80
-60,0,90
-60,0,100
-50,0,0
-50,0,10
-50,0,20
-50,0,30
-50,0,40
-50,0,50
-50,0,60
-50,0,70
-50,0,80
-50,0,90
-50,0,100
-40,0,0
-40,0,10
-40,0,20
-40,0,30
-40,0,40
-40,0,50
-40,0,60
-40,0,70
-40,0,80
-40,0,90
-40,0,100
-30,0,0
-30,0,10
-30,0,20
-30,0,30
-30,0,40
-30,0,50
-30,0,60
-30,0,70
-30,0,80
-30,0,90
-30,0,100
-20,0,0
-20,0,10
-20,0,20
-20,0,30
-20,0,40
-20,0,50
-20,0,60
-20,0,70
-20,0,80
-20,0,90
-20,0,100
-10,0,0
-10,0,10
-10,0,20
-10,0,30
-10,0,40
-10,0,50
-10,0,60
-10,0,70
-10,0,80
-10,0,90
-10,0,100
0,0,0
0,0,10
0,0,20
0,0,30
0,0,40
0,0,50
0,0,60
0,0,70
0,0,80
0,0,90
0,0,100
10,0,0
10,3,10
10,1.5,20
10,4,30
10,4.5,40
10,3,50
10,5.5,60
10,3,70
10,1,80
10,1,90
10,5.5,100
20,7,0
20,1,10
20,1.5,20
20,0,30
20,0,40
20,0.5,50
20,0,60
20,0,70
20,0,80
20,0,90
20,0,100
30,3.5,0
30,0,10
30,0,20
30,0,30
30,0,40
30,0,50
30,0,60
30,0,70
30,0,80
30,0,90
30,0,100
40,2,0
40,0,10
40,0,20
40,0,30
40,0,40
40,0,50
40,0,60
40,0,70
40,0,80
40,0,90
40,0,100
Last edited by roamer on Tue Jun 07, 2005 5:43 am, edited 1 time in total.

roamer
Newbie
Newbie
Posts: 7
Joined: Fri Nov 15, 2002 12:00 am
Location: Brisbane, Australia
Contact:

Post by roamer » Tue Jun 07, 2005 5:41 am

Hi again,

actually, I can't make *any* set of data work in the Feature Demo when it is read from a text file and when the Irregular Grid check box is checked, even sets of data that work perfectly well in my own application when that data is contained in a DataTable...

Ricky

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Jun 07, 2005 12:07 pm

Hi Ricky,

I've been able to reproduce the problem but it doesn't seem to come from negative values as:

Code: Select all

		private void Form1_Load(object sender, System.EventArgs e)
		{
			Steema.TeeChart.Styles.ColorGrid surf = new Steema.TeeChart.Styles.ColorGrid(tChart1.Chart);
			commander1.Chart = tChart1;

			surf.IrregularGrid=true;

			for (double x=0; x<50; ++x)
				for (double z=0; z<=10; ++z)
					surf.Add(x,0,z);			
		}
Also doesn't work, the problem seems to come from IrregularGrid=true, however the using line below works:

Code: Select all

for (double x=-5; x<5; ++x)
Regarding the demo example, I've been able to load the data .txt file setting IrregularGrid=false.

I've already added all this to our bug list (TF02010690) to be fixed for next releases.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply