Example #1
0
        public void GetsData()
        {
            // Get the parent PipelineVM and add DiagramNode
            var vm   = MainViewModelTest.GetInstance().PipelineViewModel;
            var node = new NodeViewModel(new HistogramNode(), vm);

            vm.Nodes.Add(node);
            vm.Parent.Model.Graph.AddNode(node.Model);

            var hvm = new HistogramViewModel((HistogramNode)vm.Nodes.Single().Model);

            // Generates an array of 1 Frame with randomly filled Data
            var testSize = new Size(5, 5);

            Frame[] inputs = { new Frame(testSize) };
            for (var x = 0; x < testSize.Width; x++)
            {
                for (var y = 0; y < testSize.Height; y++)
                {
                    inputs[0][x, y] = new Rgb((byte)(x + y), (byte)(x + y), (byte)(x + y));
                }
            }

            hvm.NodeModel.Type = HistogramType.R;

            // porcess one frame with chosen type
            hvm.NodeModel.Process(inputs, 0);
            hvm.Handle(null);

            Assert.NotEmpty(hvm.Data.Data);
        }
Example #2
0
        public ActionResult Index()
        {
            var viewmodel = new HistogramViewModel();

            viewmodel.Filter = new RaceFilterViewModel();
            return(View(viewmodel));
        }
Example #3
0
        private HistogramViewModel CreateHistogramViewModel(RaceFilterViewModel filter)
        {
            var viewModel = new HistogramViewModel();

            viewModel.Filter = filter;
            var athletes = GetFilteredAthletes(GetAllAthletesForRaces(filter), filter);

            var calculator = new TriStatsCalculator(athletes);

            viewModel.SwimMedian   = calculator.TimeSpanMedian("Swim");
            viewModel.BikeMedian   = calculator.TimeSpanMedian("Bike");
            viewModel.RunMedian    = calculator.TimeSpanMedian("Run");
            viewModel.FinishMedian = calculator.TimeSpanMedian("Finish");

            viewModel.Triathletes = athletes;
            return(viewModel);
        }
Example #4
0
 public HistogramWindow(HistogramViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }
Example #5
0
        public ViewResult Histogram(int cityID)
        {
            User user = (User)Session["User"];
            City city = user.Cities.FirstOrDefault(x => x.CityID == cityID);
            IEnumerable <WeatherReading> weatherReadings = weatherRepository.WeatherReadings.Where(x => x.CityID == cityID);

            double[] temperatureDataKelwin = weatherReadings.Select(x => x.Temperature).ToArray();
            for (int i = 0; i < temperatureDataKelwin.Length; i++)
            {
                temperatureDataKelwin[i] = Math.Round(temperatureDataKelwin[i] - 273.15, 0);
            }

            object[] temperatureData = temperatureDataKelwin.Cast <object>().ToArray();
            object[] humidityData    = weatherReadings.Select(x => x.Humidity).Cast <object>().ToArray();
            string[] dates           = weatherReadings.Select(x => x.Date.ToString()).ToArray();

            Highcharts temperatureChart = new Highcharts("temperature")
                                          .InitChart(new Chart
            {
                Type         = ChartTypes.Line,
                MarginRight  = 130,
                MarginBottom = 25,
                ClassName    = "temperature"
            })
                                          .SetTitle(new Title {
                Text = "Temperatura (°C)", X = -20
            })
                                          .SetSubtitle(new Subtitle {
                Text = "Źródło danych pogodowych: openweathermap.org", X = -20
            })
                                          .SetXAxis(new XAxis {
                Categories = dates
            })
                                          .SetYAxis(new YAxis
            {
                Title = new YAxisTitle {
                    Text = "Temperatura (°C)"
                },
                PlotLines = new[] { new YAxisPlotLines {
                                        Value = 0, Width = 1, Color = ColorTranslator.FromHtml("#808080")
                                    } }
            })
                                          .SetTooltip(new Tooltip {
                Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y +'°C'; }"
            })
                                          .SetLegend(new Legend
            {
                Layout        = Layouts.Vertical,
                Align         = HorizontalAligns.Right,
                VerticalAlign = VerticalAligns.Top,
                X             = -10,
                Y             = 100,
                BorderWidth   = 0
            })
                                          .SetSeries(new[] { new Series {
                                                                 Name = city.Name, Data = new Data(temperatureData), Color = Color.FromArgb(217, 83, 79)
                                                             } }
                                                     );

            Highcharts humidityChart = new Highcharts("humidity")
                                       .InitChart(new Chart
            {
                Type         = ChartTypes.Line,
                MarginRight  = 130,
                MarginBottom = 25,
                ClassName    = "humidity"
            })
                                       .SetTitle(new Title {
                Text = "Wilgotność (%)", X = -20
            })
                                       .SetSubtitle(new Subtitle {
                Text = "Źródło danych pogodowych: openweathermap.org", X = -20
            })
                                       .SetXAxis(new XAxis {
                Categories = dates
            })
                                       .SetYAxis(new YAxis
            {
                Title = new YAxisTitle {
                    Text = "Wilgotność (%)"
                },
                PlotLines = new[] { new YAxisPlotLines {
                                        Value = 0, Width = 1, Color = ColorTranslator.FromHtml("#808080")
                                    } }
            })
                                       .SetTooltip(new Tooltip {
                Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y +'%'; }"
            })
                                       .SetLegend(new Legend
            {
                Layout        = Layouts.Vertical,
                Align         = HorizontalAligns.Right,
                VerticalAlign = VerticalAligns.Top,
                X             = -10,
                Y             = 100,
                BorderWidth   = 0
            })
                                       .SetSeries(new[] { new Series {
                                                              Name = city.Name, Data = new Data(humidityData), Color = Color.FromArgb(51, 122, 183)
                                                          } }
                                                  );

            HistogramViewModel model = new HistogramViewModel()
            {
                City             = city.Name,
                TemperatureChart = temperatureChart,
                HumidityChart    = humidityChart
            };

            return(View(model));
        }