Annotation Control

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
gs
Newbie
Newbie
Posts: 84
Joined: Mon Mar 20, 2006 12:00 am
Location: US

Annotation Control

Post by gs » Tue Jul 21, 2009 8:34 pm

Is it possible to add a control to annotation?

Thanks,
Sachin

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Annotation Control

Post by Sandra » Wed Jul 22, 2009 7:37 am

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

gs
Newbie
Newbie
Posts: 84
Joined: Mon Mar 20, 2006 12:00 am
Location: US

Re: Annotation Control

Post by gs » Wed Jul 22, 2009 3:28 pm

I wanted to do something similar to that seen in the image attached for annotation
annotation.JPG
annotation.JPG (17.7 KiB) Viewed 9818 times
Thanks,
Sachin

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Annotation Control

Post by Narcís » Thu Jul 23, 2009 10:05 am

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!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

gs
Newbie
Newbie
Posts: 84
Joined: Mon Mar 20, 2006 12:00 am
Location: US

Re: Annotation Control

Post by gs » Mon Aug 03, 2009 8:28 pm

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

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Annotation Control

Post by Yeray » Tue Aug 04, 2009 12:01 pm

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
            }
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

gs
Newbie
Newbie
Posts: 84
Joined: Mon Mar 20, 2006 12:00 am
Location: US

Re: Annotation Control

Post by gs » Tue Aug 04, 2009 8:59 pm

Thanks that works

Thanks,
Sachin

Post Reply