I asked in a previous question how to set a specific number of rings and sectors for a polar diagram . I now have a button which changes the chart from polar to radar. The problem is the number of segments changes from 24 (correct) to 25 (wrong). I have no idea why.
The code to set the number of rings:
Series s = chartleft.Series; // a reference to the default series
ChartArea ca = chartleft.ChartAreas; // a reference to the default chart area
Axis ax = ca.AxisX;
Axis ay = ca.AxisY;
s.ChartType = SeriesChartType.Polar; // set the charttype of the series
ax.Interval = 15;
ay.Interval = 1;
ax.IntervalOffset = 0;
ax.Minimum = 0;
ax.Maximum = 360;
ay.IntervalOffset = 0;
ay.Minimum = 0;
ay.Maximum = 10;
Series s2 = chartright.Series; // a reference to the default series
ChartArea ca2 = chartright.ChartAreas; // a reference to the default chart area
Axis ax2 = ca2.AxisX;
Axis ay2 = ca2.AxisY;
s2.ChartType = SeriesChartType.Polar; // set the charttype of the series
// a few data to test:
ax2.Interval = 15;
ay2.Interval = 1;
ax2.IntervalOffset = 0;
ax2.Minimum = 0;
ax2.Maximum = 360;
ay2.IntervalOffset = 0;
ay2.Minimum = 0;
ay2.Maximum = 10;
Radar charts look rather similar, but they really are quite different.
As you saw, in a
Polar chart you can influence the number of segments by setting the relevant X-Axis properties.
Most important are the
Maximum and the
Radar is different: It basically works like an indexed chart. This means that all points are sitting at equal distance in a row (or rather a circle) completely ignoring the x-values.
This means that:
XAxis.Maximum, -Minimum and -Intervalare ignored.
DataPointscan share the same spot, even if their x-values are the same.
In your example you must have
25 datapoints, probably the first and last being equal. For the
Polar chart these will sit at the same spot but for the Radar chart they sit beside each other, hence you see one more segment.
Let me clone the first point and add it to the end:
You can see it even better if you add colors to the first and the last
s.Points.First().Color = Color.Orange; s.Points.Last().Color = Color.Red;
Now you can see one colored line segment in the
Polar chart but two colored datapoint segments in the
You can also see that I have added
DataPoints to the
Chart. The first and last coincide in the
Polar chart but sit beside each other in the