将ChartType从Polar更改为Radar [英] Changing a ChartType from Polar to Radar
问题描述
我在
Polar
和雷达
图表看起来很相似,但它们确实是完全不同的。
您在 Polar
图表中看到,您可以通过设置相关的X轴属性来影响细分的数量。
最重要的是最大
和间隔
。
Radar
是不同:它基本上像一个索引图表。这意味着所有点都处于等距行(或圆形)中,完全忽略x值。
这意味着:
- 段数等于
XAxis.Maximum,-Minimum和-Interval
的值 $
DataPoints
/ code>被忽略。 - 没有两个
DataPoints
可以共享同一个点,即使它们的x值是
在您的示例中,您必须具有 25
数据点和最后相等。对于 Polar
图表,这些图表将位于相同位置,但对于雷达图表,它们位于旁边
让我克隆第一点并将其添加到最后:
s.Points.Add(s.Points.First()。Clone());
你可以看到它更好,如果你添加颜色的第一个和最后 DataPoint
:
s.Points.First()。Color = Color.Orange;
s.Points.Last()。Color = Colour.Red;
现在,您可以在 Polar
图表中的两个彩色数据点段: Radar
图表:
您还可以看到我已添加 12 + 1
到
图表
。第一个和最后一个在 Polar
图表中重合,但在 Radar
图表中彼此相邻。
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:
#region chartdesign
Series s = chartleft.Series[0]; // a reference to the default series
ChartArea ca = chartleft.ChartAreas[0]; // 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
s.Points.AddXY(0,0);
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[0]; // a reference to the default series
ChartArea ca2 = chartright.ChartAreas[0]; // 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:
s2.Points.AddXY(0, 0);
ax2.Interval = 15;
ay2.Interval = 1;
ax2.IntervalOffset = 0;
ax2.Minimum = 0;
ax2.Maximum = 360;
ay2.IntervalOffset = 0;
ay2.Minimum = 0;
ay2.Maximum = 10;
#endregion
Polar
and 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 Interval
.
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:
- The number of segments is equal to the number of
DataPoints
. - The values for
XAxis.Maximum, -Minimum and -Interval
are ignored. - No two
DataPoints
can 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:
s.Points.Add(s.Points.First().Clone());
You can see it even better if you add colors to the first and the last DataPoint
:
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 Radar
chart:
You can also see that I have added 12+1
DataPoints
to the Chart
. The first and last coincide in the Polar
chart but sit beside each other in the Radar
chart.
这篇关于将ChartType从Polar更改为Radar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!