We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

InteractiveCursor : How to convert OffsetX to DateTime Value

Hi,

This thread is link to the following one but it is a different question

InteractiveCursor, how to convert Mouse position => OffsetX

So same use case; I have a Chart diplaying financial indictors  (Xaxis is DateTime)

I want let user to move 2 vertival InteractiveCursor in order to define a Sub DateTime range.

Simple question : how can I have the related DateTime of  each InteractiveCursor.

It must be simple because there is a label displaying that value when the InteractiveCursor is moved by the mouse.

I have attched a sample

Regards,

Rodolphe



CursorLineSample_bd1c5b1.zip

2 Replies

RB Rodolphe Billottet January 21, 2014 07:55 AM UTC

Hi,

 

I tried to InteractiveCursor.DataPoint.X instead of InteractiveCursor.OffsetX .

There is way to find the related point; I'm doing a dichotomic search among InteractiveCursor.Selectedseries.Data.

This method is working as far as the InteractiveCursor.DataPoint is set.  But actually it is not always the case, sometime it is null if the position of the InteractiveCursor is between 2 distant points.

So it is again a convertion question :
How to convert OffsetX  <=>  Data.X  ??

Additional question: is there any event raised when the cursor is moving ?

Regards,

Rodolphe



KV Karthikeyan V Syncfusion Team January 22, 2014 08:32 AM UTC

Hi Rodolphe,

Thanks for using the Syncfusion products.

We have analyzed the reported requirement. You can achieve your requirement by help of PointToValue and ValueToPoint method in ChartArea.

Code snippet [C#]:

 

private void ChartArea_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)

        {

            ChartArea area = sender as ChartArea;

            var point = e.GetPosition(area);

            var range = area.PointToValue(area.PrimaryAxis, point);

            var date = DateTime.FromOADate(range);

}

We do not have interactive cursor moving event in ChartArea. But you can able to achieve with mouse move event in chartarea.

 

Code snippet [C#]:

 

        private void ChartArea_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)

        {

            ChartArea area = sender as ChartArea;

            if((e.MouseDevice).LeftButton == System.Windows.Input.MouseButtonState.Pressed)

            {

                foreach (var item in area.InteractiveCursors)

                {

                    if(item.IsMouseOver)

                    {

                        // Do something here of your requirement.

                    }

                }

            }

        }

 

Please let us know if you require further assistance on this.

 

Regards,

Karthikeyan V.


Loader.
Live Chat Icon For mobile
Up arrow icon