How to: Create a 2D Stacked Spline Area Chart

  • 2 minutes to read

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

Also, this example shows how to specify AreaStackedSeries2D.Transparency and SplineAreaStackedSeries2D.LineTension properties and add a legend to a chart.

<Window
        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"
        x:Class="StackedSplineAreaChart.MainWindow"
        Title="Stacked Spline Area Chart" Height="600" Width="800">
    <Grid>
        <dxc:ChartControl>
            <dxc:ChartControl.Diagram>
                <dxc:XYDiagram2D>
                    <dxc:XYDiagram2D.Series>
                        <dxc:SplineAreaStackedSeries2D DisplayName="1998" LineTension="0.8"
                                                       Transparency="0.4">
                            <dxc:SplineAreaStackedSeries2D.Points>
                                <dxc:SeriesPoint Argument="Illinois" Value="423.721" />
                                <dxc:SeriesPoint Argument="Indiana" Value="178.719" />
                                <dxc:SeriesPoint Argument="Michigan" Value="308.845" />
                                <dxc:SeriesPoint Argument="Ohio" Value="348.555" />
                                <dxc:SeriesPoint Argument="Wisconsin" Value="160.274" />
                            </dxc:SplineAreaStackedSeries2D.Points>
                            <dxc:SplineAreaStackedSeries2D.Label>
                                <dxc:SeriesLabel Visible="True"  dxc:MarkerSeries2D.Angle="40" />
                            </dxc:SplineAreaStackedSeries2D.Label>
                        </dxc:SplineAreaStackedSeries2D>
                        <dxc:SplineAreaStackedSeries2D DisplayName="2001" LineTension="0.8"
                                                       Transparency="0.4">
                            <dxc:SplineAreaStackedSeries2D.Points>
                                <dxc:SeriesPoint Argument="Illinois" Value="476.851" />
                                <dxc:SeriesPoint Argument="Indiana" Value="195.769" />
                                <dxc:SeriesPoint Argument="Michigan" Value="335.793" />
                                <dxc:SeriesPoint Argument="Ohio" Value="374.771" />
                                <dxc:SeriesPoint Argument="Wisconsin" Value="182.373" />
                            </dxc:SplineAreaStackedSeries2D.Points>
                            <dxc:SplineAreaStackedSeries2D.Label>
                                <dxc:SeriesLabel Visible="True" dxc:MarkerSeries2D.Angle="40" />
                            </dxc:SplineAreaStackedSeries2D.Label>
                        </dxc:SplineAreaStackedSeries2D>
                        <dxc:SplineAreaStackedSeries2D DisplayName="2004" LineTension="0.8"
                                                       Transparency="0.4">
                            <dxc:SplineAreaStackedSeries2D.Points>
                                <dxc:SeriesPoint Argument="Illinois" Value="528.904" />
                                <dxc:SeriesPoint Argument="Indiana" Value="227.271" />
                                <dxc:SeriesPoint Argument="Michigan" Value="372.576" />
                                <dxc:SeriesPoint Argument="Ohio" Value="418.258" />
                                <dxc:SeriesPoint Argument="Wisconsin" Value="211.727" />
                            </dxc:SplineAreaStackedSeries2D.Points>
                            <dxc:SplineAreaStackedSeries2D.Label>
                                <dxc:SeriesLabel Visible="True" dxc:MarkerSeries2D.Angle="40" />
                            </dxc:SplineAreaStackedSeries2D.Label>
                        </dxc:SplineAreaStackedSeries2D>
                    </dxc:XYDiagram2D.Series>
                    <dxc:XYDiagram2D.AxisX>
                        <dxc:AxisX2D>
                            <dxc:AxisX2D.WholeRange>
                                <dxc:Range SideMarginsValue="0" />
                            </dxc:AxisX2D.WholeRange>
                        </dxc:AxisX2D>
                    </dxc:XYDiagram2D.AxisX>
                    <dxc:XYDiagram2D.AxisY>
                        <dxc:AxisY2D>
                            <dxc:AxisY2D.Title>
                                <dxc:AxisTitle Content="Millions of Dollars" />
                            </dxc:AxisY2D.Title>
                        </dxc:AxisY2D>
                    </dxc:XYDiagram2D.AxisY>
                </dxc:XYDiagram2D>
            </dxc:ChartControl.Diagram>
            <dxc:ChartControl.Legend>
                <dxc:Legend HorizontalPosition="Right" />
            </dxc:ChartControl.Legend>
            <dxc:ChartControl.Titles>
                <dxc:Title Dock="Top" HorizontalAlignment="Center">Great Lakes Gross State Product
                </dxc:Title>
            </dxc:ChartControl.Titles>
        </dxc:ChartControl>
    </Grid>
</Window>