Customizing MarksTip Tool

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
AIS
Newbie
Newbie
Posts: 70
Joined: Wed Jun 25, 2008 12:00 am

Customizing MarksTip Tool

Post by AIS » Wed Jan 28, 2009 9:37 am

Hi,

is it possible to change the text format of a markstip tool? For example there is an "Label and Value" style which show something like that "28.01.2009 5" but i want to show in multiline:
"Date: 28.01.2009
Value: 5"

A custom style would be intresting in that case. For example: "Date: %XValue \nValue: %YValue".

Thanks in advance.
Last edited by AIS on Wed Jan 28, 2009 11:09 am, edited 1 time in total.

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

Post by Narcís » Wed Jan 28, 2009 9:55 am

Hi AIS,

Yes, you can do that using MarksTip's GetText event, for example:

Code: Select all

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

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line1.FillSampleValues();
			line1.XValues.DateTime = true;

			Steema.TeeChart.Tools.MarksTip marksTip1 = new Steema.TeeChart.Tools.MarksTip(tChart1.Chart);
			marksTip1.Style = Steema.TeeChart.Styles.MarksStyles.XY;
			marksTip1.GetText += new Steema.TeeChart.Tools.MarksTipGetTextEventHandler(marksTip1_GetText);
		}

		void marksTip1_GetText(Steema.TeeChart.Tools.MarksTip sender, Steema.TeeChart.Tools.MarksTipGetTextEventArgs e)
		{
			int tmp = e.Text.IndexOf(" ");
			e.Text = "Date: " + e.Text.Substring(0, tmp) + "\n" +
							"Value: " + e.Text.Substring(tmp + 1);
		}
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

AIS
Newbie
Newbie
Posts: 70
Joined: Wed Jun 25, 2008 12:00 am

Post by AIS » Wed Jan 28, 2009 10:59 am

Thanks for the quick response.

What could i do, if i want to know the series title and the y value? I want only use one markstiptool for all series.
Last edited by AIS on Wed Jan 28, 2009 11:10 am, edited 1 time in total.

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

Post by Narcís » Wed Jan 28, 2009 11:09 am

Hi AIS,

In that case you can do this:

Code: Select all

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

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line1.FillSampleValues();
			line1.XValues.DateTime = true;

			Steema.TeeChart.Styles.Line line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line2.FillSampleValues();
			line2.XValues.DateTime = true;

			Steema.TeeChart.Tools.MarksTip marksTip1 = new Steema.TeeChart.Tools.MarksTip(tChart1.Chart);
			marksTip1.Style = Steema.TeeChart.Styles.MarksStyles.XY;
			marksTip1.GetText += new Steema.TeeChart.Tools.MarksTipGetTextEventHandler(marksTip1_GetText);

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

		private int SeriesIndex = -1;

		void tChart1_MouseMove(object sender, MouseEventArgs e)
		{
			for (int i = 0; i < tChart1.Series.Count; i++)
			{
				if (tChart1[0].Clicked(e.X,e.Y) != 0)
				{
					SeriesIndex = i;
					break;
				}

				SeriesIndex = -1;
			}
		}

		void marksTip1_GetText(Steema.TeeChart.Tools.MarksTip sender, Steema.TeeChart.Tools.MarksTipGetTextEventArgs e)
		{
			int tmp = e.Text.IndexOf(" ");
			e.Text = "SeriesName: " + tChart1[SeriesIndex].Title + "\n" +
									"Value: " + e.Text.Substring(tmp + 1);
		}
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

AIS
Newbie
Newbie
Posts: 70
Joined: Wed Jun 25, 2008 12:00 am

Post by AIS » Wed Jan 28, 2009 12:21 pm

Hi Narcís,

a little correction of your code:

Code: Select all

        void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            for (int i = 0; i < tChart1.Series.Count; i++)
            {
                if (tChart1[i].Clicked(e.X, e.Y) != -1)
                {
                    SeriesIndex = i;
                    break;
                }

                SeriesIndex = -1;
            }
        }

        void marksTip1_GetText(Steema.TeeChart.Tools.MarksTip sender, Steema.TeeChart.Tools.MarksTipGetTextEventArgs e)
        {
            if (SeriesIndex > -1)
            {
                int tmp = e.Text.IndexOf(" ");
                e.Text = "SeriesName: " + tChart1[SeriesIndex].Title + "\n" +
                                  "Value: " + e.Text.Substring(tmp + 1);
            }
        }
This solution works, but it is a little bit flickering :-/

Thanks anyway :)

Post Reply