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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

InteractiveCursor : How to convert OffsetX to DateTime Value

Thread ID:

Created:

Updated:

Platform:

Replies:

115487 Jan 20,2014 06:49 AM UTC Jan 22,2014 08:32 AM UTC WPF 2
loading
Tags: Chart
Rodolphe Billottet
Asked On January 20, 2014 06:49 AM UTC

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

Rodolphe Billottet
Replied On 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


Karthikeyan V [Syncfusion]
Replied On 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.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;