Page 1 of 1

Axis Nearest Value

Posted: Wed Mar 18, 2009 12:19 pm
by 14047415
Hello Sir,

I want to display the nearest Axis values of X,Y,Z on right clicking at a particular point of surface,in a small dialog.
How can i get these values using Steema Chart.
I have uploaded image "3D Plot.JPG" , which shows an arrow highlighting the desired value.
Please help.Thanks in Advance.

Regards,
Sanyog

Posted: Wed Mar 18, 2009 3:57 pm
by yeray
Hi Sanyog,

Here there is an example of how I think you could do this:

Code: Select all

        public Form1()
        {
            InitializeComponent();

            InitializeChart();
        }

        Steema.TeeChart.Styles.Surface surf1;
        Steema.TeeChart.Tools.Annotation annotation1;

        private void InitializeChart()
        {
            tChart1.Aspect.Chart3DPercent = 50;
            chartController1.Chart = tChart1;

            annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
            annotation1.Active = false;

            surf1 = new Steema.TeeChart.Styles.Surface(tChart1.Chart);
            surf1.FillSampleValues(25);

            surf1.Click += new MouseEventHandler(surf1_Click);
        }

        void surf1_Click(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                int ValueIndex = ((Steema.TeeChart.Styles.Surface)sender).Clicked(e.X, e.Y);

                if (ValueIndex > -1)
                {
                    annotation1.Left = e.X;
                    annotation1.Top = e.Y;
                    annotation1.Text = "X: " + surf1.XValues.Value[ValueIndex].ToString() + "  Y: " + surf1.YValues.Value[ValueIndex].ToString() + "  Z: " + surf1.ZValues.Value[ValueIndex].ToString();
                    annotation1.Active = true;
                }
            }
            else
            {
                annotation1.Active = false;
            }