This is a migrated thread and some comments may be shown as answers.

Draw horizontal line in chart?

5 Answers 800 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Monika Kogler
Top achievements
Rank 1
Monika Kogler asked on 23 Mar 2010, 01:00 PM
Hi,
I'm using the line-chart for displaying complex data. Now, i want to put the ranges (upper and lower limit in which all data is supposed to occur) in the charts. These limits should be horizontal lines in the background (simple red lines without any points). How can i do this?
Thx

5 Answers, 1 is accepted

Sort by
0
Monika Kogler
Top achievements
Rank 1
answered on 24 Mar 2010, 02:49 PM
Okay, I have tried to use line-series but it didn't work because i can't set any x-values of the points. How can I get the minX and maxX value of my axes in an dynamic generated chart? MinValue and MaxValue didn't work. And how can set the pointer-markers to null to that there is only a blank line???

Or is there something like MarkedZones in WPF chart? That would be very helpful!

0
Velin
Telerik team
answered on 25 Mar 2010, 11:13 AM
Hello Monika Kogler,

You could determine the axis X values with code like this:

    RadChart1.DataBound += new EventHandler<ChartDataBoundEventArgs>(RadChart1_DataBound);
 
void RadChart1_DataBound(object sender, ChartDataBoundEventArgs e)
{
    double maxValue = RadChart1.DefaultView.ChartArea.AxisX.ActualMaxValue;
    double minValue = RadChart1.DefaultView.ChartArea.AxisX.ActualMinValue;
}

Also you can turn off the point marks with code like this:
LineSeriesDefinition def = new LineSeriesDefinition();
def.ShowPointMarks = false;

Our development team plans to implement "Marked Zones" for the next major release of the control.

Best wishes,
Velin
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Monika Kogler
Top achievements
Rank 1
answered on 25 Mar 2010, 12:10 PM
hi,
chart_databound doesn't work for me because i'm using a custom chartarea. und chartarea doesn't have a databound-event. how can i implement your suggestions for me?

That's my code:
               LineSeriesDefinition def = new LineSeriesDefinition {ShowPointMarks = false};
                DataSeries lowerLimit = new DataSeries
                {
                    Definition = def,
                    LegendLabel = string.Empty
                };

                lowerLimit.Definition.ShowItemToolTips = false;
                lowerLimit.Add(new DataPoint(minValue, LowerLimit));
                lowerLimit.Add(new DataPoint(maxValue, LowerLimit));
                chartArea.DataSeries.Add(lowerLimit);


thx in advance
0
Velin
Telerik team
answered on 30 Mar 2010, 08:03 PM
Hello Monika Kogler,

You need to keep track of the minimum X value and the maximum X value when you are populating the control with data. These two values should be used to create a dummy line series showing the lower limit. If you could send us a sample project, we might be able to suggest a specific implementation for this.

Our development team plans to implement "Marked Zones" for the next major release of the control.

Regards,
Velin
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Guilherme
Top achievements
Rank 1
answered on 05 Apr 2013, 06:24 PM
You can use Annotaions. Here's an example of how to add one horizontal annotaion in code behind:

    Annotations = new AnnotationCollection();

            Annotations.Add(new CustomLine()
            {
                Slope = 0,
                YIntercept = yourLimitValue,
                MinX = yourMinXvalue,
                MinY = 0,
                MaxX = yourMaxXvalue,
                MaxY = yourMaxYvalue,
                Stroke = new SolidColorBrush(Colors.Red),
                StrokeThickness = 20
            });
Tags
Chart
Asked by
Monika Kogler
Top achievements
Rank 1
Answers by
Monika Kogler
Top achievements
Rank 1
Velin
Telerik team
Guilherme
Top achievements
Rank 1
Share this question
or