예제 #1
0
        void SetCharts()
        {
            ChartValues <double> standardDeviationChart = new LiveCharts.ChartValues <double>();
            ChartValues <double> mediaChart             = new LiveCharts.ChartValues <double>();
            ChartValues <double> bestValueChart         = new LiveCharts.ChartValues <double>();
            ChartValues <double> worstValueChart        = new LiveCharts.ChartValues <double>();

            foreach (var item in population.Generations)
            {
                standardDeviationChart.Add(item.StandardDeviation);
                mediaChart.Add(item.Media);
                bestValueChart.Add(item.BetterSubject.FitnessValue);
                worstValueChart.Add(item.WorstSubject.FitnessValue);
            }

            SeriesCollection standardDeviationSeries = new SeriesCollection
            {
                new LineSeries
                {
                    Values = standardDeviationChart
                }
            };
            SeriesCollection mediaSeries = new SeriesCollection
            {
                new LineSeries
                {
                    Values = mediaChart
                }
            };
            SeriesCollection bestValueSeries = new SeriesCollection
            {
                new LineSeries
                {
                    Values = bestValueChart
                }
            };
            SeriesCollection worstValueSeries = new SeriesCollection
            {
                new LineSeries
                {
                    Values = worstValueChart
                }
            };

            StandarDeviationChart.Series = standardDeviationSeries;
            MediaChart.Series            = mediaSeries;
            BestValueChart.Series        = bestValueSeries;
            WorstValueChart.Series       = worstValueSeries;
        }
예제 #2
0
        void SetCharts()
        {
            ChartValues <double> generationNumberChart  = new LiveCharts.ChartValues <double>();
            ChartValues <double> evaluationNumberChart  = new LiveCharts.ChartValues <double>();
            ChartValues <double> bestByGenerationChart  = new LiveCharts.ChartValues <double>();
            ChartValues <double> worstByGenerationChart = new LiveCharts.ChartValues <double>();

            for (int i = 0; i < populations.Count; i++)
            {
                generationNumberChart.Add(populations[i].CurrentGeneration);
                evaluationNumberChart.Add(populations[i].CurrentEvaluation);
                bestByGenerationChart.Add(populations[i].Generations.Last().BetterSubject.FitnessValue);
                worstByGenerationChart.Add(populations[i].Generations.Last().WorstSubject.FitnessValue);
            }

            SeriesCollection generationNumberSeries = new SeriesCollection
            {
                new LineSeries
                {
                    Values = generationNumberChart
                }
            };
            SeriesCollection evaluationNumberSeries = new SeriesCollection
            {
                new LineSeries
                {
                    Values = evaluationNumberChart
                }
            };
            SeriesCollection bestByGenerationSeries = new SeriesCollection
            {
                new LineSeries
                {
                    Values = bestByGenerationChart
                }
            };
            SeriesCollection worstByGenerationSeries = new SeriesCollection
            {
                new LineSeries
                {
                    Values = worstByGenerationChart
                }
            };

            GenerationNumberChart.Series  = generationNumberSeries;
            EvaluationNumberChart.Series  = evaluationNumberSeries;
            BestByGenerationChart.Series  = bestByGenerationSeries;
            WorstByGenerationChart.Series = worstByGenerationSeries;
        }
예제 #3
0
        public void GraphConsumption(int a_min, string codeText, List <string> a_dateConsumption, List <decimal> a_consumptionList)
        {
            if (a_consumptionList.Count() != 0)
            {
                LabelsX = new List <string>(a_dateConsumption.AsEnumerable());
                MaxY    = a_consumptionList.Max() + 2;
                MinY    = a_min;

                MaxX = a_dateConsumption.Count() - 1;
                MinX = a_dateConsumption.Count() - 16;

                Series = new LiveCharts.ChartValues <decimal>(a_consumptionList.AsEnumerable());
                Title  = ManageLanguage.GetLanguageString(codeText, ManageLanguage.LanguageSelected);

                var mapper1 = new CartesianMapper <double>()
                              .X((value, index) => index)  //use the index as X
                              .Y((value, index) => value); //use the value as Y
                LiveCharts.Charting.For <double>(mapper1, SeriesOrientation.Horizontal);
            }
        }
        private void btn_DownloadData_Click(object sender, EventArgs e)
        {
            dates.Clear();
            openingPrices.Clear();
            closingPrices.Clear();
            volumes.Clear();


            dataChart.Series["Open"].Points.Clear();
            dataChart.Series["Close"].Points.Clear();
            dataChart.Series["Volume"].Points.Clear();

            cartesianChart.Series.Clear();

            string companyTag = textBox_CompanyTag.Text.ToString().ToLower();
            string startDate  = date_Start.Value.ToString("yyyyMMdd");
            string stopDate   = date_Stop.Value.ToString("yyyyMMdd");
            string urlAddress = String.Format("https://stooq.pl/q/d/l/?s={0}&d1={1}&d2={2}&i=d",
                                              companyTag, startDate, stopDate);

            dgv_Data.Columns.Clear();
            dgv_Data.Columns.Add("DATE", "Date");
            dgv_Data.Columns.Add("OPEN", "Opening Price");
            dgv_Data.Columns.Add("CLOSE", "Closing Price");
            dgv_Data.Columns.Add("VOLUME", "Volume");

            dgv_Data.Columns[0].Width = 100;
            dgv_Data.Columns[1].Width = 200;
            dgv_Data.Columns[2].Width = 200;
            dgv_Data.Columns[3].Width = 150;



            try
            {
                WebClient webClient = new WebClient();
                string    s         = webClient.DownloadString(urlAddress);


                string[] lines = s.Split('\n');

                for (int i = 1; i < lines.Length; i++)
                {
                    string   line  = lines[i];
                    string[] items = line.Trim().Split(',');

                    if (items.Length == 6)
                    {
                        string[] row = new string[4]
                        {
                            items[0], items [1], items[4], items[5]
                        };

                        dgv_Data.Rows.Add(row);

                        this.dataChart.Series["Open"].Points.AddXY(items[0], items[1]);
                        this.dataChart.Series["Close"].Points.AddXY(items[0], items[4]);
                        this.dataChart.Series["Volume"].Points.AddXY(items[0], items[5]);

                        dates.Add(items[0]);
                        openingPrices.Add(Double.Parse(items[1], CultureInfo.InvariantCulture));
                        closingPrices.Add(Double.Parse(items[4], CultureInfo.InvariantCulture));
                        volumes.Add(Int32.Parse(items[5]));



                        //openingPrices.Add(Double.Parse(items[1]));
                        //closingPrices.Add(Double.Parse(items[4]));
                        //volume.Add(Int32.Parse(items[5]));
                        //Series series = new Series;

                        //this.chartControl1.Series["Open"].Points.Add(items[0], Double.Parse(items[1]));
                        //this.chartControl1.Series["Close"].Points.Add(items[0], Double.Parse(items[4]));
                        //this.chartControl1.Series["Volume"].Points.Add(items[0], Double.Parse(items[1]));
                        // chart_Chart.Series = dgv_Data.Columns["CLOSE"]
                        //seriesOpen.ChartPoints.AddXY(items[0], Double.Parse(items[4], CultureInfo.InvariantCulture));
                        //chart_Chart.Series.Append(PointsArray items[1]);
                        // seriesVolume.ChartPoints.AddXY(items[0], Int32.Parse(items[5]));
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }



            //chart_Chart.AsChartValues() = openingPrices.AsChartValues();
            //chart_Chart.Series = openingPrices.AsChartValues();
            //closingPrices

            //    chart_Chart.Series.Append(openingPrices.Item);
            //    volume;


            //dvcChart.Visible = Enabled;

            //cartesianChart.Series.Clear();


            var openingPricesLine = new LiveCharts.ChartValues <double>();
            var closingPricesLine = new LiveCharts.ChartValues <double>();

            foreach (var item in openingPrices)
            {
                openingPricesLine.Add(item);
            }

            foreach (var item in closingPrices)
            {
                closingPricesLine.Add(item);
            }



            cartesianChart.Series = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = "Opening Prices",
                    Values = openingPricesLine,
                },
                new LineSeries
                {
                    Title  = "Closing Prices",
                    Values = closingPricesLine
                }
            };



            //cartesianChart.AxisX.Remove(cartesianChart.AxisX[0]);
            //MessageBox.Show(cartesianChart.AxisY.Count.ToString());
            //MessageBox.Show(cartesianChart.AxisX.Count.ToString());

            //cartesianChart.AxisX.Clear();
            //cartesianChart.AxisY.Clear();

            //MessageBox.Show("os Y po usnięciu " +cartesianChart.AxisY.Count.ToString());
            //MessageBox.Show("os X po usnięciu " + cartesianChart.AxisX.Count.ToString());

            //cartesianChart.AxisX.Clear();
            //MessageBox.Show("os X po usnięciu jeszcze raz " + cartesianChart.AxisX.Count.ToString());



            //cartesianChart.AxisX.Add(new Axis
            //{
            //    Title = "Date",


            //    LabelFormatter = value => value.ToString(),

            //    //Labels = new[] { "Jan", "Feb", "Mar", "Apr", "May" }
            //}); ;


            //cartesianChart.AxisY.Add(new Axis
            //{
            //    Title = "Price",
            //    LabelFormatter = value => value.ToString("C")
            //});

            //cartesianChart.LegendLocation = LegendLocation.Bottom;


            //cartesianChart2.AxisY.Add(new Axis
            //{
            //    Title = "sdfsf",
            //    LabelFormatter = value => value.ToString("C")
            //});
        }
예제 #5
0
 public GraphVoyage()
 {
     //Коллекции данных графика
     items  = new ChartValues <PasItem>(); items.Add(new PasItem(DateTime.Now, 0, ""));
     items2 = new ChartValues <PasItem>(); items2.Add(new PasItem(DateTime.Now, 0, ""));
 }