Page 1 of 1

MarksTip tool

Posted: Fri Feb 05, 2010 7:47 am
by 13052926
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?

Re: MarksTip tool

Posted: Fri Feb 05, 2010 10:27 am
by 10050769
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,

Re: MarksTip tool

Posted: Fri Feb 05, 2010 12:17 pm
by 13052926
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!

Re: MarksTip tool

Posted: Mon Feb 08, 2010 10:54 am
by 10050769
Hello rossmc,

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

Thanks,

Re: MarksTip tool

Posted: Mon Feb 08, 2010 11:34 am
by 13052926
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.

Re: MarksTip tool

Posted: Tue Jul 06, 2010 3:12 pm
by 16056172
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

Re: MarksTip tool

Posted: Thu Jul 08, 2010 10:47 am
by 10050769
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,