Search code examples
c#winformslivecharts

Draw vertical line in a line chart with LiveCharts


I am developing a winform application to display a line chart with the use of LiveCharts. How can I draw a vertical line at a certain x coordinate? Thanks in advance.


Solution

  • I found:

            cartesianChart.AxisX.Add(new Axis
            {
                //IsMerged = true,
                Sections = new SectionsCollection
                {
                    new AxisSection
                    {
                        Value = x_best,
                        Stroke = System.Windows.Media.Brushes.Red,
                        StrokeThickness = 3,
                        StrokeDashArray = new System.Windows.Media.DoubleCollection(new [] {10d})
    
                    }
                }
            });