Back to Devexpress

SeriesPoint.Value Property

wpf-devexpress-dot-xpf-dot-charts-dot-seriespoint-8d5ab1ff.md

latest14.3 KB
Original Source

SeriesPoint.Value Property

Gets or sets the series point’s value.

Namespace : DevExpress.Xpf.Charts

Assembly : DevExpress.Xpf.Charts.v25.2.dll

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
[DefaultValue(NaN)]
public double Value { get; set; }
vb
<DefaultValue(NaN)>
Public Property Value As Double

Property Value

TypeDefaultDescription
DoubleNaN

A Double value.

|

Example

This example shows how to create a 2D Side-by-Side Bar chart.

  1. Create a ChartControl and set its ChartControl.Diagram property to a XYDiagram2D object. 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.

  2. Specify the Diagram.SeriesItemsSource property to bind a collection of objects used to generate series.

  3. Use the following API members to configure the x-axis options.

  4. Create a legend and customize its settings. For more information about legends, refer to the following topic: Legends

View Example: Chart for WPF - Create a 2D Side-by-Side Bar Chart

xaml
<Window x:Class="SideBySideBar2DChart.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:SideBySideBar2DChart"
        Title="Window1" Height="350" Width="620">
    <Window.DataContext>
        <local:ChartViewModel/>
    </Window.DataContext>
    <Grid>
        <dxc:ChartControl Name="chartControl1">
            <dxc:ChartControl.Diagram>
                <dxc:XYDiagram2D SeriesItemsSource="{Binding Data}">
                    <dxc:XYDiagram2D.SeriesItemTemplate>
                        <DataTemplate>
                            <dxc:BarSideBySideSeries2D DisplayName="{Binding Name}" 
                                               DataSource="{Binding Values}"
                                               ArgumentDataMember="Argument"
                                               ValueDataMember="Value" 
                                               BarWidth="0.6">
                                <dxc:BarSideBySideSeries2D.Model>
                                    <dxc:BorderlessSimpleBar2DModel/>
                                </dxc:BarSideBySideSeries2D.Model>
                            </dxc:BarSideBySideSeries2D>
                        </DataTemplate>
                    </dxc:XYDiagram2D.SeriesItemTemplate>
                    <dxc:XYDiagram2D.AxisX>
                        <dxc:AxisX2D>
                            <dxc:AxisX2D.DateTimeScaleOptions>
                                <dxc:ManualDateTimeScaleOptions MeasureUnit="Year" GridAlignment="Year" 
                                                                AutoGrid="False" GridSpacing="1"/>
                            </dxc:AxisX2D.DateTimeScaleOptions>
                        </dxc:AxisX2D>
                    </dxc:XYDiagram2D.AxisX>
                </dxc:XYDiagram2D>
            </dxc:ChartControl.Diagram>
            <dxc:ChartControl.Legends>
                <dxc:Legend HorizontalPosition="Right"/>
            </dxc:ChartControl.Legends>
        </dxc:ChartControl>
    </Grid>
</Window>
csharp
using System;
using System.Collections.ObjectModel;
using System.Windows;
namespace SideBySideBar2DChart {
    public partial class Window1 : Window {
        public Window1() {
            InitializeComponent();
        }
    }
    public class ChartViewModel {
        public ObservableCollection<DataSeries> Data { get; private set; }

        public ChartViewModel() {
            Data = new ObservableCollection<DataSeries> {
                new DataSeries{
                    Name = "DevAV North",
                    Values = new ObservableCollection<DataPoint> {
                        new DataPoint (new DateTime(2013,12,31), 362.5),
                        new DataPoint (new DateTime(2014,12,31), 348.4),
                        new DataPoint (new DateTime(2015,12,31), 279.0),
                        new DataPoint (new DateTime(2016,12,31), 230.9),
                        new DataPoint (new DateTime(2017,12,31), 203.5),
                        new DataPoint (new DateTime(2018,12,31), 197.1)
                    }
                },
                new DataSeries{
                    Name = "DevAV South",
                    Values = new ObservableCollection<DataPoint> {
                        new DataPoint (new DateTime(2013,12,31), 277.0),
                        new DataPoint (new DateTime(2014,12,31), 328.5),
                        new DataPoint (new DateTime(2015,12,31), 297.0),
                        new DataPoint (new DateTime(2016,12,31), 255.3),
                        new DataPoint (new DateTime(2017,12,31), 173.5),
                        new DataPoint (new DateTime(2018,12,31), 131.8)
                    }
                }
            };
        }
        public class DataSeries {
            public string Name { get; set; }
            public ObservableCollection<DataPoint> Values { get; set; }
        }
        public class DataPoint {
            public DateTime Argument { get; set; }
            public double Value { get; set; }
            public DataPoint(DateTime argument, double value) {
                Argument = argument;
                Value = value;
            }
        }
    }
}
vb
Imports System
Imports System.Collections.ObjectModel

Namespace SideBySideBar2DChart
    Public Partial Class Window1
        Inherits Window

        Public Sub New()
            InitializeComponent()
        End Sub
    End Class

    Public Class ChartViewModel
        Private _Data As System.Collections.ObjectModel.ObservableCollection(Of SideBySideBar2DChart.ChartViewModel.DataSeries)

        Public Property Data As ObservableCollection(Of DataSeries)
            Get
                Return _Data
            End Get
            Private Set(ByVal value As ObservableCollection(Of DataSeries))
                _Data = value
            End Set
        End Property

        Public Sub New()
            Data = New ObservableCollection(Of DataSeries) From {
                New DataSeries With {
                    .Name = "DevAV North",
                    .Values = New ObservableCollection(Of DataPoint) From {
                        New DataPoint(New DateTime(2013, 12, 31), 362.5),
                        New DataPoint(New DateTime(2014, 12, 31), 348.4),
                        New DataPoint(New DateTime(2015, 12, 31), 279.0),
                        New DataPoint(New DateTime(2016, 12, 31), 230.9),
                        New DataPoint(New DateTime(2017, 12, 31), 203.5),
                        New DataPoint(New DateTime(2018, 12, 31), 197.1)
                    }
                },
                New DataSeries With {
                    .Name = "DevAV South",
                    .Values = New ObservableCollection(Of DataPoint) From {
                        New DataPoint(New DateTime(2013, 12, 31), 277.0),
                        New DataPoint(New DateTime(2014, 12, 31), 328.5),
                        New DataPoint(New DateTime(2015, 12, 31), 297.0),
                        New DataPoint(New DateTime(2016, 12, 31), 255.3),
                        New DataPoint(New DateTime(2017, 12, 31), 173.5),
                        New DataPoint(New DateTime(2018, 12, 31), 131.8)
                    }
                }
            }
        End Sub

        Public Class DataSeries
            Public Property Name As String
            Public Property Values As ObservableCollection(Of DataPoint)
        End Class

        Public Class DataPoint
            Public Property Argument As Date
            Public Property Value As Double

            Public Sub New(ByVal argument As Date, ByVal value As Double)
                Me.Argument = argument
                Me.Value = value
            End Sub
        End Class
    End Class
End Namespace

The following code snippets (auto-collected from DevExpress Examples) contain references to the Value property.

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.

wpf-charts-add-custom-legend-item-to-legend/CS/CustomLegendItemSample/MainWindow.xaml#L39

xml
<dxc:PieSeries2D.Points>
    <dxc:SeriesPoint Argument="USA" Value="9.63142" />
    <dxc:SeriesPoint Argument="Canada" Value="9.98467" />

wpf-charts-custom-draw-crosshair-cursor/CS/CrosshairCustomDraw/MainWindow.xaml#L25

xml
<dxc:LineSeries2D DisplayName="Series1">
    <dxc:SeriesPoint Argument="1" Value="50"/>
    <dxc:SeriesPoint Argument="2" Value="44"/>

wpf-charts-custom-draw-chart-series-points/CS/CustomDrawChart/MainWindow.xaml#L35

xml
<dxc:BarSideBySideSeries2D LabelsVisibility="True">
    <dxc:SeriesPoint Argument="A" Value="0.3" />
    <dxc:SeriesPoint Argument="B" Value="1.2" />

wpf-charts-display-custom-tooltips-over-the-data-point-hovered-by-the-mouse/CS/Window1.xaml#L14

xml
<dxc:BarSideBySideSeries2D.Points>
    <dxc:SeriesPoint Argument="A" Value="1" />
    <dxc:SeriesPoint Argument="B" Value="2" />

wpf-charts-custom-draw-crosshair-cursor/CS/CrosshairCustomDraw/MainWindow.xaml.cs#L41

csharp
// Specify the foreground and font size for the crosshair cursor label that shows series.
if (element.SeriesPoint.Value > 50) {
    element.LabelElement.Foreground = Brushes.Green;

wpf-charts-custom-draw-chart-series-points/CS/CustomDrawChart/MainWindow.xaml.cs#L32

csharp
{
    string color = CorrectDrawOptions(e.SeriesPoint.Value, e.DrawOptions);
    if (!String.IsNullOrEmpty(color))

wpf-charts-display-custom-tooltips-over-the-data-point-hovered-by-the-mouse/CS/Window1.xaml.cs#L20

csharp
tooltip_text.Text = string.Format("Series = {0}\nArgument = {1}\nValue = {2}",
    point.Series.DisplayName, point.Argument, point.Value);
tooltip1.Placement = PlacementMode.Mouse;

wpf-charts-custom-draw-crosshair-cursor/VB/CrosshairCustomDraw/MainWindow.xaml.vb#L42

vb
' Specify the foreground and font size for the crosshair cursor label that shows series.
If element.SeriesPoint.Value > 50 Then
    element.LabelElement.Foreground = Brushes.Green

wpf-charts-custom-draw-chart-series-points/VB/CustomDrawChart/MainWindow.xaml.vb#L24

vb
If CBool(Me.chbCustomDraw.IsChecked) Then
    Dim color As String = CorrectDrawOptions(e.SeriesPoint.Value, e.DrawOptions)
    If Not String.IsNullOrEmpty(color) Then e.LabelText = color & ": " & e.LabelText

wpf-charts-display-custom-tooltips-over-the-data-point-hovered-by-the-mouse/VB/Window1.xaml.vb#L19

vb
Dim point As SeriesPoint = hitInfo.SeriesPoint
Me.tooltip_text.Text = String.Format("Series = {0}" & Microsoft.VisualBasic.Constants.vbLf & "Argument = {1}" & Microsoft.VisualBasic.Constants.vbLf & "Value = {2}", point.Series.DisplayName, point.Argument, point.Value)
Me.tooltip1.Placement = PlacementMode.Mouse

See Also

SeriesPoint Class

SeriesPoint Members

DevExpress.Xpf.Charts Namespace