Skip to main content

How to: Create a 2D Full-Stacked Area Chart

The following example demonstrates how to create a 2D Full-Stacked Area chart. To do this, it is necessary to assign the ChartControl.Diagram property to XYDiagram2D, and then add two AreaFullStackedSeries2D objects with points to the diagram’s Diagram.Series collection.

Also, this example shows how to add a legend (showing series names) to a chart.

<Window x:Class="FullStackedArea2DChart.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts" Title="Window1" Height="350" Width="620">
    <Grid>
        <dxc:ChartControl Name="chartControl1">
             <dxc:ChartControl.Diagram>
                <dxc:XYDiagram2D>
                    <dxc:XYDiagram2D.Series>
                        <dxc:AreaFullStackedSeries2D DisplayName="First Series" Transparency="0.5">
                            <dxc:AreaFullStackedSeries2D.Points>
                                <dxc:SeriesPoint Argument="A" Value="2" />
                                <dxc:SeriesPoint Argument="B" Value="2" />
                                <dxc:SeriesPoint Argument="C" Value="1" />
                                <dxc:SeriesPoint Argument="D" Value="6" />
                            </dxc:AreaFullStackedSeries2D.Points>
                            <!--region #PointOptions-->
                            <dxc:AreaFullStackedSeries2D.PointOptions>
                                <dxc:PointOptions>
                                    <dxc:PointOptions.ValueNumericOptions>
                                        <dxc:NumericOptions Format="Percent" Precision="2" />
                                    </dxc:PointOptions.ValueNumericOptions>
                                    <dxc:AreaFullStackedSeries2D.PercentOptions>
                                        <dxc:PercentOptions PercentageAccuracy="3" />
                                    </dxc:AreaFullStackedSeries2D.PercentOptions>
                                </dxc:PointOptions>
                            </dxc:AreaFullStackedSeries2D.PointOptions>
                            <!--endregion #PointOptions-->
                        </dxc:AreaFullStackedSeries2D>
                        <dxc:AreaFullStackedSeries2D DisplayName="Second Series" Transparency="0.5">
                            <dxc:AreaFullStackedSeries2D.Points>
                                <dxc:SeriesPoint Argument="A" Value="4" />
                                <dxc:SeriesPoint Argument="B" Value="3" />
                                <dxc:SeriesPoint Argument="C" Value="2" />
                                <dxc:SeriesPoint Argument="D" Value="1" />
                            </dxc:AreaFullStackedSeries2D.Points>
                            <!--region #PointOptions2-->
                            <dxc:AreaFullStackedSeries2D.PointOptions>
                                <dxc:PointOptions>
                                    <dxc:PointOptions.ValueNumericOptions>
                                        <dxc:NumericOptions Format="Percent" Precision="2" />
                                    </dxc:PointOptions.ValueNumericOptions>
                                    <dxc:AreaFullStackedSeries2D.PercentOptions>
                                        <dxc:PercentOptions PercentageAccuracy="3" />
                                    </dxc:AreaFullStackedSeries2D.PercentOptions>
                                </dxc:PointOptions>
                            </dxc:AreaFullStackedSeries2D.PointOptions>
                            <!--endregion #PointOptions2-->
                        </dxc:AreaFullStackedSeries2D>
                    </dxc:XYDiagram2D.Series>
                    <dxc:XYDiagram2D.AxisX>
                        <dxc:AxisX2D Range="SideMarginsEnabled=False" />
                    </dxc:XYDiagram2D.AxisX>
                    <dxc:XYDiagram2D.AxisY>
                        <dxc:AxisY2D Range="SideMarginsEnabled=False" GridSpacing="0.25" />
                    </dxc:XYDiagram2D.AxisY>
                </dxc:XYDiagram2D>                 
            </dxc:ChartControl.Diagram>
            <dxc:ChartControl.Legend>
                <dxc:Legend />
            </dxc:ChartControl.Legend>
        </dxc:ChartControl>
    </Grid>
</Window>