2015/01/13

C#.Net 透過Chart繪製FastLine

程式碼:
using System;
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[] { new Series(), new Series() };

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //雷達圖
            foreach (Series s in _series)
            {
                s.ChartType = SeriesChartType.FastLine;
                chart1.Series.Add(s);
            }


            Parallel.For(0, 10095, index =>
            {
                  chart1.Invoke(new MethodInvoker(delegate()
                {
                    _series[0].Points.AddXY(index, index*2.3);
                    _series[1].Points.AddXY(index, index*5);
                }));
            });
          
          
           
        }
    }
}

執行結果: