Skip to main content

How to: Create a 2D Side-by-Side Full-Stacked Bar Chart

The following example demonstrates how to create a 2D Side-by-Side Full-Stacked Bar chart. To do this, it is necessary to assign the ChartControl.Diagram property to XYDiagram2D, and then add four BarSideBySideFullStackedSeries2D objects with points to the diagram’s Diagram.Series collection. And, to stack the series, use their BarSideBySideFullStackedSeries2D.StackedGroup property.

<Window x:Class="SideBySideFullStackedBarChart.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts">
    <Grid>
        <dxc:ChartControl HorizontalAlignment="Left" Name="chartControl1" VerticalAlignment="Top" Height="311" Width="503">
            <dxc:ChartControl.Diagram>
                <dxc:XYDiagram2D>
                    <dxc:XYDiagram2D.Series>
                        <dxc:BarSideBySideFullStackedSeries2D DisplayName="First Series" StackedGroup="1" BarWidth="0.5">
                            <!--region #Model-->
                            <dxc:BarSideBySideFullStackedSeries2D.Model>
                                <dxc:Quasi3DBar2DModel />
                            </dxc:BarSideBySideFullStackedSeries2D.Model>
                            <!--endregion #Model-->
                            <dxc:BarSideBySideFullStackedSeries2D.Points>
                                <dxc:SeriesPoint Argument="A" Value="1" />
                                <dxc:SeriesPoint Argument="B" Value="2" />
                            </dxc:BarSideBySideFullStackedSeries2D.Points>
                        </dxc:BarSideBySideFullStackedSeries2D>
                        <dxc:BarSideBySideFullStackedSeries2D DisplayName="Second Series" StackedGroup="1" BarWidth="0.5">
                            <!--region #Model2-->
                            <dxc:BarSideBySideFullStackedSeries2D.Model>
                                <dxc:Quasi3DBar2DModel />
                            </dxc:BarSideBySideFullStackedSeries2D.Model>
                            <!--endregion #Model2-->
                            <dxc:BarSideBySideFullStackedSeries2D.Points>
                                <dxc:SeriesPoint Argument="A" Value="4" />
                                <dxc:SeriesPoint Argument="B" Value="3" />
                            </dxc:BarSideBySideFullStackedSeries2D.Points>
                        </dxc:BarSideBySideFullStackedSeries2D>
                        <dxc:BarSideBySideFullStackedSeries2D DisplayName="Third Series" StackedGroup="2" BarWidth="0.5">
                            <!--region #Model3-->
                            <dxc:BarSideBySideFullStackedSeries2D.Model>
                                <dxc:Quasi3DBar2DModel />
                            </dxc:BarSideBySideFullStackedSeries2D.Model>
                            <!--endregion #Model3-->
                            <dxc:BarSideBySideFullStackedSeries2D.Points>
                                <dxc:SeriesPoint Argument="A" Value="5" />
                                <dxc:SeriesPoint Argument="B" Value="6" />
                            </dxc:BarSideBySideFullStackedSeries2D.Points>
                        </dxc:BarSideBySideFullStackedSeries2D>
                        <dxc:BarSideBySideFullStackedSeries2D DisplayName="Fourth Series" StackedGroup="2" BarWidth="0.5">
                            <!--region #Model4-->
                            <dxc:BarSideBySideFullStackedSeries2D.Model>
                                <dxc:Quasi3DBar2DModel />
                            </dxc:BarSideBySideFullStackedSeries2D.Model>
                            <!--endregion #Model4-->
                            <dxc:BarSideBySideFullStackedSeries2D.Points>
                                <dxc:SeriesPoint Argument="A" Value="2" />
                                <dxc:SeriesPoint Argument="B" Value="3" />
                            </dxc:BarSideBySideFullStackedSeries2D.Points>
                        </dxc:BarSideBySideFullStackedSeries2D>
                    </dxc:XYDiagram2D.Series>
                </dxc:XYDiagram2D>
            </dxc:ChartControl.Diagram>
        </dxc:ChartControl>
    </Grid>
</Window>