How add vertical line in SfChart

Dear, 

We using SfChart component in WPF in our company.
Need add one vertical line (and horizontal) and dynamical set this position (see image). 
We are tried with ChartCrossHairBehavior, this looks good (see image) but position is binding on mouse position, we need fix position and we will calculate and set this from code.
Please give me some suggestion how to set horizontal position for ChartCrossHairBehavior or example with some another component where we can generate vertical line.

Image_7401_1713336803263

Best regards, Goran


1 Reply

DR Dhanaraj Rajendran Syncfusion Team April 18, 2024 02:19 PM UTC

Hi Siegfried,


To add the vertical line in the chart, we recommend using the Annotation feature instead of the ChartCrossHairBehavior. The Annotation allows you to add both vertical and horizontal lines to the chart, and you can dynamically set their positions programmatically.

To assist you further, we have provided a user guide for Horizontal and Vertical Line Annotation in our documentation, which you can refer to for detailed instructions. The guide will walk you through the process of adding and customizing vertical and horizontal lines in the chart.

UG Link: Horizontal and Vertical Line Annotation in WPF SfChart.

Additionally, to define the X and Y values for the annotation lines based on the axis, you can refer to the documentation section on setting values for annotations.

UG Link: Setting Annotation value based on Axis

Sample output:


We hope this suggestion helps to address your requirement effectively. If you have any further questions or need assistance with implementing this solution, please feel free to reach out to us.


Regards,

Dhanaraj Rajendran.


Loader.
Up arrow icon