Example #1
0
        private void codeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string        connectionString;
            SqlConnection cnn;

            connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Айдын\source\repos\UXCountryWorld\UXCountryWorld\LocalDBWorldCountry.mdf;Integrated Security=True";

            cnn = new SqlConnection(connectionString);


            string        sql = "select * from Country where Code = '" + codeComboBox.Text + "';";
            SqlCommand    cmd = new SqlCommand(sql, cnn);
            SqlDataReader myreader;

            try
            {
                cnn.Open();
                myreader = cmd.ExecuteReader();
                while (myreader.Read())
                {
                    string name       = myreader.GetString(1);
                    string capital    = myreader.GetString(3);
                    string population = myreader.GetInt64(4).ToString();
                    string regionID   = myreader.GetInt32(5).ToString();
                    string code       = myreader.GetString(2);
                    nameTextBox.Text       = name;
                    capitalTextBox.Text    = capital;
                    populationTextBox.Text = population;
                    PopulationByYear.GetCSV(code);
                    var records = PopulationByYear.Countries.ToArray();
                    Results = records.AsChartValues();
                    Labels  = records.Select(x => x.Year).ToList();

                    cartesianChartCountryPopulation.Series = new SeriesCollection
                    {
                        new LineSeries
                        {
                            Configuration = mapper,
                            Values        = Results
                        }
                    };
                    cartesianChartCountryPopulation.AxisY = new AxesCollection();
                    cartesianChartCountryPopulation.AxisX = new AxesCollection();
                    cartesianChartCountryPopulation.AxisY.Add(new Axis
                    {
                        LabelFormatter = value => (value / 1000000).ToString("N") + "M"
                    });
                    cartesianChartCountryPopulation.AxisX.Add(new Axis
                    {
                        Labels            = Labels,
                        DisableAnimations = true,
                        LabelsRotation    = 20
                    });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        public CountryData()
        {
            InitializeComponent();
            fillComboBox();


            mapper = Mappers.Xy <PopulationOfCountry>()
                     .X((population, index) => index)
                     .Y(population => population.CountryPopulation);
            PopulationByYear.GetCSV("CZ");

            var records = PopulationByYear.Countries.ToArray();

            Results = records.AsChartValues();
            Labels  = records.Select(x => x.Year).ToList();

            cartesianChartCountryPopulation.Series = new SeriesCollection
            {
                new LineSeries
                {
                    Configuration = mapper,
                    Values        = Results
                }
            };

            cartesianChartCountryPopulation.AxisY.Add(new Axis
            {
                LabelFormatter = value => (value / 1000000).ToString("N") + "M"
            });
            cartesianChartCountryPopulation.AxisX.Add(new Axis
            {
                Labels            = Labels,
                DisableAnimations = true,
                LabelsRotation    = 20
            });
        }