2015/01/13

C#.Net 透過Chart繪製雷達圖


程式碼:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace Sample
{
    public partial class Form1 : Form
    {
        private Series _series = new Series();


        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //雷達圖
            _series.ChartType = SeriesChartType.Radar;


            for (int index = 1; index <= 4; index++)
            {
                //第n個點, 數值
                _series.Points.AddXY(index, index*100);

                //點的名稱
                _series.Points[index - 1].Label = index.ToString();
            }

            chart1.Series.Add(_series);
        }
    }
}

執行結果: