예제 #1
0
파일: Program.cs 프로젝트: nopcoder/rx
        public static Chart Pixels()
        {

            var path = Path.Combine(Environment.CurrentDirectory, "logo.png");
            var image = new Bitmap(path);

            var pixels = ColorPoint.Pixels(image);

            var copy = from pixel in pixels
                       let y = new System.Linq.Charting.Point.DataPoint(image.Height - pixel.Y) { Color = pixel.Color }
                       let x = pixel.X + 1
                       select KeyValuePair.Create(x, y);

            var pixelated = new System.Linq.Charting.Point 
                            { Points = { copy } 
                            };

            return new Chart { ChartAreas = { pixelated }, Dock = DockStyle.Fill };
        }
예제 #2
0
파일: Program.cs 프로젝트: nopcoder/rx
        public static Chart FuelEconomy()
        {
            #region
            Func<Car, double> Displacement = car => car.Displacement;
            Func<Car, int> Highway = car => car.Highway;
            Func<Car, int> Cylinders = car => car.Cylinders;
            #endregion

            var cars = Car.ParseFromFile();

            var data = from car in cars.GroupBy(Displacement).ThenBy(Highway, Cylinders)
                       from hwy in car from cylinder in hwy
                       select new
                       { X = car.Key
                       , Y = new System.Linq.Charting.Point.DataPoint(hwy.Key)
                           { Color = CylindersToColor(cylinder)
                           , MarkerSize = cylinder * 4
                           , ToolTip = string.Format("{0} cyclinders", cylinder)
                           }
                       };

            var series = new System.Linq.Charting.Point
            {
                Points = { data.Select(xy => KeyValuePair.Create(xy.X, xy.Y)) }
            };

            var area = new ChartArea
            { Series = { series }
            , AxisX = { Title = "Displacement" }
            , AxisY = { Title = "Highway mpg" }
            };

            return new Chart { ChartAreas = { area }, Dock = DockStyle.Fill };
        }