Animated Chart

Hello

It is possibile to render and drag something like a Crosshair vertical line in an SfChart?

I would like to drag this vertical line horizontaly along the chart and get the X coordinate value.

I would like also to update its X position using TwoWay binding.


CrossHair is very close to my needs but it disappears when mouse go out of the borders of chart and i've not found a solution to set its position, visibility and drag methods programmatically.


CrossHair.jpg


Thanks

Michele



3 Replies

NT Nitheeshkumar Thangaraj Syncfusion Team August 14, 2023 09:41 AM UTC

Hi Michele,


Based on your query, we can achieve your requirement by utilizing vertical line annotations. By enabling the CanDrag property, you can enable the dragging functionality for the vertical line. To achieve this, the DragXValues property in the ViewModel has been initialized to obtain the X values during the drag operation. Below, you will find the provided code snippet, image, and a sample for reference.


<syncfusion:SfChart.Annotations>

                <syncfusion:VerticalLineAnnotation ShowAxisLabel="True" X1="{Binding DragXValue,Mode=TwoWay}" CanDrag="True"></syncfusion:VerticalLineAnnotation>

            </syncfusion:SfChart.Annotations>


private double dragxValue;

        publicdouble DragXValue

        {

            get { return dragxValue; }

            set { dragxValue = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("DragXValue")); }

        }




We hope it helps. If you need any further assistance, feel free to ask.


Regards,

Nitheeshkumar.


Attachment: DraggingSample_53703f36.zip



MI Michele August 16, 2023 06:43 AM UTC

Hello  Nitheeshkumar

Thanks, it fit my needs


Michele



PR Preethi Rajakandham Syncfusion Team August 16, 2023 08:32 AM UTC

Hi Michele,

You're welcome. We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help.

Regards,

Preethi R


Loader.
Up arrow icon