C# 显示图表数据实例

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Windows.Forms;
 9 using System.Windows.Forms.DataVisualization.Charting;
10 
11 namespace WindowsFormsApplication8
12 {
13     public partial class Form1 : Form
14     {
15         public Form1()
16         {
17             InitializeComponent();
18         }
19 
20         private void Form1_Load(object sender, EventArgs e)
21         {
22             //清除默认的series
23             chart1.Series.Clear();
24             //new 一个叫做【Strength】的系列
25             Series Strength = new Series("力量");
26             Series test = new Series("耐力");
27             test.ChartType = SeriesChartType.Radar;
28             //设置chart的类型,这里为柱状图
29             Strength.ChartType = SeriesChartType.Radar;
30             //给系列上的点进行赋值,分别对应横坐标和纵坐标的值
31             Strength.Points.AddXY("A", "90");
32             Strength.Points.AddXY("B", "88");
33             Strength.Points.AddXY("C", "60");
34             Strength.Points.AddXY("D", "93");
35             Strength.Points.AddXY("E", "79");
36             Strength.Points.AddXY("F", "85");
37             test.Points.AddXY("A", "20");
38             test.Points.AddXY("B", "20");
39             test.Points.AddXY("C", "50");
40             test.Points.AddXY("D", "99");
41             test.Points.AddXY("E", "50");
42             test.Points.AddXY("F", "89");
43 
44             chart1.Series.Add(Strength);
45             chart1.Series.Add(test);
46 
47         }
48     }
49 }

 

posted @ 2019-05-17 16:03  星空沃土  阅读(2057)  评论(0编辑  收藏  举报