Radar
Radar图就是雷达图,又叫做网络图或蛛网图,用来体现一个整体在3个或更多指标上的分项和整体强弱程度。
示例一
用一个雷达图显示某乒乓球运动员的六种能力强弱,代码:
Dim
nms()
As
String
= {"力量",
"速度",
"经验",
"防守",
"技术",
"发球"}
'能力名称
Dim
caps()
As
Integer
= {10, 9, 10, 9, 10, 8}
'能力值
Dim
Chart
As
WinForm.Chart = e.Form.Controls("Chart1")
'定义一个图表变量
Chart.ChartType = ChartTypeEnum.Radar
'雷达图
Chart.AxisY.Min = 0
'Y轴最小值为0
Chart.AxisY.Max = 10
'Y轴最大值为10
Chart.AxisY.Major = 2
'Y周主刻度为2
Chart.AxisY.MinorTick =
False
'Y轴不显示副刻度
Chart.AxisY.ForeColor = Color.SpringGreen
'设置Y轴颜色
Chart.ShowOutLine =
False
'去掉图表边框
Chart.Style.Border.BorderStyle = C1Chart.BorderStyleEnum.None
'去掉控件边框
Chart.ChartAreaStyle.Border.BorderStyle = C1Chart.BorderStyleEnum.None
'去掉图表区边框
Chart.PlotAreaStyle.BackColor = Color.FromArgb(90, Color.CadetBlue)
'设置绘制去北京
Chart.SeriesList.Clear()
'清除图表原来的图系
Dim
Series
As
WinForm.ChartSeries = Chart.SeriesList.Add()
'增加图系
Series.Length = caps.Length
'数据点个数
Series.LineColor = Color.Salmon
For
m
As
Integer
= 0
To
nms.Length - 1
'增加数据点
Series.X(m) = m
Series.Y(m) = caps(m)
Chart.AxisX.SetValueLabel(m, nms(m))
'设置字符表示
Next
Chart.AxisX.AnnoWithLabels =
True
'启用字符标示
生成的图表:
示例二
这次在一个图表中生成三个球员的能力雷达图,代码为:
Dim
caps()
As
String
= {"力量",
"速度",
"经验",
"防守",
"技术",
"发球"}
'六种能力
Dim
nms()
As
String
= {"马龙",
"王浩",
"马琳"}
Dim
cls()
As
Color = {Color.SeaGreen,Color.Navy, Color.Chocolate}
Dim
Chart
As
WinForm.Chart = e.Form.Controls("Chart1")
'定义一个图表变量
Chart.ChartType = ChartTypeEnum.Radar
'雷达图
Chart.SeriesList.Clear()
'清除图表原来的图系
Chart.AxisY.Min = 0
'Y轴最小值为0
Chart.AxisY.Max = 10
'Y轴最大值为10
Chart.AxisY.Major = 2
'Y周主刻度为2
Chart.AxisY.MinorTick =
False
'Y轴不显示副刻度
Chart.AxisY.ForeColor = Color.SpringGreen
'设置Y轴颜色
Chart.AxisX.ForeColor = Color.Green
'设置X轴颜色
Chart.PlotAreaStyle.BackColor = Color.GhostWhite
'绘制区背景颜色
Chart.Style.Border.BorderStyle = C1Chart.BorderStyleEnum.None
'去掉控件边框
Chart.ChartAreaStyle.Border.BorderStyle = C1Chart.BorderStyleEnum.None
'去掉图表区边框
Chart.LegendVisible =
True
'显示图例
Chart.LegendCompass = CompassEnum.South
'图例位置
For
n
As
Integer
= 0
To
nms.Length - 1
'每个选手生成一个图系
Dim
Series
As
WinForm.ChartSeries = Chart.SeriesList.Add()
'增加一个图系
Series.Text = nms(n)
'系列名为选手名
Series.Length = caps.Length
'数据点个数为能力个数
Series.LineColor = Color.FromArgb(90, cls(n))
For
m
As
Integer
= 0
To
caps.Length - 1
'增加数据点
Series.X(m) = m
Series.Y(m) = 6 + Rand.Next(0, 5)
Next
Next
For
m
As
Integer
= 0
To
caps.Length - 1
Chart.AxisX.SetValueLabel(m, Caps(m))
'设置X轴的字符表示
Next
Chart.AxisX.AnnoWithLabels =
True
'X轴启用字符标示
生成的图表为: