ColorGrid and negative values
Posted: 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
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