Using Teechart 2025.7.7 with 3D surface, I have a problem with surfaceNearestTool.
After Redraw, all cells are displayed in rainbow colors.
If I move the cursor on the cells, all colors disappear and all cells have same color.
This problem changes with Z range.
My setup is here:
surface1.PaletteMin = 0;
surface1.PaletteStep = 100;
surface1.PaletteStyle = Steema.TeeChart.Styles.PaletteStyles.Rainbow;
surface1.Title = "surface1";
surface1.UseColorRange = false;
surface1.UsePalette = true;
surface1.PaletteSteps = 30;
surfaceNearestTool1.Series = surface1;
Best Regards
Christian Frank
Problem with SurfaceNearest Tool
-
- Newbie
- Posts: 4
- Joined: Tue Mar 18, 2025 12:00 am
Problem with SurfaceNearest Tool
- Attachments
-
- teechart_3D_before_cursor_nearesttool_contact.jpg (148.85 KiB) Viewed 3520 times
-
- teechart_3D_after_cursor_nearesttool_contact.jpg (127.08 KiB) Viewed 3520 times
Re: Problem with SurfaceNearest Tool
Hello Christian,
Check that you have no event running that's resetting UsePalette.
This code test ok and may be worth checking as a comparison:
I've checked this on framework 4.8. Let me know if you're running a later framework and the test code shows the same problem.
Regards,
Marc Meumann
Check that you have no event running that's resetting UsePalette.
This code test ok and may be worth checking as a comparison:
Code: Select all
tChart1.Aspect.View3D = true;
tChart1.Aspect.Chart3DPercent = 40;
tChart1.Series.Clear();
tChart1.Tools.Clear();
surface1 = new Steema.TeeChart.Styles.Surface();
surfaceNearestTool1 = new Steema.TeeChart.Tools.SurfaceNearestTool();
tChart1.Series.Add(surface1);
tChart1.Tools.Add(surfaceNearestTool1);
surface1.UseColorRange = false;
surface1.UsePalette = true;
surface1.PaletteMin = 0D;
surface1.PaletteStep = 0D;
surface1.PaletteStyle = Steema.TeeChart.Styles.PaletteStyles.Rainbow;
surface1.Title = "surface1";
surface1.FillSampleValues(50);
surfaceNearestTool1.CellColor = System.Drawing.Color.Red;
surfaceNearestTool1.ColumnColor = System.Drawing.Color.Green;
surfaceNearestTool1.RowColor = System.Drawing.Color.Blue;
surfaceNearestTool1.SelectedCell = -1;
surfaceNearestTool1.Series = surface1;
surfaceNearestTool1.SeriesIndex = 0;
Regards,
Marc Meumann
Steema Support
-
- Newbie
- Posts: 4
- Joined: Tue Mar 18, 2025 12:00 am
Re: Problem with SurfaceNearest Tool
Hello Mark,
thank you for your sample code.
I work with Visual Studio 2022 and have framework 4.8.
I have tested with your code, all works fine with sample values or with some demo values.
But when I draw my user data, then I habe the same problem, all colors are away after moving the cursor in the chart.
The complete chart has same color.
for (xIndex = 0; xIndex < nNumCol; xIndex++)
{
for (yIndex = 0; yIndex < nNumRow; yIndex++)
{
arrayIndex = xIndex + (yIndex * nNumCol);
if (arrayIndex < myDataSet.tDataArray[nPlotSet].nActDataNum)
{
dXVal = (double)myDataSet.tDataArray[nPlotSet].tDataPos[arrayIndex].nPosXMikroMeter / 1000.0;
dYVal = (double)myDataSet.tDataArray[nPlotSet].tDataPos[arrayIndex].nPosYMikroMeter / 1000.0;
dZVal = (double)myDataSet.tDataArray[nPlotSet].tDataValue[arrayIndex].profileMikroMeter / 1000.0;
surface1.Add(dXVal, dZVal, dYVal);
}
}
}
Best Regards
Christian Frank
thank you for your sample code.
I work with Visual Studio 2022 and have framework 4.8.
I have tested with your code, all works fine with sample values or with some demo values.
But when I draw my user data, then I habe the same problem, all colors are away after moving the cursor in the chart.
The complete chart has same color.
for (xIndex = 0; xIndex < nNumCol; xIndex++)
{
for (yIndex = 0; yIndex < nNumRow; yIndex++)
{
arrayIndex = xIndex + (yIndex * nNumCol);
if (arrayIndex < myDataSet.tDataArray[nPlotSet].nActDataNum)
{
dXVal = (double)myDataSet.tDataArray[nPlotSet].tDataPos[arrayIndex].nPosXMikroMeter / 1000.0;
dYVal = (double)myDataSet.tDataArray[nPlotSet].tDataPos[arrayIndex].nPosYMikroMeter / 1000.0;
dZVal = (double)myDataSet.tDataArray[nPlotSet].tDataValue[arrayIndex].profileMikroMeter / 1000.0;
surface1.Add(dXVal, dZVal, dYVal);
}
}
}
Best Regards
Christian Frank
-
- Newbie
- Posts: 4
- Joined: Tue Mar 18, 2025 12:00 am
Re: Problem with SurfaceNearest Tool
Hello Marc,
now I tested with your start-code. Then I filled the values with:
for (int x = 0; x <= 50; x++)
for (int z = 0; z <= 50; z++)
{
y = -1.0 + 8.0 * (double)z / 50.0;
surface1.Add(x, y, z);
}
>> It works fine
Then I changed the range: (y=-1.0 >> y=0.0)
for (int x = 0; x <= 50; x++)
for (int z = 0; z <= 50; z++)
{
y = 0.0 + 8.0 * (double)z / 50.0;
surface1.Add(x, y, z);
}
and the problem comes again, all colors are same.
It seems, if the call to surfaceNearest overwrites all celles with the color of first cells.
Best Regards,
Christian Frank
now I tested with your start-code. Then I filled the values with:
for (int x = 0; x <= 50; x++)
for (int z = 0; z <= 50; z++)
{
y = -1.0 + 8.0 * (double)z / 50.0;
surface1.Add(x, y, z);
}
>> It works fine
Then I changed the range: (y=-1.0 >> y=0.0)
for (int x = 0; x <= 50; x++)
for (int z = 0; z <= 50; z++)
{
y = 0.0 + 8.0 * (double)z / 50.0;
surface1.Add(x, y, z);
}
and the problem comes again, all colors are same.
It seems, if the call to surfaceNearest overwrites all celles with the color of first cells.
Best Regards,
Christian Frank
Re: Problem with SurfaceNearest Tool
Hello Christian,
Thank you for the extra information. I am able to reproduce the problem and confirm that it is caused when the Y data value range shifts.
We're checking for the cause and possible solutions.
Regards,
Marc
Thank you for the extra information. I am able to reproduce the problem and confirm that it is caused when the Y data value range shifts.
We're checking for the cause and possible solutions.
Regards,
Marc
Re: Problem with SurfaceNearest Tool
Hello Christian,
Thank you for the bug report, the problem has been identified and a fix applied for the next update.
ref.: https://www.steema.com/bugs/show_bug.cgi?id=2780
A workaround exists that could be used until the "in-code" fix is available. It has worked for test cases but may have limitations.
At the moment the series tries to match the 0 index colour with series.Count colour (a point that is not assigned) to test for a homogenous palette and applies an invalid Grid upToColor causing a condition result to be invalid. The internal fix (pending publication) addresses that by correcting the match to Series.Count-1. The workaround sets a colour likely to fail the match condition.
Regards,
Marc Meumann
Thank you for the bug report, the problem has been identified and a fix applied for the next update.
ref.: https://www.steema.com/bugs/show_bug.cgi?id=2780
A workaround exists that could be used until the "in-code" fix is available. It has worked for test cases but may have limitations.
Code: Select all
//set a GetValueColor event for the Series
surface1.GetValueColor += new Steema.TeeChart.Styles.Custom3DPalette.GetColorEventHandler(this.surface1_GetValueColor);
//set a colour where ValueIndex = Series.Count.
private void surface1_GetValueColor(Series sender, Custom3DPalette.GetColorEventArgs e)
{
if (e.ValueIndex == sender.Count)
e.Color = System.Drawing.Color.AliceBlue; //some improbable match colour
}
Regards,
Marc Meumann
-
- Newbie
- Posts: 1
- Joined: Wed May 31, 2023 12:00 am
Re: Problem with SurfaceNearest Tool
Hello Marc,
thank you for your workaround. I tested it and my surfaceNearestTool cursor moves around the chart, all colors are correct.
(see my picture in attachement)
I have another probblem, maybe the origin is the surfaceNearestTool :
When I call my 3D Winform, my program crashes sometimes with the following message:
unresolved exception: System.ArgumentOutOfRangeException: "The index was out of range. It must not be negative or smaller than the collection.
After that, I exit program and start again. Then I can call the 3D Winform many times without a problem, showing the same dataset as in the crash. (see picture)
In details part of the exception window, i get this text:
" bei System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)\r\n bei Steema.TeeChart.Styles.Custom3DPalette.qkx(Double jmq)\r\n bei Steema.TeeChart.Styles.Custom3DPalette.GetValueColorValue(Double aValue)\r\n bei Steema.TeeChart.Styles.Custom3DPalette.ValueColor(Int32 valueIndex)\r\n bei Steema.TeeChart.Tools.SurfaceNearestTool.MouseEvent(MouseEventKinds kind, MouseEventArgs e, Cursor& c)\r\n bei Steema.TeeChart.Chart.BroadcastMouseEvent(MouseEventKinds kind, MouseEventArgs e, Cursor& c)\r\n bei Steema.TeeChart.TChart.OnMouseMove(MouseEventArgs e)\r\n bei System.Windows.Forms.Control.WmMouseMove(Message& m)\r\n bei System.Windows.Forms.Control.WndProc(Message& m)\r\n bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)\r\n bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n bei Laser_Position.Program.Main() in C:\\Users\\cfrank\\Documents\\work\\Wacker\\WackerLaser\\2024\\Software\\VisualStudio\\Laser_Position\\Program.cs: Zeile16"
Do you have any idea, what is the cause of this ?
Best Regards
Christian Frank
thank you for your workaround. I tested it and my surfaceNearestTool cursor moves around the chart, all colors are correct.
(see my picture in attachement)
I have another probblem, maybe the origin is the surfaceNearestTool :
When I call my 3D Winform, my program crashes sometimes with the following message:
unresolved exception: System.ArgumentOutOfRangeException: "The index was out of range. It must not be negative or smaller than the collection.
After that, I exit program and start again. Then I can call the 3D Winform many times without a problem, showing the same dataset as in the crash. (see picture)
In details part of the exception window, i get this text:
" bei System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)\r\n bei Steema.TeeChart.Styles.Custom3DPalette.qkx(Double jmq)\r\n bei Steema.TeeChart.Styles.Custom3DPalette.GetValueColorValue(Double aValue)\r\n bei Steema.TeeChart.Styles.Custom3DPalette.ValueColor(Int32 valueIndex)\r\n bei Steema.TeeChart.Tools.SurfaceNearestTool.MouseEvent(MouseEventKinds kind, MouseEventArgs e, Cursor& c)\r\n bei Steema.TeeChart.Chart.BroadcastMouseEvent(MouseEventKinds kind, MouseEventArgs e, Cursor& c)\r\n bei Steema.TeeChart.TChart.OnMouseMove(MouseEventArgs e)\r\n bei System.Windows.Forms.Control.WmMouseMove(Message& m)\r\n bei System.Windows.Forms.Control.WndProc(Message& m)\r\n bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)\r\n bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n bei Laser_Position.Program.Main() in C:\\Users\\cfrank\\Documents\\work\\Wacker\\WackerLaser\\2024\\Software\\VisualStudio\\Laser_Position\\Program.cs: Zeile16"
Do you have any idea, what is the cause of this ?
Best Regards
Christian Frank
- Attachments
-
- example for my dataset
- surfaceNearestTool after workaround.jpg (258.07 KiB) Viewed 1559 times