Esempio n. 1
0
        /// <summary>
        /// Shows the Area Chart from Pressure Sea Level forecast.
        /// </summary>
        /// <param name="weather"> Weather info</param>
        private void SeaLevelForecast(ActualWeather weather)
        {
            var tChart1 = new Chart();

            tChart1.Zoom.Active    = false;
            tChart1.Aspect.View3D  = false;
            tChart1.Legend.Visible = false;
            tChart1.Panning.Allow  = ScrollModes.None;
            tChart1.Header.Text    = "Sea Level of " + App.Weather.Name;

            var seaLevel = new Area(tChart1);

            foreach (var item in weather.LstWeather)
            {
                seaLevel.Add(item.Date, item.SeaLevel);
            }

            seaLevel.Legend.Visible       = true;
            seaLevel.Color                = Color.FromRgb(27, 177, 255); //  FromHex("#084B8A");
            seaLevel.Stairs               = false;
            seaLevel.LinePen.Visible      = false;
            seaLevel.AreaLinesPen.Visible = false;

            AxisSettings(tChart1);
            TitleSettings(tChart1);

            tChart1.Axes.Left.Increment = 4;

            ShowChart(tChart1);
        }
Esempio n. 2
0
        public Visualization(object sender, ActualWeather actuWeather)
        {
            InitializeComponent();

            MenuItemType selectedItem = (MenuItemType)sender;

            weather = actuWeather;
            InitializeChart(selectedItem);
        }
Esempio n. 3
0
        /// <summary>
        /// Shows the Line3D Chart from Minimum Temperature forecast.
        /// </summary>
        /// <param name="weather"> Weather info</param>
        private void MinTemperatureForecast(ActualWeather weather)
        {
            var tChart1 = new Chart();

            tChart1.Header.Text                       = "Min Temperature of " + App.Weather.Name;
            tChart1.Legend.Visible                    = true;
            tChart1.Legend.Alignment                  = LegendAlignments.Bottom;
            tChart1.Legend.LegendStyle                = LegendStyles.Series;
            tChart1.Legend.Transparent                = true;
            tChart1.Aspect.View3D                     = false;
            tChart1.Axes.Bottom.Labels.Angle          = 90;
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MMM";

            var minTemp = new Line(tChart1.Chart);

            minTemp.Marks.Visible = false;
            double max = App.getDegScaleTemp(weather.LstWeather[0].MinTemperature);
            double min = App.getDegScaleTemp(weather.LstWeather[0].MinTemperature);

            minTemp.LinePen.Width       = 3;
            minTemp.Pointer.Visible     = true;
            minTemp.Pointer.HorizSize   = 3;
            minTemp.Pointer.VertSize    = 3;
            minTemp.Pointer.Style       = PointerStyles.Sphere;
            minTemp.Pointer.Pen.Visible = false;
            minTemp.LinePen.Color       = Color.FromRgb(27, 177, 255);
            minTemp.Color           = Color.FromRgb(27, 177, 255);
            minTemp.Title           = "Min Temperature";
            minTemp.Marks.Visible   = true;
            minTemp.Marks.DrawEvery = 4;

            AxisSettings(tChart1);
            TitleSettings(tChart1);
            //SeriesMarksSettings(minTemp);

            foreach (var item in weather.LstWeather)
            {
                if (App.getDegScaleTemp(item.MinTemperature) > max)
                {
                    max = App.getDegScaleTemp(item.MinTemperature);
                }
                if (App.getDegScaleTemp(item.MinTemperature) < min)
                {
                    min = App.getDegScaleTemp(item.MinTemperature);
                }
                minTemp.Add(item.Date, App.getDegScaleTemp(item.MinTemperature));
            }

            //tChart1.Axes.Left.SetMinMax((int)min - 5, (int)max + 5);
            tChart1.Axes.Bottom.Increment    = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneDay);
            tChart1.Axes.Bottom.Grid.Visible = false;
            tChart1.Axes.Left.Increment      = 4;
            tChart1.Legend.Font.Color        = Color.FromRgb(100, 100, 100);

            ShowChart(tChart1);
        }
Esempio n. 4
0
        /// <summary>
        /// Shows the Line Chart from Temperature forecast.
        /// </summary>
        /// <param name="weather"> Weather info</param>
        private void TemperatureForecast(ActualWeather weather)
        {
            try
            {
                var tChart1 = new Chart();

                tChart1.Axes.Bottom.Labels.Angle          = 90;
                tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MMM";
                tChart1.Axes.Bottom.Increment             = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneDay);
                tChart1.Axes.Left.Title.Text = "Temperature (" + (App.DegTempScale == TempScale.celsius ? "ºC" : "ºF") + ")";

                tChart1.Header.Text      = "Average temperature of " + App.Weather.Name;
                tChart1.Header.Alignment = TextAlignment.Center;
                tChart1.Header.TextAlign = TextAlignment.Center;

                double min = App.getDegScaleTemp(weather.LstWeather[0].MinTemperature);
                double max = App.getDegScaleTemp(weather.LstWeather[0].MaxTemperature);

                var avTemp = new Line(tChart1);
                foreach (var item in weather.LstWeather)
                {
                    if (App.getDegScaleTemp(item.MaxTemperature) > max)
                    {
                        max = App.getDegScaleTemp(item.MaxTemperature);
                    }
                    if (App.getDegScaleTemp(item.MinTemperature) < min)
                    {
                        min = App.getDegScaleTemp(item.MinTemperature);
                    }
                    avTemp.Add(item.Date, App.getDegScaleTemp(item.Temperature));
                }

                tChart1.Axes.Left.SetMinMax((int)min - 3, (int)max + 3);
                tChart1.Axes.Bottom.SetMinMax(tChart1.Axes.Bottom.MinXValue + 0.5, tChart1.Axes.Bottom.MaxXValue - 0.5);

                AxisSettings(tChart1);
                TitleSettings(tChart1);
                //SeriesMarksSettings(avTemp);

                ShowChart(tChart1);

                avTemp.Legend.Visible  = false;
                avTemp.LinePen.Width   = 3;
                avTemp.LinePen.EndCap  = Steema.TeeChart.Drawing.PenLineCap.Round;
                avTemp.Color           = Color.FromRgb(27, 177, 255);
                avTemp.Marks.Visible   = true;
                avTemp.Marks.DrawEvery = 4;
                tChart1.Series.Add(avTemp);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
        }
        public static async Task <ActualWeather> GetCoordinate(string latitude, string longitude)
        {
            string  key         = "c8a760683089adad086eef5d6a85e5a3";
            string  queryString = String.Format("http://api.openweathermap.org/data/2.5/forecast?lat={0}&lon={1}&units=metric&APPID={2}", latitude, longitude, key);
            dynamic results     = await DataService.getDataFromService(queryString);

            if (results.cod != 502)
            {
                try
                {
                    List <WeatherData> lstWeather = new List <WeatherData>();
                    foreach (var item in results.list)
                    {
                        WeatherData weather = new WeatherData(
                            (double)item.main.temp,
                            (double)item.main.temp_max,
                            (double)item.main.temp_min,
                            (double)item.wind.speed,
                            (double)item.wind.deg,
                            (double)item.main.pressure,
                            (double)item.main.humidity,
                            (double)item.main.sea_level,
                            (double)item.main.grnd_level,
                            (string)item.weather[0].main,
                            (string)item.weather[0].description,
                            (string)"http://openweathermap.org/img/w/" + item.weather[0].icon + ".png",
                            (DateTime)item.dt_txt);
                        lstWeather.Add(weather);
                    }

                    ActualWeather actuWeather = new ActualWeather(
                        (string)DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss"),
                        (string)results.city.name,
                        (string)results.city.country,
                        (double)results.city.coord.lat,
                        (double)results.city.coord.lon,
                        lstWeather
                        );
                    return(actuWeather);
                }
                catch
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// That void saves into the physical devices, the Weather item that we created with the api's server info
        /// </summary>
        /// <param name="folder">Name of the folder where we want to save the file</param>
        /// <param name="weather">Weather info that we want to save</param>
        /// <param name="fileName">The name that the file will have. </param>
        public static async void SerializeWeather(string folder, ActualWeather weather, string fileName)
        {
            try
            {
                IFolder rootFolder     = FileSystem.Current.LocalStorage;
                IFolder resourceFolder = await rootFolder.CreateFolderAsync(folder, CreationCollisionOption.OpenIfExists);

                IFile file = await resourceFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);

                var companiesString = JsonConvert.SerializeObject(weather, Formatting.Indented);
                await file.WriteAllTextAsync(companiesString);
            }
            catch
            {
            }
        }
        /// <summary>
        /// Get the weather info, from a file that we have on the physical device.
        /// </summary>
        /// <param name="city">name of the city where we search the info, also is the filename.</param>
        /// <param name="folder">folder where we have the files with the info</param>
        /// <returns>An object from ActualWeather class, whith the actual weather and the forecast of 5 days</returns>
        public static async Task <ActualWeather> GetStoredWeather(string city, string folder)
        {
            dynamic results = await DataService.ReadWeatherFromFile(city, folder);

            if (results != null)
            {
                try
                {
                    ActualWeather actuWeather = results;
                    return(actuWeather);
                }
                catch
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Shows the HorizontalBar Chart from Humidity forecast.
        /// </summary>
        /// <param name="weather"> Weather info</param>
        private void HumidityForecast(ActualWeather weather)
        {
            var tChart1 = new Chart();

            tChart1.Axes.Left.Increment = Steema.TeeChart.Utils.GetDateTimeStep(DateTimeSteps.OneDay);
            tChart1.Aspect.View3D       = false;
            tChart1.Legend.Visible      = false;
            tChart1.Header.Text         = "Humidity of " + App.Weather.Name;

            var humidity = new HorizBar(tChart1);

            humidity.Marks.AutoPosition = true;
            humidity.Marks.Transparent  = true;
            humidity.MarksLocation      = MarksLocation.End;
            humidity.Marks.Font.Size    = 11;
            humidity.Marks.Style        = MarksStyles.Value;
            humidity.Marks.Arrow.Color  = Color.Transparent;
            humidity.Marks.DrawEvery    = 2;

            double max = weather.LstWeather[0].Humidity;

            foreach (var item in weather.LstWeather)
            {
                if (item.Humidity > max)
                {
                    max = item.Humidity;
                }
                humidity.Add(item.Humidity, item.Date);
            }

            tChart1.Legend.Visible = false;
            tChart1.Axes.Bottom.SetMinMax(0, max + 20);
            humidity.Color = Color.FromRgb(27, 177, 255);

            AxisSettings(tChart1);
            TitleSettings(tChart1);
            tChart1.Header.Visible = true;

            ShowChart(tChart1);
        }
Esempio n. 9
0
        //private RealTimeLine windSpeed2;
        /// <summary>
        /// Shows the Circular Gauge Chart from Wind Speed forecast.
        /// </summary>
        /// <param name="weather"> Weather info</param>
        private async Task WindSpeedForecastAsync(ActualWeather weather)
        {
            Grid grid = new Grid
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = 5,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    //new RowDefinition { Height = new GridLength(0.5, GridUnitType.Star) },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            windSpeed = new DashBoard.CircularGaugeChart(weather);
            //windSpeed2 = new RealTimeLine();
            grid.Children.Add(windSpeed.chartView, 0, 0);
            //grid.Children.Add(windSpeed2.chartView, 0, 1);
            Content = grid;

            windSpeed.chartView.Chart.Header.Font.Size = 15;
            //windSpeed2.chartView.Chart.Header.Font.Size = 15;
            windSpeed.chartView.Chart.Header.Font.Color = Color.White;
            //windSpeed2.chartView.Chart.Header.Font.Color = Color.White;
            windSpeed.chartView.Chart.SubHeader.Visible    = true;
            windSpeed.chartView.Chart.SubHeader.Font.Color = Color.White;
            windSpeed.chartView.Chart.SubHeader.Alignment  = TextAlignment.End;
            windSpeed.chartView.Chart.SubHeader.Font.Size += 4;
        }
Esempio n. 10
0
        /// <summary>
        /// Shows the Surface Chart from Pressure Ground Level forecast.
        /// </summary>
        /// <param name="weather"> Weather info</param>
        private void GroundLevelForecast(ActualWeather weather)
        {
            var tChart1 = new Chart();

            tChart1.Axes.Left.Title.Text   = "Hours";
            tChart1.Axes.Bottom.Title.Text = "Days";
            tChart1.Legend.Visible         = false;
            tChart1.Panning.Allow          = ScrollModes.None;
            tChart1.Header.Text            = "Ground Level of " + App.Weather.Name;
            double min = weather.LstWeather[0].GroundLevel;
            double max = weather.LstWeather[0].GroundLevel;

            var groundLevel = new ColorGrid(tChart1);

            groundLevel.FillSampleValues();

            groundLevel.IrregularGrid = true;

            foreach (var item in weather.LstWeather)
            {
                Debug.WriteLine(item.Date.Day + ";" + item.GroundLevel + ";" + item.Date.Hour);
                groundLevel.Add(item.Date.Day, item.GroundLevel, item.Date.Hour);
            }

            groundLevel.StartColor = Color.FromHex("#F2B551");
            groundLevel.EndColor   = Color.FromHex("#ED8256");
            groundLevel.MidColor   = Color.FromHex("#ED8256");
            //tChart1.AfterDraw += new PaintChartEventHandler(this.tChart1_AfterDraw);
            groundLevel.Marks.Visible = false;

            AxisSettings(tChart1);
            TitleSettings(tChart1);
            SeriesMarksSettings(groundLevel);

            ShowChart(tChart1);
        }
Esempio n. 11
0
        /// <summary>
        /// Shows the Historigram Chart from Maximum Temperature forecast.
        /// </summary>
        /// <param name="weather"> Weather info</param>
        private void MaxTemperatureForecast(ActualWeather weather)
        {
            var tChart1 = new Chart();

            tChart1.Aspect.View3D                     = false;
            tChart1.Legend.Visible                    = false;
            tChart1.Axes.Bottom.Labels.Angle          = 90;
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MMM";
            tChart1.Header.Text = "Min/Max Temperature of " + App.Weather.Name;
            var maxTemp = new Histogram(tChart1.Chart);
            var highlow = new HighLow(tChart1.Chart);

            //maxTemp.LinesPen.Visible = false;
            maxTemp.Color                   = Color.FromRgb(27, 177, 255);
            maxTemp.LinePen.Color           = Color.FromRgb(27, 177, 255);
            maxTemp.LinePen.Width           = 20;
            maxTemp.LinesPen.Width          = 20;
            maxTemp.LinesPen.Visible        = true;
            maxTemp.LinePen.Visible         = true;
            maxTemp.LinesPen.Color          = Color.FromRgb(27, 177, 255);
            highlow.HighPen.Width           = 4;
            highlow.LowPen.Width            = 4;
            highlow.HighPen.DashCap         = Steema.TeeChart.Drawing.PenLineCap.Round;
            highlow.HighPen.EndCap          = Steema.TeeChart.Drawing.PenLineCap.Round;
            highlow.HighPen.Style           = Steema.TeeChart.Drawing.DashStyle.Solid;
            highlow.LowPen.DashCap          = Steema.TeeChart.Drawing.PenLineCap.Round;
            highlow.LowPen.EndCap           = Steema.TeeChart.Drawing.PenLineCap.Round;
            highlow.LowPen.Style            = Steema.TeeChart.Drawing.DashStyle.Solid;
            highlow.Marks.Visible           = true;
            highlow.Marks.DrawEvery         = 3;
            highlow.Marks.FollowSeriesColor = true;
            highlow.HighPen.Color           = Color.FromRgb(223, 5, 0);
            highlow.LowPen.Color            = Color.FromRgb(240, 186, 0);
            highlow.Pen.Visible             = false;

            double max = App.getDegScaleTemp(weather.LstWeather[0].MaxTemperature);
            double min = App.getDegScaleTemp(weather.LstWeather[0].MaxTemperature);

            foreach (var item in weather.LstWeather)
            {
                if (App.getDegScaleTemp(item.MaxTemperature) > max)
                {
                    max = App.getDegScaleTemp(item.MaxTemperature);
                }
                if (App.getDegScaleTemp(item.MaxTemperature) < min)
                {
                    min = App.getDegScaleTemp(item.MinTemperature);
                }
                maxTemp.Add(item.Date, App.getDegScaleTemp(item.MaxTemperature));
                highlow.Add(maxTemp.XValues.Last, item.MaxTemperature, item.MinTemperature);
            }
            maxTemp.Marks.AutoPosition = true;
            maxTemp.Marks.Transparent  = true;
            tChart1.Axes.Left.SetMinMax((int)min - 3, (int)max + 4);

            tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneDay);
            tChart1.Axes.Bottom.SetMinMax(tChart1.Axes.Bottom.MinXValue + 0.5, tChart1.Axes.Bottom.MaxXValue - 0.5);
            AxisSettings(tChart1);
            TitleSettings(tChart1);
            //SeriesMarksSettings(maxTemp);
            tChart1.Axes.Left.Increment = 4;

            ShowChart(tChart1);
        }