Shop
Anmelden
MindFusion

Q: I want to draw range lines on an area chart. I draw the area but I fail to draw the range lines. Mostly, I do not know the start and end values of the axis and how should I set the range values to make the lines appear at the level I need them.

A: In order to draw the range lines you need a LineSeries that has two X points and two Y points which will be of the same value. You know at what height the range line should be drawn – let’s say it’s 10. We understand you want the range line to start and end where the axis starts and ends. If you try to get the min and max values of the axis with the properties XAxisSettings.MinValue and XAxisSettings.MaxValue you can get double.NaN if the properties are not set. This means, if the axis is calculated automatically by the control, the MinValue and MaxValues have their default value of double.NaN and currently there is no way in which you can tell the axis range. So, you’d better set it yourself based on your data. Then you can use the values to create the range line.

The following code sets the axis from 1 to 5 and creates a red range line at the height of 10 and parallel to the X-axis.

 //set the range for the X-axis
 lineChart1.XAxisSettings.MinValue = 0;
 lineChart1.XAxisSettings.MaxValue = 5;

 //create the range line
 LineSeries series1 = new LineSeries();
 //the range line is drawn parallel to the X-axis
 series1.XData = new List() { 0, 5};
 series1.YData = new List() { 10, 10};
 //the range line is red
 series1.Fills = new List();
 series1.Fills.Add(Brushes.Red);
 //it is a line graphic
 series1.LineType = LineType.Line;
 lineChart1.Series.Add(series1);



Copyright © 2001-2024 MindFusion LLC. Alle Rechte vorbehalten.
Nutzungsbedingungen - Kontakt