Tooltip for DateTime format

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Tooltip for DateTime format

Post by amol » Mon Jun 19, 2017 2:15 pm

Hi Steema,

We have one query regarding the tooltip as shown in the attached image, i am showing tooltip using Markstip Tool.
But in my case X scale is plotted with "date-time" values and Y axis use double value and we are using candle series.
1.png
Image
1.png (7.6 KiB) Viewed 7564 times
And i am using below code-
StringBuilder sb = new StringBuilder("");
sb.Append("Time: ");
sb.Append(e.Text);

So when we are using this e.Text property, it gives X value in double format i.e "42,739" and Y value is "122.545" so here Y value is correct but X value is not in Datetime format.
i also used method ---scandleSeries1.ScreenPointToValuePoint(e.X,0).X; for this but still this method does not able to convert this double value to date time.

Please provide any solution asap.

Thanks in advance.

Planoresearch

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Tooltip for DateTime format

Post by Christopher » Mon Jun 26, 2017 7:49 am

Hello Amol,

Apologies for the delay in this reply.

This code:

Code: Select all

    private void InitializeChart()
    {
      Candle series = new Candle(tChart1.Chart);
      series.FillSampleValues();

      MarksTip tool = new MarksTip(tChart1.Chart);

      tool.Style = MarksStyles.XY;
    }
will give you this result:
markstip.png
markstip.png (29.84 KiB) Viewed 7542 times
to modify the DateTime string you can use the GetText event, e.g.

Code: Select all

    private void InitializeChart()
    {
      Candle series = new Candle(tChart1.Chart);
      series.FillSampleValues();

      MarksTip tool = new MarksTip(tChart1.Chart);

      tool.Style = MarksStyles.XY;

      tool.GetText += Tool_GetText;
    }

    private void Tool_GetText(MarksTip sender, MarksTipGetTextEventArgs e)
    {
      string text = e.Text;
      string[] lines = text.Split(' ');
      DateTime dt = DateTime.Parse(lines[0]);
      e.Text = dt.ToLongDateString() + " " + lines[1];
    }
markstip2.png
markstip2.png (30.92 KiB) Viewed 7537 times
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply