How to draw a reference line on chart?

3 posts, 0 answers
  1. kiran
    kiran avatar
    36 posts
    Member since:
    May 2008

    Posted 11 Jun 2008 Link to this post

    Hi All,

    Can any one please tell me how to draw a reference line at a point on Y-axis?like a threshold line at threshold point.

    exact requirement:

    i need to draw a horizontal reference line parallel to X-axis like suppose at point 3 on y-axis i need to draw a cut-off line which should be parallel to the x-axis like

    ------------------------------------------------------- X-axis 

    is this possible? if so please share some sample code.

    Thanks in advance.


  2. Jane
    Jane avatar
    3 posts
    Member since:
    Jun 2008

    Posted 12 Jun 2008 Link to this post

    Hi Kiran,

    you can use Scale breaks to implement this feature. I am not sure. you can check with telerik people.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dwight
    Dwight avatar
    475 posts

    Posted 13 Jun 2008 Link to this post

    Hi Kirian,

    There are two approaches I can suggest. The first one is using marked areas:
    1 ChartMarkedZone zone = new ChartMarkedZone("zone 1"); 
    2 zone.ValueStartY = 20d; 
    3 zone.ValueEndY = 20.5d; 
    4 zone.Appearance.FillStyle.MainColor = Color.FromArgb(128, Color.Red); 
    5 this.radChart1.PlotArea.MarkedZones.Add(zone); 

    These marked areas, however, show beneath the series. If you require the reference line to be on top of the rest, I suggest adding a line series using the same values for all Items, or adding only two items, but setting their X values:
    1 ChartSeries referenceSeries = new ChartSeries("Reference line", ChartSeriesType.Line, this.radChart1.Series); 
    2 referenceSeries.Items.Add(new ChartSeriesItem(0, 10)); 
    3 referenceSeries.Items.Add(new ChartSeriesItem(4, 10)); 
    4 referenceSeries.Appearance.LabelAppearance.Visible = false
    5 referenceSeries.Appearance.FillStyle.MainColor = Color.Red; 
    7 this.radChart1.Series.Add(referenceSeries); 

    Should you need further help, do not hesitate to write us back.

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top