Page 1 of 1

Annotation Control

Posted: Tue Jul 21, 2009 8:34 pm
by 9640703
Is it possible to add a control to annotation?

Thanks,
Sachin

Re: Annotation Control

Posted: Wed Jul 22, 2009 7:37 am
by 10050769
Hello Sachin,
Is it possible to add a control to annotation?
Is not possible to add a control to annotation tool.

Please, you can say exactly what do you want to do? so we could try to find alternative solution, that works as you want in your application.

Thanks,

Re: Annotation Control

Posted: Wed Jul 22, 2009 3:28 pm
by 9640703
I wanted to do something similar to that seen in the image attached for annotation
annotation.JPG
annotation.JPG (17.7 KiB) Viewed 9976 times
Thanks,
Sachin

Re: Annotation Control

Posted: Thu Jul 23, 2009 10:05 am
by narcis
Hi Sachin,

I don't think this can be done with an annotation tool. However, you can add other controls with a TChart as their parent. For example, in the code below I used a Panel and a MessageBox. You may use other controls but can't use a System.Windows.Form in a chart as it's a top-level control.

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private void InitializeChart()
		{
			tChart1.Dock = DockStyle.Fill;

			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line1.FillSampleValues();

			tChart1.Click += new EventHandler(tChart1_Click);
			tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
		}

		Panel myPanel;

		void tChart1_MouseMove(object sender, MouseEventArgs e)
		{
			if (myPanel != null)
			{
				myPanel.Dispose();
			}

			myPanel = new Panel();
			tChart1.Controls.Add(myPanel);
			myPanel.Location = new Point(e.X, e.Y);

			Label myLabel = new Label();
			myLabel.Text = "This is the text I want to use";
			myPanel.Controls.Add(myLabel);

			Button yesBtn = new Button();
			yesBtn.Location = new Point(10, 20);
			yesBtn.Text = "Yes";
			myPanel.Controls.Add(yesBtn);
		}

		void tChart1_Click(object sender, EventArgs e)
		{

			DialogResult reply = MessageBox.Show(tChart1, "Tap either Yes or No", "Caption", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

			if ((reply == DialogResult.Yes))
			{
				// Process Yes
			}
			else
			{
				// Process No
			}
		}
Hope this helps!

Re: Annotation Control

Posted: Mon Aug 03, 2009 8:28 pm
by 9640703
I was able to create a custom similar to Msgbox as mentioned by you. I want to have a line going from Msgbox to the point on Series something similar to Annotation callout how can I acheive that?

Thanks,
Sachin

Re: Annotation Control

Posted: Tue Aug 04, 2009 12:01 pm
by yeray
Hi Sachin,

Taking Narcis' example, you could use OnAfterDraw event to draw a line from the desired point (in the example the sixth, valueindex 5)

Code: Select all

public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }

        Steema.TeeChart.Styles.Line line1;
        int MouseX, MouseY;

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart1.Dock = DockStyle.Fill;

            line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line1.FillSampleValues();

            line1.Pointer.Visible = true;

            MouseX = 0;
            MouseY = 0;

            tChart1.Click += new EventHandler(tChart1_Click);
            tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
        }

        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            g.Line(line1.CalcXPos(5), line1.CalcYPos(5), MouseX, MouseY);
        }

        Panel myPanel;

        void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            if (myPanel != null)
            {
                myPanel.Dispose();
            }

            myPanel = new Panel();
            tChart1.Controls.Add(myPanel);
            myPanel.Location = new Point(e.X, e.Y);

            Label myLabel = new Label();
            myLabel.Text = "This is the text I want to use";
            myPanel.Controls.Add(myLabel);

            Button yesBtn = new Button();
            yesBtn.Location = new Point(10, 20);
            yesBtn.Text = "Yes";
            myPanel.Controls.Add(yesBtn);

            MouseX = e.X;
            MouseY = e.Y;
            
            tChart1.Refresh();
        }

        void tChart1_Click(object sender, EventArgs e)
        {

            DialogResult reply = MessageBox.Show(tChart1, "Tap either Yes or No", "Caption", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

            if ((reply == DialogResult.Yes))
            {
                // Process Yes
            }
            else
            {
                // Process No
            }
        }

Re: Annotation Control

Posted: Tue Aug 04, 2009 8:59 pm
by 9640703
Thanks that works

Thanks,
Sachin