Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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));
            }
        }
    }
}