StockSeries2D Class
Represents the 2D Stock series.
Namespace: DevExpress.Xpf.Charts
Assembly: DevExpress.Xpf.Charts.v19.2.dll
Declaration
Example
This example shows how to create a 2D Stock Chart.
Create a ChartControl and specify its ChartControl.Diagram property to a SimpleDiagram2D object.
Note
Note that the ChartControl.Diagram is a content property. You can declare a diagram in XAML directly after a chart control’s declaration without wrapping it in opening and closing ChartControl.Diagram tags.
Add a
StockSeries2D
object to the Diagram.Series collection.Note
Note that the Diagram.Series is a content property. You can declare series in XAML directly after a diagram’s declaration without wrapping them in opening and closing Diagram.Series tags.
Use the following properties to bind the series to data:
- Series.DataSource - Specifies the series’s data source.
- Series.ArgumentDataMember - Defines the data member that provides the series’s arguments.
- FinancialSeries2D.OpenValueDataMember - Specifies the data member that provides data for Open point values.
- FinancialSeries2D.HighValueDataMember - Defines the data member that provides data for High point values.
- FinancialSeries2D.LowValueDataMember - Specifies the data member that provides data for Low point values.
- FinancialSeries2D.CloseValueDataMember - Specifies the data member that provides data for Close point values.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-create-a-2d-stock-chart-e1684.
<Window x:Class="Stock2DChart.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"
xmlns:local="clr-namespace:Stock2DChart"
Title="Window1"
Height="350" Width="620">
<Window.DataContext>
<local:ChartViewModel/>
</Window.DataContext>
<Grid>
<dxc:ChartControl Name="chartControl1">
<dxc:XYDiagram2D>
<dxc:StockSeries2D ArgumentScaleType="DateTime"
DataSource="{Binding Data}"
ArgumentDataMember="Date"
OpenValueDataMember="Open"
HighValueDataMember="High"
LowValueDataMember="Low"
CloseValueDataMember="Close"
LabelsVisibility="True">
<dxc:StockSeries2D.Label>
<dxc:SeriesLabel TextPattern="{}{HV}"/>
</dxc:StockSeries2D.Label>
<!--region #Model-->
<dxc:StockSeries2D.Model>
<dxc:FlatStock2DModel/>
</dxc:StockSeries2D.Model>
<!--endregion #Model-->
<!--region #ReductionOptions-->
<dxc:StockSeries2D.ReductionOptions>
<dxc:ReductionStockOptions Level="CloseValue"
ColorMode="OpenToCloseValue"/>
</dxc:StockSeries2D.ReductionOptions>
<!--endregion #ReductionOptions-->
</dxc:StockSeries2D>
<dxc:XYDiagram2D.AxisX>
<dxc:AxisX2D>
<dxc:AxisX2D.Label>
<dxc:AxisLabel TextPattern="{}{A:MMM d}"/>
</dxc:AxisX2D.Label>
<dxc:AxisX2D.DateTimeScaleOptions>
<dxc:ManualDateTimeScaleOptions AutoGrid="False"
GridSpacing="1"/>
</dxc:AxisX2D.DateTimeScaleOptions>
</dxc:AxisX2D>
</dxc:XYDiagram2D.AxisX>
<dxc:XYDiagram2D.AxisY>
<dxc:AxisY2D>
<dxc:AxisY2D.WholeRange>
<dxc:Range dxc:AxisY2D.AlwaysShowZeroLevel="False" />
</dxc:AxisY2D.WholeRange>
</dxc:AxisY2D>
</dxc:XYDiagram2D.AxisY>
</dxc:XYDiagram2D>
</dxc:ChartControl>
</Grid>
</Window>
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the StockSeries2D class.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.