コード例 #1
0
ファイル: Form1.cs プロジェクト: weinre/SimpleImageCharts
        private void BtnBarChart_Click(object sender, EventArgs e)
        {
            var chart = new BarChart
            {
                Width      = pictureBox1.Width,
                Height     = pictureBox1.Height,
                Categories = new[] { "Product A", "Product B", "Product C" },
                DataSets   = new[]
                {
                    new BarSeries
                    {
                        Label = "LightBlue",
                        Color = Color.LightBlue,
                        Data  = new[] { -5f, 10f, 15f },
                    },
                    new BarSeries
                    {
                        Label = "LightCoral",
                        Color = Color.LightCoral,
                        Data  = new[] { 1f, -2f, 3f },
                    }
                    ,
                    new BarSeries
                    {
                        Label = "LightGreen",
                        Color = Color.LightGreen,
                        Data  = new[] { 5f, 20f, -13f },
                    }
                }
            };

            pictureBox1.Image = chart.CreateImage();
            pictureBox1.Image.Save(@"D:\GitHub\SimpleImageCharts\screenshots\BarChart.jpg");
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: weinre/SimpleImageCharts
        private void BtnStackedBar_Click(object sender, EventArgs e)
        {
            var chart = new BarChart
            {
                Width           = pictureBox1.Width,
                Height          = pictureBox1.Height,
                IsStacked       = true,
                FormatAxisValue = "{0:0;0}", // force positive values
                FormatBarValue  = "{0:0;0}",
                Categories      = new[] { "Product A", "Product B", "Product C", "Product A", "Product B", "Product C", "Product A", "Product B", "Product C" },
                DataSets        = new[]
                {
                    new BarSeries
                    {
                        Label = "Yesterday",
                        Color = Color.LightBlue,
                        Data  = new[] { -5f, -10f, -1f, -5f, -10f, -1f, -5f, -10f, -1f },
                    },
                    new BarSeries
                    {
                        Label = "Today",
                        Color = Color.LightCoral,
                        Data  = new[] { 10f, 20f, 5f, 10f, 20f, 5f, 10f, 20f, 5f },
                    }
                }
            };

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