예제 #1
0
        private void BtnColumnChart_Click(object sender, EventArgs e)
        {
            var categories = new[] { "Product A", "Product B", "Product C", "Product D", "Product E" };
            var rand       = new Random();
            var datasets   = new ColumnSeries[3];

            for (int i = 0; i < datasets.Length; i++)
            {
                var data = new float[categories.Length];
                for (int j = 0; j < categories.Length; j++)
                {
                    data[j] = rand.Next(30) - 10;
                }

                var dataset = new ColumnSeries
                {
                    Color = Color.FromArgb(rand.Next(0, 256), rand.Next(0, 256), rand.Next(0, 256)),
                    Data  = data
                };
                datasets[i] = dataset;
            }

            var chart = new ColumnChart
            {
                ColumnSize = 30,
                Width      = pictureBox1.Width,
                Height     = pictureBox1.Height,
                Categories = categories,
                DataSets   = datasets
            };

            pictureBox1.Image = chart.CreateImage();
            pictureBox1.Image.Save(@"D:\GitHub\SimpleImageCharts\screenshots\ColumnChart.jpg");
        }