Skip to main content

How to: Create a 2D Point Chart

  • 3 minutes to read

This example shows how to create a 2D Point chart and configure its titles, label format, axes, and appearance.

2D Point Chart

Follow the steps below to create a 2D Point chart:

  1. Create a ChartControl and set its DataContext property to a ViewModel.

  2. Set the chart’s Diagram property to an XYDiagram2D object.

  3. Add a PointSeries2D to the diagram’s Series collection.

  4. Specify the following series parameters to bind the series to data:

    For more information about series, refer to the following topic: Series.

  5. Set the Series.LabelsVisibility property to True to display point labels. Specify the SeriesLabel.TextPattern property to format labels.

  6. Use the XYDiagram2D.AxisX and XYDiagram2D.AxisY properties to customize axes (scale options, title, and labels). Refer to the following help topic for more information about axes: Axes.

  7. Add a Title object to the ChartControl.Titles collection, and specify title content. Refer to the following topic for more information about titles: Chart Titles.

View Example

<Window x:Class="Point2DChart.Window1" 
        xmlns:local ="clr-namespace:Point2DChart"
        Title="Window1" Height="350" Width="620">
        <dxc:ChartControl Name="chartControl1">
                        <dxc:PointSeries2D DisplayName="Day Temperature" 
                                           DataSource="{Binding DataPoints}" 
                                           CrosshairLabelPattern="{}{A:MMMM}: {V:f2}&#176;C"
                                <dxc:SeriesLabel TextPattern="{}{V:f1}" 
                        <dxc:AxisX2D TickmarksMinorVisible="False">
                                <dxc:Range SideMarginsValue="10"/>
                                <dxc:AxisLabel TextPattern="{}{A:MMM}"/>
                                <dxc:ManualDateTimeScaleOptions GridSpacing="1" 
                                <dxc:AxisTitle Content="Temperature (&#176;C)"/>
                <dxc:Title Dock="Top" 
                           Content="Average Day Temperature"/>
using System;
using System.Collections.Generic;
using System.Windows;
namespace Point2DChart {
    public class ChartViewModel {
        List<DataPoint> dataPoints;
        public List<DataPoint> DataPoints {
            get {
                if (dataPoints == null) {
                    dataPoints = new List<DataPoint> {
                            new DataPoint (new DateTime(2019, 1, 1), 7.2),
                            new DataPoint (new DateTime(2019, 2, 1), 8.3),
                            new DataPoint (new DateTime(2019, 3, 1), 12.2),
                            new DataPoint (new DateTime(2019, 4, 1), 15.6),
                            new DataPoint (new DateTime(2019, 5, 1), 19.6),
                            new DataPoint (new DateTime(2019, 6, 1), 22.7),
                            new DataPoint (new DateTime(2019, 7, 1), 25.2),
                            new DataPoint (new DateTime(2019, 8, 1), 25),
                            new DataPoint (new DateTime(2019, 9, 1), 21.1),
                            new DataPoint (new DateTime(2019, 10, 1), 16.3),
                            new DataPoint (new DateTime(2019, 11, 1), 10.8),
                            new DataPoint (new DateTime(2019, 12, 1), 7.5)
                return dataPoints;
    public class DataPoint {
        public DateTime Time { get; set; }
        public double Value { get; set; }
        public DataPoint(DateTime time, double value) {
            this.Time = time;
            this.Value = value;