Scatter Polar Line Chart
- 7 minutes to read
The Scatter Polar Line chart uses the ScatterPolarLineSeriesView to visualize data. The Chart Control displays series points in the same order they were added to the collection without aggregation by arguments.
The following image shows a Scatter Polar Line Chart (the Archimedean spiral):
Chart Type Characteristics
The table below lists the main Scatter Polar Line chart characteristics:
Feature | Value |
---|---|
Series View type | ScatterPolarLineSeriesView |
Diagram type | 2D-PolarDiagram |
Number of arguments per series point | 1 |
Number of values per series point | 1 |
Note
- For information on which chart types can be combined with the Scatter Polar Line chart, refer to the Series Views Compatibility document.
- The axis scale types should be numeric continuous to display data correctly.
Create a Scatter Polar Line Chart at Runtime
Add Points Manually
The following example creates a Scatter Polar Line Chart at runtime:
Create an instance of the Chart Control class.
Create a Series and specify the Series.Name and ViewType in the series constructor. Populate the Series.Points collection with SeriesPoint objects and add this series to the ChartControl.Series collection.
Cast the ChartControl.Diagram property to the PolarDiagram. Use the PolarDiagram.StartAngleInDegrees and PolarDiagram.RotationDirection properties to specify the start angle and rotation direction for the radial axis.
Use the LegendBase.Visibility property to hide the chart’s legend.
Call the Titles.Add method to add a chart’s title to the ChartControl.Titles collection.
using DevExpress.XtraCharts;
using System;
using System.Windows.Forms;
using DevExpress.Utils;
namespace ScatterPolarLine {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
// Create a new chart.
ChartControl scatterPolarLineChart = new ChartControl();
// Add the chart to the form.
scatterPolarLineChart.Dock = DockStyle.Fill;
this.Controls.Add(scatterPolarLineChart);
// Create a scatter polar line series.
Series series1 = new Series("Series 1", ViewType.ScatterPolarLine);
// Add points to it.
series1.Points.Add(new SeriesPoint(0, 0.523598));
series1.Points.Add(new SeriesPoint(30, 0.523598));
series1.Points.Add(new SeriesPoint(60, 1.047197));
series1.Points.Add(new SeriesPoint(90, 1.570796));
series1.Points.Add(new SeriesPoint(120, 2.094395));
series1.Points.Add(new SeriesPoint(150, 2.617993));
series1.Points.Add(new SeriesPoint(180, 3.141592));
series1.Points.Add(new SeriesPoint(210, 3.665191));
series1.Points.Add(new SeriesPoint(240, 4.188790));
series1.Points.Add(new SeriesPoint(270, 4.712388));
series1.Points.Add(new SeriesPoint(300, 5.235987));
series1.Points.Add(new SeriesPoint(330, 5.759586));
series1.Points.Add(new SeriesPoint(0, 6.283185));
series1.Points.Add(new SeriesPoint(30, 6.806784));
series1.Points.Add(new SeriesPoint(60, 7.330382));
series1.Points.Add(new SeriesPoint(90, 7.853981));
series1.Points.Add(new SeriesPoint(120, 8.377580));
series1.Points.Add(new SeriesPoint(150, 8.901179));
series1.Points.Add(new SeriesPoint(180, 9.424777));
series1.Points.Add(new SeriesPoint(210, 9.948376));
series1.Points.Add(new SeriesPoint(240, 10.4719755));
series1.Points.Add(new SeriesPoint(270, 10.9955742));
series1.Points.Add(new SeriesPoint(300, 11.5191730));
series1.Points.Add(new SeriesPoint(330, 12.04277183));
series1.Points.Add(new SeriesPoint(0, 12.56637061));
// Add the series to the chart.
scatterPolarLineChart.Series.Add(series1);
// Flip the diagram (if necessary).
((PolarDiagram)scatterPolarLineChart.Diagram).StartAngleInDegrees = 180;
((PolarDiagram)scatterPolarLineChart.Diagram).RotationDirection =
RadarDiagramRotationDirection.Counterclockwise;
// Hide the legend (if necessary).
scatterPolarLineChart.Legend.Visibility = DefaultBoolean.False;
// Add a title to the chart (if necessary).
scatterPolarLineChart.Titles.Add(new ChartTitle());
scatterPolarLineChart.Titles[0].Text = "A Scatter Polar Line Chart";
}
}
}
Result:
Bind a Chart to a Data Source
The following example binds a Scatter Polar Line Chart to a data table:
Create an instance of the Chart Control class and specify the ChartControl.DataSource property. (See also: Series. Data Providing.)
Create a Series and specify the Series.Name and ViewType in the series constructor. Set the Series.ArgumentDataMember property to a data source field that contains series point arguments, and the Series.ValueDataMembers property - to a data source field that contains values. Add this series to the ChartControl.Series collection.
Cast the Series.View property to the ScatterPolarLineSeriesView and set the RadarLineSeriesView.MarkerVisibility property to false to hide markers. Set the ScatterPolarLineSeriesView.Closed property to false to hide the line that connects the first and last points. See the following section for more information about the chart appearance customization: Change Chart Appearance.
Use the LegendBase.Visibility property to hide the chart’s legend.
Call the Titles.Add method to add a chart’s title to the ChartControl.Titles collection.
private void Form1_Load(object sender, EventArgs e) {
// Create a new chart.
ChartControl scatterPolarLineChart = new ChartControl();
// Add the chart to the form.
scatterPolarLineChart.Dock = DockStyle.Fill;
this.Controls.Add(scatterPolarLineChart);
scatterPolarLineChart.DataSource = CreateChartData();
// Create a scatter polar line series.
Series series = new Series("Series 1", ViewType.ScatterPolarLine);
series.ArgumentDataMember = "Angle";
series.ValueDataMembers.AddRange(new string[] { "Distance" });
scatterPolarLineChart.Series.Add(series);
ScatterPolarLineSeriesView view = (ScatterPolarLineSeriesView)series.View;
// Hide markers.
view.MarkerVisibility = DefaultBoolean.False;
// Hide the line that connects the first and last point.
view.Closed = false;
// Hide the legend.
scatterPolarLineChart.Legend.Visibility = DefaultBoolean.False;
// Add a title to the chart.
scatterPolarLineChart.Titles.Add(new ChartTitle());
scatterPolarLineChart.Titles[0].Text = "Archimedean Spiral";
}
private DataTable CreateChartData() {
DataTable table = new DataTable("Table1");
table.Columns.Add("Angle", typeof(double));
table.Columns.Add("Distance", typeof(double));
double minAngle = 0;
double maxAngle = 720;
int intervalsCount = 72;
double angleStep = (maxAngle - minAngle) / (double)intervalsCount;
for (int pointIndex = 0; pointIndex <= intervalsCount; pointIndex++) {
double angle = minAngle + pointIndex * angleStep;
double angleRadians = angle * Math.PI / 180.0;
double distance = angleRadians;
double normalizeAngle = angle % 360;
table.Rows.Add(new object[] { normalizeAngle, distance });
}
return table;
}
Result:
Change Chart Appearance
The ScatterPolarLineSeriesView class exposes the following appearance settings for the Scatter Polar Line chart:
ScatterPolarLineSeriesView.Closed- Specifies whether the last point in a series is joined with the first point to form a closed polygon.
ScatterPolarLineSeriesView.Color - Gets or sets the series color.
- RadarLineSeriesView.MarkerVisibility - Specifies whether the series point markers are visible.
- ScatterPolarLineSeriesView.LineMarkerOptions - Contains series point marker settings.
- ScatterPolarLineSeriesView.LineStyle - Contains line style settings.
The code below changes the marker border color, line color and thickness, and displays the line shadow:
using DevExpress.Utils;
using System.Drawing;
//...
ScatterPolarLineSeriesView view = (ScatterPolarLineSeriesView)series1.View;
view.LineMarkerOptions.BorderColor = Color.DarkBlue;
view.LineStyle.Thickness = 3;
view.Color = Color.CornflowerBlue;
view.Shadow.Color = Color.LightGray;
view.Shadow.Visible = true;
view.Closed = false;
Tip
You can use tooltips to show additional information when a user hovers a series point. Note the Chart Control does not display Crosshair Cursor for polar and radar series.