hello dear teechart team,
i have a question of teechart surface serial as following scenario:
when i click on the surface, i want to highlight the nearest cross-point at the mouse position, i want to use a white circle to mark this cross point and show x/y/z value of the point, how can i realize it? I know the surfacenearest tool may be a choise, but i do not want to mark a cell, only the cross-point.
How to hightlight cross point in surface serial?
Re: How to hightlight cross point in surface serial?
Hello,
I'm afraid this should be done manually. Here it is, as a start point, an example of how to draw the four points of the clicked cell.
From here, you have to calculate which one of those points is the nearest to the mouse position.
I'm afraid this should be done manually. Here it is, as a start point, an example of how to draw the four points of the clicked cell.
From here, you have to calculate which one of those points is the nearest to the mouse position.
Code: Select all
Steema.TeeChart.Drawing.Point3D P1, P2, P3, P4;
bool drawPoint;
private void InitializeChart()
{
tChart1.Aspect.Orthogonal = false;
tChart1.Aspect.Chart3DPercent = 100;
tChart1.Aspect.Zoom = 70;
drawPoint = false;
Steema.TeeChart.Styles.Surface surf1 = new Steema.TeeChart.Styles.Surface(tChart1.Chart);
surf1.FillSampleValues();
surf1.Click += new MouseEventHandler(surf1_Click);
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
}
void surf1_Click(object sender, MouseEventArgs e)
{
Steema.TeeChart.Styles.Surface surf = sender as Steema.TeeChart.Styles.Surface;
int ValueIndex = surf.Clicked(e.X, e.Y);
P1 = new Steema.TeeChart.Drawing.Point3D(surf.CalcXPos(ValueIndex), surf.CalcYPos(ValueIndex), surf.CalcZPos(ValueIndex));
P2 = new Steema.TeeChart.Drawing.Point3D(surf.CalcXPos(ValueIndex - 1), surf.CalcYPos(ValueIndex - 1), surf.CalcZPos(ValueIndex - 1));
P3 = new Steema.TeeChart.Drawing.Point3D(surf.CalcXPos(ValueIndex + surf.NumXValues), surf.CalcYPos(ValueIndex + surf.NumXValues), surf.CalcZPos(ValueIndex + surf.NumXValues));
P4 = new Steema.TeeChart.Drawing.Point3D(surf.CalcXPos(ValueIndex + surf.NumXValues - 1), surf.CalcYPos(ValueIndex + surf.NumXValues - 1), surf.CalcZPos(ValueIndex + surf.NumXValues - 1));
drawPoint = true;
tChart1.Refresh();
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
if (drawPoint)
{
tChart1.Graphics3D.Pen.Width = 2;
tChart1.Graphics3D.Pen.Color = Color.White;
tChart1.Graphics3D.Brush.Color = Color.Transparent;
tChart1.Graphics3D.Ellipse(P1.X - 5, P1.Y - 5, P1.X + 5, P1.Y + 5, P1.Z);
tChart1.Graphics3D.Ellipse(P2.X - 5, P2.Y - 5, P2.X + 5, P2.Y + 5, P2.Z);
tChart1.Graphics3D.Ellipse(P3.X - 5, P3.Y - 5, P3.X + 5, P3.Y + 5, P3.Z);
tChart1.Graphics3D.Ellipse(P4.X - 5, P4.Y - 5, P4.X + 5, P4.Y + 5, P4.Z);
}
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |