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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

InteractiveCursor, how to convert Mouse position => OffsetX

Thread ID:

Created:

Updated:

Platform:

Replies:

115485 Jan 20,2014 06:07 AM UTC Jan 22,2014 01:08 AM UTC WPF 2
loading
Tags: Chart
Rodolphe Billottet
Asked On January 20, 2014 06:07 AM UTC

 Hi

I have a Chart diplaying financial indictors  (Xaxis is DateTime)

I want to dynamicaly add some InteractiveCursor (Only VerticalCurso)  in the Chart using the mouse a the exact place where I click (for instance with right click).

I tried the code below but there is a gap between mouse and  the InteractiveCursor X position

That seems to be the margine between the area and beginning of the axis/series.

I used a constant value '-44' to fix that gap, but it is a crapy solution.

How can I set correctly the OffsetX from the Mouse position ?

 

Code Snippet [C#]:

private void ChartAreaMouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
 var point = e.GetPosition(sender as ChartArea);
              
 currentCursor = new InteractiveCursor
 {
  OffsetX = point.X - 44,
  IsBindWithSegment = false,
  BindWithMouseMoveOnSegment = false,                                                                         
  HorizontalCursorVisibility = Visibility.Hidden,
  VerticalLabelVisibility = Visibility.Hidden,

...

}

ChartArea.InteractiveCursors.Add(currentCursor);


Karthikeyan V [Syncfusion]
Replied On January 21, 2014 12:47 PM UTC

Hi Rodolphe,

Thanks for using the Syncfusion products.

We have analysed the reported requirement. You can achieve your requirement by applying the below code snippet.

Code snippet [C#]:

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

        {

            var point = e.GetPosition(sender as ChartArea);

 

            InteractiveCursor currentCursor = new InteractiveCursor

            {

                OffsetX = point.X - this.Chart1.Areas[0].AxesThickness.Left - ((sender as ChartArea).ElementMargin.Left *4),

                IsBindWithSegment = false,

                IsBindWithMouseMove = false,

                BindWithMouseMoveOnSegment = false,

                HorizontalCursorVisibility = Visibility.Hidden,

                VerticalLabelVisibility = Visibility.Hidden

            };

 

            Chart1.Areas[0].InteractiveCursors.Add(currentCursor);

        }

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

Thanks,

Karthikeyan V.


Rodolphe Billottet
Replied On January 22, 2014 01:08 AM UTC

Hi Karthikeyan,

 

Thanks for the solution. That works fine.

 

Best Regards,

Rodolphe


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

;