Csharp chart极坐标标记线,举例说明,写出代码
时间: 2024-06-10 17:04:27 浏览: 121
CSharp写的代理服务器源代码功能强大支持http和socks5
好的,我知道你要问关于Csharp chart极坐标标记线的问题。以下是示例代码,供参考:
```csharp
//创建一个极坐标图表并添加数据
var chart1 = new Chart();
chart1.Width = 500;
chart1.Height = 500;
chart1.BackColor = Color.White;
Series series1 = new Series("Series1");
series1.ChartType = SeriesChartType.Polar;
series1.Points.Add(45);
series1.Points.Add(90);
series1.Points.Add(135);
series1.Points.Add(180);
series1.Points.Add(225);
series1.Points.Add(270);
series1.Points.Add(315);
series1.Points.Add(360);
chart1.Series.Add(series1);
//设置极坐标轴样式
chart1.ChartAreas[0].AxisX.IsReversed = false;
chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.LightGray;
chart1.ChartAreas[0].AxisX.MajorGrid.LineWidth = 1;
chart1.ChartAreas[0].AxisX.Interval = 45;
chart1.ChartAreas[0].AxisX.Minimum = 0;
chart1.ChartAreas[0].AxisX.Maximum = 360;
chart1.ChartAreas[0].AxisX.LabelStyle.Font = new Font("Calibri", 12, FontStyle.Regular);
chart1.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.Black;
chart1.ChartAreas[0].AxisY.Interval = 1;
chart1.ChartAreas[0].AxisY.Minimum = 0;
chart1.ChartAreas[0].AxisY.Maximum = 10;
chart1.ChartAreas[0].AxisY.LabelStyle.Enabled = false;
chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
//添加极坐标标记线
var marker1 = new AxisMarker(0, Color.Blue, 2);
marker1.AxisXType = AxisType.Primary;
marker1.AxisYType = AxisType.Primary;
marker1.IsSizeAlwaysRelative = true;
marker1.SizeType = MarkerSizeType.Percent;
chart1.ChartAreas[0].AxisX.Markers.Add(marker1);
var marker2 = new AxisMarker(90, Color.Red, 2);
marker2.AxisXType = AxisType.Primary;
marker2.AxisYType = AxisType.Primary;
marker2.IsSizeAlwaysRelative = true;
marker2.SizeType = MarkerSizeType.Percent;
chart1.ChartAreas[0].AxisX.Markers.Add(marker2);
var marker3 = new AxisMarker(180, Color.Green, 2);
marker3.AxisXType = AxisType.Primary;
marker3.AxisYType = AxisType.Primary;
marker3.IsSizeAlwaysRelative = true;
marker3.SizeType = MarkerSizeType.Percent;
chart1.ChartAreas[0].AxisX.Markers.Add(marker3);
var marker4 = new AxisMarker(270, Color.Orange, 2);
marker4.AxisXType = AxisType.Primary;
marker4.AxisYType = AxisType.Primary;
marker4.IsSizeAlwaysRelative = true;
marker4.SizeType = MarkerSizeType.Percent;
chart1.ChartAreas[0].AxisX.Markers.Add(marker4);
//显示图表
this.Controls.Add(chart1);
```
该代码创建了一个极坐标图表,添加了一组数据和四条标记线。标记线的长度和颜色可以按需更改。
阅读全文