Skip to main content

How to: Draw a Custom Function in the 2D Scatter Line Chart

  • 2 minutes to read

This example demonstrates how to draw an Archimedian Spiral function in the Scatter Line chart. To do this, it is necessary to add a LineScatterSeries2D object to the diagram’s Diagram.Series collection and then programmatically add series points to it.

For more information, see the CreateArchimedianSpiralPoints method’s implementation below.

using System;
using System.Windows;
using DevExpress.Xpf.Charts;

namespace ScatterLineChartWithCustomFunction {

    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
            CreateArchimedianSpiralPoints();
        }

        void CreateArchimedianSpiralPoints() {
            for (int i = 0; i < 720; i += 15) {
                double t = (double)i / 180 * Math.PI;
                double x = t * Math.Cos(t);
                double y = t * Math.Sin(t);
                ArchimedianSpiral.Points.Add(new SeriesPoint(x, y));
            }
        }
    }
}