Page 1 of 1

Problem with SurfaceNearest Tool

Posted: Tue Aug 12, 2025 8:48 am
by 15699625
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

Re: Problem with SurfaceNearest Tool

Posted: Tue Aug 12, 2025 10:45 am
by Marc
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:

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

Re: Problem with SurfaceNearest Tool

Posted: Tue Aug 12, 2025 1:00 pm
by 15699625
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

Re: Problem with SurfaceNearest Tool

Posted: Tue Aug 12, 2025 1:46 pm
by 15699625
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

Re: Problem with SurfaceNearest Tool

Posted: Wed Aug 13, 2025 2:39 pm
by Marc
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

Re: Problem with SurfaceNearest Tool

Posted: Thu Aug 14, 2025 10:39 am
by Marc
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.

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