Multiple Series On Top Of Each Other

3 posts, 0 answers
  1. Jason Van Dusen
    Jason Van Dusen avatar
    33 posts
    Member since:
    May 2007

    Posted 06 May 2009 Link to this post

    If I have two series, is it possible to show the second series on top of the first?  Any help would be greatly appreciated.  Basically what I am trying to do is show an overlap in time as a red bar and the rest of the bar as a different color.

    Jason
  2. Jason Van Dusen
    Jason Van Dusen avatar
    33 posts
    Member since:
    May 2007

    Posted 07 May 2009 Link to this post

    I figured it out.

    myChart.Appearance.BarOverlapPercent = 100
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 08 May 2009 Link to this post

    Hello Jason,

    The default behavior of the RadChart to horizontally split the available space can be worked around by giving different X values for each of the series. Here is a short example:
    public partial class Form1 : Form 
        public Form1() 
        { 
            Random random = new Random(0x65412); 
     
            InitializeComponent(); 
     
            ChartSeries series = new ChartSeries(); 
            ChartSeries coverSeries = new ChartSeries(); 
            series.Type = ChartSeriesType.Gantt; 
            coverSeries.Type = ChartSeriesType.Gantt; 
            coverSeries.Appearance.LabelAppearance.Visible = false
     
            for (int i = 0; i < 10; i++) 
            { 
                ChartSeriesItem item = new ChartSeriesItem(); 
                item.YValue2 = random.Next(50, 100); 
                item.YValue = random.Next(150, 200); 
                item.XValue = i; 
                series.Items.Add(item); 
     
                ChartSeriesItem coverItem = new ChartSeriesItem(); 
                coverItem.YValue2 = random.Next(105, 120); 
                coverItem.YValue = random.Next(130, 145); 
                coverItem.XValue = i + 0.0001; 
                coverSeries.Items.Add(coverItem); 
            } 
     
            this.radChart1.Series.Add(series); 
            this.radChart1.Series.Add(coverSeries); 
        } 

    As you can see, the index of the respective item is used as it's X value, but for the second series, a constant of 0.0001 is added. That will make the chart to draw the second series on top of the first one.

    Best,
    Evtim
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top