コード例 #1
0
        public void InitializeChart()
        {
            if (CountryCovidResults != null)
            {
                confirmed   = new List <double>();
                deaths      = new List <double>();
                deathsTotal = new List <double>();
                dates       = new List <string>();
                var previousresult = new CountryCovidResult()
                {
                    Cases = 0, Recovered = 0, Deaths = 0, Confirmed = 0
                };
                foreach (var result in CountryCovidResults)
                {
                    dates.Add(result.Date.ToString("dd/MM/yy"));
                    confirmed.Add(result.Confirmed - previousresult.Confirmed);
                    deaths.Add(result.Deaths - previousresult.Deaths);
                    previousresult = result;
                }

                deathsTotal = CountryCovidResults.Select(c => (double)c.Deaths).ToList();
                RefreshChart();
                XCollection[0].ShowLabels     = true;
                XCollection[0].Title          = "Dates";
                XCollection[0].Labels         = dates;
                XCollection[0].LabelsRotation = 40;
                XCollection[0].Separator      = new Separator // force the separator step to 1, so it always display all labels
                {
                    Step      = dates.Count / 27,
                    IsEnabled = false //disable it to make it invisible.
                };
            }
        }
コード例 #2
0
        public void InitializeChart()
        {
            if (CountryCovidResults != null)
            {
                var confirmed      = new List <double>();
                var deaths         = new List <double>();
                var deathsTotal    = new List <double>();
                var dates          = new List <string>();
                var previousresult = new CountryCovidResult()
                {
                    Cases = 0, Recovered = 0, Deaths = 0, Confirmed = 0
                };
                foreach (var result in CountryCovidResults)
                {
                    dates.Add(result.Date.ToString("dd/MM/yy"));
                    confirmed.Add(result.Confirmed - previousresult.Confirmed);
                    deaths.Add(result.Deaths - previousresult.Deaths);
                    previousresult = result;
                }

                deathsTotal      = CountryCovidResults.Select(c => (double)c.Deaths).ToList();
                SeriesCollection = new SeriesCollection
                {
                    new LineSeries
                    {
                        Values        = new ChartValues <double>(confirmed),
                        Title         = "Cases",
                        PointGeometry = null,
                        Visibility    = CasesSeriesVisibility ? Visibility.Visible : Visibility.Collapsed
                    },
                    new LineSeries
                    {
                        Values        = new ChartValues <double>(deaths),
                        Title         = "Deaths",
                        PointGeometry = null,
                        Visibility    = DeathsSeriesVisibility ? Visibility.Visible : Visibility.Collapsed
                    },
                    //new LineSeries
                    //{
                    //    Values = new ChartValues<double>(recovered),
                    //    Title = "Recovered"

                    //}
                    new LineSeries
                    {
                        Values        = new ChartValues <double>(deathsTotal),
                        Title         = "Total Deaths",
                        PointGeometry = null,
                        Visibility    = TotalDeathsSeriesVisibility ? Visibility.Visible : Visibility.Collapsed
                    }
                    // new LineSeries
                    // {
                    //     Values = new ChartValues<double>(recoveredTotal),
                    //     Title = "Total Recovered"

                    // }
                };
                XCollection[0].ShowLabels     = true;
                XCollection[0].Title          = "Dates";
                XCollection[0].Labels         = dates;
                XCollection[0].LabelsRotation = 40;
                XCollection[0].Separator      = new Separator // force the separator step to 1, so it always display all labels
                {
                    Step      = dates.Count / 27,
                    IsEnabled = false //disable it to make it invisible.
                };
            }
        }