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));
}
}
}
}
<Window x:Class="ScatterLineChartWithCustomFunction.MainWindow"
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"
Title="MainWindow" Height="350" Width="525">
<Grid>
<dxc:ChartControl>
<dxc:ChartControl.Diagram>
<dxc:XYDiagram2D>
<dxc:XYDiagram2D.Series>
<dxc:LineScatterSeries2D x:Name="ArchimedianSpiral" ArgumentScaleType="Numerical">
<dxc:LineScatterSeries2D.Label>
<dxc:SeriesLabel Visible="False" />
</dxc:LineScatterSeries2D.Label>
</dxc:LineScatterSeries2D>
</dxc:XYDiagram2D.Series>
<dxc:XYDiagram2D.AxisX>
<dxc:AxisX2D GridLinesVisible="True" />
</dxc:XYDiagram2D.AxisX>
<dxc:XYDiagram2D.AxisY>
<dxc:AxisY2D GridLinesMinorVisible="True" />
</dxc:XYDiagram2D.AxisY>
</dxc:XYDiagram2D>
</dxc:ChartControl.Diagram>
<dxc:ChartControl.Titles>
<dxc:Title Dock="Top" HorizontalAlignment="Center" Content="Archimedian Spiral Function" />
</dxc:ChartControl.Titles>
</dxc:ChartControl>
</Grid>
</Window>
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows
Imports DevExpress.Xpf.Charts
Namespace ScatterLineChartWithCustomFunction
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
CreateArchimedianSpiralPoints()
End Sub
Private Sub CreateArchimedianSpiralPoints()
For i As Integer = 0 To 719 Step 15
Dim t As Double = CDbl(i) / 180 * Math.PI
Dim x As Double = t * Math.Cos(t)
Dim y As Double = t * Math.Sin(t)
ArchimedianSpiral.Points.Add(New SeriesPoint(x, y))
Next i
End Sub
End Class
End Namespace