Exemple #1
0
        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 };
        }
Exemple #2
0
        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 };
        }