Draw horizontal line in chart?

6 posts, 0 answers
  1. Monika Kogler
    Monika Kogler avatar
    30 posts
    Member since:
    Aug 2009

    Posted 23 Mar 2010 Link to this post

    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
  2. Monika Kogler
    Monika Kogler avatar
    30 posts
    Member since:
    Aug 2009

    Posted 24 Mar 2010 Link to this post

    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!

  3. UI for WPF is Visual Studio 2017 Ready
  4. Velin
    Admin
    Velin avatar
    391 posts

    Posted 25 Mar 2010 Link to this post

    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.
  5. Monika Kogler
    Monika Kogler avatar
    30 posts
    Member since:
    Aug 2009

    Posted 25 Mar 2010 Link to this post

    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
  6. Velin
    Admin
    Velin avatar
    391 posts

    Posted 30 Mar 2010 Link to this post

    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.
  7. Guilherme
    Guilherme avatar
    3 posts
    Member since:
    Jun 2012

    Posted 05 Apr 2013 Link to this post

    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
                });
Back to Top
UI for WPF is Visual Studio 2017 Ready