Bars and StackedBar Combined...

Thread is closed for posting
3 posts, 1 answers
  1. Marcos Perez
    Marcos Perez avatar
    5 posts
    Member since:
    Nov 2004

    Posted 07 May 2010 Link to this post

    Hello
    I Need to combine a bar chart with a stacked bar, I tried to do it with the code I show you below
    In the first series the bars are generated fine, but when I add the stacked bar that are placed next to the first bar and I need the stacked bar to be placed at the fourth position
    I also attach a graph to show you what generates the code and what I need
    Could you please help me?
    Thanks
    Best regards
    Marcos J. Perez


    Here is the code:
                    RadChart graExpediente = new RadChart(); 
                    graExpediente.ChartTitle.TextBlock.Text = "Expedientes"
                    graExpediente.PlotArea.XAxis.AutoScale = false
                    graExpediente.PlotArea.XAxis.AddRange(1, 4, 1); 
                    graExpediente.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 8, System.Drawing.FontStyle.Regular); 
                    graExpediente.PlotArea.XAxis[0].TextBlock.Text = "Asignados"
                    graExpediente.PlotArea.XAxis[1].TextBlock.Text = "En Proceso"
                    graExpediente.PlotArea.XAxis[2].TextBlock.Text = "A Vencer"
                    graExpediente.PlotArea.XAxis[3].TextBlock.Text = "Dependientes"
                    graExpediente.PlotArea.XAxis.IsZeroBased = false
                    graExpediente.PlotArea.YAxis.AxisMode = ChartYAxisMode.Extended; 
                    graExpediente.PlotArea.YAxis.AxisLabel.TextBlock.Text = "Asignados"
                    graExpediente.Skin = "Vista"
     
                    // Crea la series y las barras para el Supervisor 
                    ChartSeries Supervisor = new ChartSeries("Supervisor", ChartSeriesType.Bar); 
                    Supervisor.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Tahoma", 7, System.Drawing.FontStyle.Regular); 
                    Supervisor.Appearance.Border.Color = System.Drawing.Color.Black; 
                    Supervisor.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing; 
                    // Define las barras en la serie 
                    Supervisor.AddItem(50, string.Empty, System.Drawing.Color.Yellow); 
                    Supervisor.AddItem(30, string.Empty, System.Drawing.Color.Green); 
                    Supervisor.AddItem(20, string.Empty, System.Drawing.Color.Red);                 
     
                    // Crea la serie y la seccion para los Dependientes 
                    ChartSeries AsignadosDep = new ChartSeries("AsignadosDep", ChartSeriesType.StackedBar); 
                    AsignadosDep.Appearance.Border.Color = System.Drawing.Color.Black; 
                    AsignadosDep.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing; 
                    // Define la seccion en la serie 
                    AsignadosDep.AddItem(11, string.Empty, System.Drawing.Color.Yellow); 
     
                    ChartSeries EnProcesoDep = new ChartSeries("EnProcesoDep", ChartSeriesType.StackedBar); 
                    EnProcesoDep.Appearance.Border.Color = System.Drawing.Color.Black; 
                    EnProcesoDep.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing;                 
                    EnProcesoDep.AddItem(6, string.Empty, System.Drawing.Color.Green); 
     
                    ChartSeries AVencerDep = new ChartSeries("AVencerDep", ChartSeriesType.StackedBar); 
                    AVencerDep.Appearance.Border.Color = System.Drawing.Color.Black; 
                    AVencerDep.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing; 
                    AVencerDep.AddItem(5, string.Empty, System.Drawing.Color.Red); 
     
     
                    // Add the series to the chart, chart to page. 
                    graExpediente.Series.Add(Supervisor); 
                    graExpediente.Series.Add(AsignadosDep); 
                    graExpediente.Series.Add(EnProcesoDep); 
                    graExpediente.Series.Add(AVencerDep);                 
     
                    this.Page.Controls.Add(graExpediente);

  2. Answer
    Ves
    Admin
    Ves avatar
    2926 posts

    Posted 12 May 2010 Link to this post

    Hello Marcos,

    You can use the XValue property of the ChartSeriesItems to define their position along the X axis. Here is an updated version of your code:

    // Define las barras en la serie
    ChartSeriesItem SupervisorItem = new ChartSeriesItem(50, string.Empty, System.Drawing.Color.Yellow);
    SupervisorItem.XValue = 1;
    Supervisor.Items.Add(SupervisorItem);
    SupervisorItem = new ChartSeriesItem(30, string.Empty, System.Drawing.Color.Green);
    SupervisorItem.XValue = 2;
    Supervisor.Items.Add(SupervisorItem);
    SupervisorItem = new ChartSeriesItem(20, string.Empty, System.Drawing.Color.Red);
    SupervisorItem.XValue = 3;
    Supervisor.Items.Add(SupervisorItem);
     
    // Crea la serie y la seccion para los Dependientes
    ChartSeries AsignadosDep = new ChartSeries("AsignadosDep", ChartSeriesType.StackedBar);
    AsignadosDep.Appearance.Border.Color = System.Drawing.Color.Black;
    AsignadosDep.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing;
    // Define la seccion en la serie
    ChartSeriesItem AsignadosDepItem = new ChartSeriesItem(11, string.Empty, System.Drawing.Color.Yellow);
    AsignadosDepItem.XValue = 4;
    AsignadosDep.Items.Add(AsignadosDepItem);
     
    ChartSeries EnProcesoDep = new ChartSeries("EnProcesoDep", ChartSeriesType.StackedBar);
    EnProcesoDep.Appearance.Border.Color = System.Drawing.Color.Black;
    EnProcesoDep.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing;
    ChartSeriesItem EnProcesoDepItem = new ChartSeriesItem(6, string.Empty, System.Drawing.Color.Green);
    EnProcesoDepItem.XValue = 4;
    EnProcesoDep.Items.Add(EnProcesoDepItem);
     
    ChartSeries AVencerDep = new ChartSeries("AVencerDep", ChartSeriesType.StackedBar);
    AVencerDep.Appearance.Border.Color = System.Drawing.Color.Black;
    AVencerDep.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing;
    ChartSeriesItem AVencerDepItem = new ChartSeriesItem(5, string.Empty, System.Drawing.Color.Red);
    AVencerDepItem.XValue = 4;
    AVencerDep.Items.Add(AVencerDepItem);

    Hope this helps.

    Regards,
    Ves
    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.
  3. Marcos Perez
    Marcos Perez avatar
    5 posts
    Member since:
    Nov 2004

    Posted 12 May 2010 Link to this post

    Thanks for the response and suggestion, works perfectly!   Is exactly what I needed
    I am very grateful with your help
    Thank you very much


Back to Top