MarksTip tool

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
rossmc
Newbie
Newbie
Posts: 57
Joined: Wed Apr 08, 2009 12:00 am

MarksTip tool

Post by rossmc » Fri Feb 05, 2010 7:47 am

Is there sample code somewhere for using the Markstip tool? I can get it working in the standard fashion, but I need to modify the text contents quite alot before it displays, as well as have multiple lines in the markstip.

For example, in my application, when the mouse hovers on my series (which represents a share price over time), the tooltip needs to display the name of the share plotted, the date under the pointer, along with all the share price stats for that day, open, high, low, close etc, each stat on it's own line.

In my old application (using the AX control), I simply had a timer turn on/off when entering/leaving a series. If the timer event fired I manually created my own tooltip and displayed that.

Is it possible to do this using the Markstip or do I need to stick to doing it manually?

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

Re: MarksTip tool

Post by Sandra » Fri Feb 05, 2010 10:27 am

Hello rossmc,

I made a simple code, that change value of Markstip tool using GetText event of MarksTip and you could use similar for your application. Please, check next example works as you want.

Code: Select all

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

        private Steema.TeeChart.Styles.Bar bar;
        Steema.TeeChart.Tools.MarksTip markstiptool;
        private void InitializeChart()
        {
            bar = new Steema.TeeChart.Styles.Bar(tChart2.Chart);
            markstiptool = new Steema.TeeChart.Tools.MarksTip(tChart2.Chart);
            bar.FillSampleValues();
            markstiptool.Series = bar;
            markstiptool.GetText += new Steema.TeeChart.Tools.MarksTipGetTextEventHandler(markstiptool_GetText);

        }
        void markstiptool_GetText(Steema.TeeChart.Tools.MarksTip sender, Steema.TeeChart.Tools.MarksTipGetTextEventArgs e)
        {
            e.Text = "Value X:" + bar.XValues.Maximum.ToString() + "" + "Value Y" + bar.YValues.Maximum.ToString();
        }

I hope will helps.

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

rossmc
Newbie
Newbie
Posts: 57
Joined: Wed Apr 08, 2009 12:00 am

Re: MarksTip tool

Post by rossmc » Fri Feb 05, 2010 12:17 pm

I don't know why that didn't work for me the first time around? But it is now. The only difference I need to the code you sent is obviously I need to know what point I am over to display info relative to the point below the mouse. I did this:

Private Sub tooltip_GetText(ByVal sender As Steema.TeeChart.Tools.MarksTip, ByVal e As teema.TeeChart.Tools.MarksTipGetTextEventArgs) Handles tooltip.GetText
Dim point As System.Drawing.Point = TChart1.PointToClient(Control.MousePosition)

e.Text = "Header" & vbCrLf
e.Text &= "Close: " & sender.Series.YValues.Item(CType(TChart1.Axes.Bottom.CalcPosPoint(point.X), Integer))
End Sub

In my production code I have a dataset that correlates exactly to the bottom axes of the chart. Therefore once I know the bottom axis point, I can simply retrieve all relevant data for that point from the dataset and set the tooltip text using that.

Oh, and Thanks!

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

Re: MarksTip tool

Post by Sandra » Mon Feb 08, 2010 10:54 am

Hello rossmc,

Please, you could send a simple example us, because we can reproduce exactly your problem here and we can help you.

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

rossmc
Newbie
Newbie
Posts: 57
Joined: Wed Apr 08, 2009 12:00 am

Re: MarksTip tool

Post by rossmc » Mon Feb 08, 2010 11:34 am

Hi Sandra

Sorry, apparently I just like writing on forums too much :)

I was trying to say in my last post on this thread that actually my problem is solved. Setting the text in the GetText event works perfectly!

Thanks again.

vk_nomura
Newbie
Newbie
Posts: 12
Joined: Mon May 17, 2010 12:00 am

Re: MarksTip tool

Post by vk_nomura » Tue Jul 06, 2010 3:12 pm

Hi Sandra,

I am trying to accomplish exactly what "rossmc" has done in WPF, C#. Can post a sample code. The api PointToClient is not available on TChart control ( wpf version).

Regards,
Vish

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

Re: MarksTip tool

Post by Sandra » Thu Jul 08, 2010 10:47 am

Hello vk_nomura,

I have made a simple code that has same behaviour that PointToClient and it can be used in WPF application:

Code: Select all

    private Steema.TeeChart.WPF.Styles.Bar bar;
        Steema.TeeChart.WPF.Tools.MarksTip markstiptool;
        private void InitializeChart()
        {
            bar = new Steema.TeeChart.WPF.Styles.Bar(tChart1.Chart);
            markstiptool = new Steema.TeeChart.WPF.Tools.MarksTip(tChart1.Chart);
            bar.FillSampleValues();
            markstiptool.Series = bar;
            markstiptool.GetText  =new Steema.TeeChart.WPF.Tools.MarksTipGetTextEventHandler(markstiptool_GetText);
            tChart1.MouseMove  = new MouseEventHandler(tChart1_MouseMove);
        
        }
        private int index;
        void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            Point p = e.GetPosition(tChart1);
            index = bar.Clicked(p);

        }
     
        void  markstiptool_GetText(Steema.TeeChart.WPF.Tools.MarksTip sender, Steema.TeeChart.WPF.Tools.MarksTipGetTextEventArgs e)
        {
            if (index != -1)
            {
                e.Text = "Close:"   bar.YValues[index].ToString(); 
            }
        }
Could you please check if previous code works as you want?

I hope will helps.

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

Post Reply