Esempio n. 1
0
        public void addNapiBevetel()
        {
            Kapcsolatok   k1   = new Kapcsolatok();
            List <double> napi = k1.getNapiBevetel();

            CartesianChart ch = new CartesianChart();

            ch.Series = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = "Napi bevétel alakulása",
                    Values = new ChartValues <double> {
                        napi[0], napi[1], napi[2], napi[3], napi[4]
                    }
                }
            };
            grafikonNapi.Children.Add(ch);
        }
Esempio n. 2
0
        static void SetChartData(CartesianChart chart, string dataSource)
        {
            if (chart == null)
            {
                return;
            }

            var chartDates = JsonConvert.DeserializeObject <List <LineChartData> >(dataSource);
            var series     = new SeriesCollection();

            series.AddRange(chartDates.Select(data => new LineSeries
            {
                Title  = data.Name,
                Values = new ChartValues <DateValueModel>(data.DataModels)
            }));


            chart.Series = series;
        }
        private void Plot()
        {
            var chart = new CartesianChart();
            var grid  = BurndownGrid;

            // prepare data
            var nOfDays = (period.endDate - period.startDate).Days + 2;

            // X axis
            chart.AxisX.Add(new Axis
            {
                Labels    = GetLabels(),
                Separator = !simplified
                ? new LiveCharts.Wpf.Separator  // force the separator step to 1, so it always display all labels
                {
                    Step      = 1,
                    IsEnabled = false
                }
                : new LiveCharts.Wpf.Separator
                {
                    IsEnabled = false
                },
                Sections = GetSections(true, true)
            });

            // series
            chart.Series = GetSeriesCollection(simplified);

            chart.AxisY.Add(new Axis
            {
                LabelFormatter = value => Math.Round(value).ToString(),
                Separator      = new LiveCharts.Wpf.Separator(),
                MinValue       = minValue
            });

            // add to grid
            chart.Margin         = new System.Windows.Thickness(0);
            chart.LegendLocation = simplified
                ? LegendLocation.None
                : LegendLocation.Top;
            grid.Children.Clear();
            grid.Children.Add(chart);
        }
Esempio n. 4
0
        protected void refresh()
        {
            cleanUp();
            content.Content = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect(2, GCCollectionMode.Forced, true);

            var chart = new CartesianChart();

            chart.Series = new SeriesCollection();

            Series series;

            series = new ColumnSeries {
                LabelPoint = point => point.Y.ToString("N0")
            };

            series.Title      = "title";
            series.Fill       = new SolidColorBrush(Colors.Red);
            series.DataLabels = true;

            series.Values = new ChartValues <double>(new List <double> {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9
            });

            chart.Series.Add(series);

            chart.AxisX = new AxesCollection();
            chart.AxisY = new AxesCollection();

            chart.AxisX.Add(new Axis {
                Title = "Hours", Labels = new List <string> {
                    "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
                }
            });
            chart.AxisY.Add(new Axis {
                Title = "Stats"
            });

            content.Content = chart;
        }
Esempio n. 5
0
        public void SharingSeries()
        {
            var aGuy = new CartesianChart();
            var bGuy = new CartesianChart();

            aGuy.MockIt(new CoreSize(200, 200));
            bGuy.MockIt(new CoreSize(200, 200));

            var aSeries = new LineSeries();

            aGuy.Series.Add(aSeries);
            aGuy.Update();
            Debug.WriteLine(aGuy.Series.Count);

            bGuy.Series.Add(aSeries);
            bGuy.Update();
            Debug.WriteLine(aGuy.Series.Count);
            Debug.WriteLine(bGuy.Series.Count);
        }
        private void SaveFile()
        {
            CartesianChart     Chart = TotalXPHeader.IsSelected ? TotalChart : DiffChart;
            RenderTargetBitmap rtb   = new RenderTargetBitmap((int)Chart.ActualWidth, (int)Chart.ActualHeight, 96, 96, PixelFormats.Pbgra32);

            rtb.Render(Chart);
            PngBitmapEncoder png = new PngBitmapEncoder();

            png.Frames.Add(BitmapFrame.Create(rtb));
            MemoryStream stream = new MemoryStream();

            png.Save(stream);
            Image image = Image.FromStream(stream);

            stream.Dispose();
            string ChartName = TotalXPHeader.IsSelected ? "TotalChart" : "DiffChart";

            image.Save(ChartName + ".png");
        }
Esempio n. 7
0
        public LineChart(List <List <IdParking> > listListCarParks, string tag)
        {
            chart = new CartesianChart();
            string nameOfParking = null;

            foreach (var item in listListCarParks)
            {
                try
                {
                    nameOfParking += $",{item[0].name}";
                }
                catch
                {
                    //brak elementów
                }
            }
            chart.Tag             = $"{tag} {nameOfParking}";
            this.listListCarParks = listListCarParks;
        }
        private void DrawChart(CartesianChart chart, string filePath, string chartTitle, string xTitle, string yTitle)
        {
            xValues = ReadDataFromFile(filePath)[0];
            yValues = ReadDataFromFile(filePath)[1];


            for (int i = 0; i < xValues.Count; i++)
            {
                ListOfPoints.Add(new ObservablePoint {
                    X = xValues[i],
                    Y = yValues[i]
                });
            }

            seriesCol = new SeriesCollection {
                new LineSeries {
                    Values         = ListOfPoints,
                    LineSmoothness = 0,
                    PointGeometry  = DefaultGeometries.Circle, // DefaultGeometries.Square tylko jak jest malo punktuf, inzcaej kupcia

                    Title = chartTitle,
                    Fill  = System.Windows.Media.Brushes.White
                }
            };

            chart.AxisX.Add(
                new Axis {
                MinValue = xValues.Min(),
                Title    = xTitle,
            });

            chart.AxisY.Add(
                new Axis {
                MinValue = 0,
                Title    = yTitle,
            });
            chart.Background = System.Windows.Media.Brushes.White;
            chart.AxisX[0].Separator.StrokeThickness = 0;
            chart.AxisY[0].Separator.StrokeThickness = 0;
            chart.AxisY[0].Separator.IsEnabled       = true;

            chart.DataContext = this;
        }
Esempio n. 9
0
        private void CreateChart(string[] years, string title, IChartValues values, bool isMoney, string axisYtitle, double minValue, double maxValue, string axisXtitle)
        {
            Label labelTitle = ViewUtils.CreateLabel(title, "StyleLabel2Center", 18, -1);

            spMain.Children.Add(labelTitle);

            SeriesCollection averageClubLevelInGameCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = title,
                    Values = values,
                }
            };

            CartesianChart cc = new CartesianChart();

            cc.Width  = 800;
            cc.Height = 375;

            cc.Series = averageClubLevelInGameCollection;

            Axis axisY = new Axis();

            axisY.Title    = axisYtitle;
            axisY.MinValue = minValue;
            axisY.MaxValue = maxValue;

            if (isMoney)
            {
                axisY.LabelFormatter = YFormatter;
            }


            Axis axisX = new Axis();

            axisX.Title  = axisXtitle;
            axisX.Labels = years;

            cc.AxisY.Add(axisY);
            cc.AxisX.Add(axisX);
            spMain.Children.Add(cc);
        }
Esempio n. 10
0
        public View()
        {
            InitializeComponent();
            Size = new System.Drawing.Size(50, 50);

            var viewModel = new ViewModel();

            cartesianChart = new CartesianChart
            {
                Series = viewModel.Series,

                // out of livecharts properties...
                Location = new System.Drawing.Point(0, 0),
                Size     = new System.Drawing.Size(50, 50),
                Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
            };

            Controls.Add(cartesianChart);
        }
Esempio n. 11
0
        public TestCartesianChartView()
        {
            if (!LiveCharts.IsConfigured)
            {
                LiveCharts.Configure(LiveChartsSkiaSharp.DefaultPlatformBuilder);
            }

            var stylesBuilder = LiveCharts.CurrentSettings.GetTheme <SkiaSharpDrawingContext>();
            var initializer   = stylesBuilder.GetVisualsInitializer();

            if (stylesBuilder.CurrentColors == null || stylesBuilder.CurrentColors.Length == 0)
            {
                throw new Exception("Default colors are not valid");
            }
            initializer.ApplyStyleToChart(this);

            Core = new CartesianChart <SkiaSharpDrawingContext>(
                this, LiveChartsSkiaSharp.DefaultPlatformBuilder, CoreCanvas);
        }
Esempio n. 12
0
        public void DisplayDiagrams(CartesianChart Diagr, System.Data.Entity.Core.Objects.ObjectResult FED, string TitleValue, int Val, string Lab)
        {
            Diagr.Series.Clear();
            Diagr.AxisX.Clear();
            Diagr.AxisY.Clear();
            if (Diagr.Series.Count >= 1)
            {
            }
            else
            {
                using (EDMX.fleerEntitiesDiagrams db = new EDMX.fleerEntitiesDiagrams())
                {
                    var       data = FED;
                    RowSeries col  = new RowSeries()
                    {
                        DataLabels = true, Values = new ChartValues <double>(), LabelPoint = point => point.X.ToString(), Title = TitleValue, Foreground = new SolidColorBrush(Colors.Black)
                    };
                    Axis ax = new Axis()
                    {
                        Separator = new LiveCharts.Wpf.Separator()
                        {
                            Step = 1, IsEnabled = false
                        }, Foreground = new SolidColorBrush(Colors.Black)
                    };
                    ax.Labels = new List <string>();
                    foreach (var x in data)
                    {
                        col.Values.Add(Val);
                        ax.Labels.Add(Lab);
                    }

                    Diagr.Series.Add(col);
                    Diagr.AxisY.Add(ax);
                    Diagr.AxisX.Add(new Axis {
                        LabelFormatter = value => value.ToString(), Separator = new LiveCharts.Wpf.Separator()
                        {
                            Stroke = new SolidColorBrush(Colors.LightGray)
                        }, Foreground = new SolidColorBrush(Colors.Black)
                    });
                }
            }
        }
Esempio n. 13
0
        public View()
        {
            InitializeComponent();
            Size = new System.Drawing.Size(50, 50);

            var viewModel = new ViewModel();

            var cartesianChart = new CartesianChart
            {
                Series   = viewModel.SeriesCollection1,
                ZoomMode = LiveChartsCore.Measure.ZoomAndPanMode.X,
                XAxes    = viewModel.SharedXAxis, // <-- notice we are using the same variable for both charts, this syncs both charts

                // out of livecharts properties...
                Location = new System.Drawing.Point(0, 0),
                Size     = new System.Drawing.Size(50, 50),
                Dock     = DockStyle.Fill
            };

            var cartesianChart2 = new CartesianChart
            {
                Series   = viewModel.SeriesCollection2,
                ZoomMode = LiveChartsCore.Measure.ZoomAndPanMode.X,
                XAxes    = viewModel.SharedXAxis, // <-- notice we are using the same variable for both charts, this syncs both charts

                // out of livecharts properties...
                Location = new System.Drawing.Point(0, 0),
                Size     = new System.Drawing.Size(50, 50),
                Dock     = DockStyle.Fill
            };

            var splitContainer = new SplitContainer
            {
                Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                //IsSplitterFixed = true,
                Orientation = Orientation.Horizontal
            };

            splitContainer.Panel1.Controls.Add(cartesianChart);
            splitContainer.Panel2.Controls.Add(cartesianChart2);
            Controls.Add(splitContainer);
        }
Esempio n. 14
0
        public CartesianChartRegionManager(CartesianChart chart)
        {
            this.chart = chart;
            myCI       = CultureInfo.CurrentCulture;
            myCal      = myCI.Calendar;
            myCWR      = myCI.DateTimeFormat.CalendarWeekRule;
            myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;

            ChartAvailable.Add(Properties.Resources.DailyCases, (int r, string s) => FillChartWitNewPositives(r, s));
            ChartAvailable.Add(Properties.Resources.DailySwabs, (int r, string s) => FillChartWitDailySwabs(r, s));
            ChartAvailable.Add(Properties.Resources.DailyCasesSwabs, (int r, string s) => FillChartWithDailySwabCases(r, s));
            ChartAvailable.Add(Properties.Resources.DailyDeads, (int r, string s) => FillChartWitDailyDeads(r, s));
            ChartAvailable.Add(Properties.Resources.WeeklyCases, (int r, string s) => FillChartWithWeeklyCases(r, s));
            ChartAvailable.Add(Properties.Resources.WeeklySwabs, (int r, string s) => FillChartWithWeeklySwab(r, s));
            ChartAvailable.Add(Properties.Resources.WeeklyCasesSwabs, (int r, string s) => FillChartWithWeeklySwabCases(r, s));
            ChartAvailable.Add(Properties.Resources.WeeklyDeads, (int r, string s) => FillChartWithWeeklyDead(r, s));
            ChartAvailable.Add(Properties.Resources.TotalCases, (int r, string s) => FillChartWitTotalCases(r, s));
            ChartAvailable.Add(Properties.Resources.IntensiveCare, (int r, string s) => FillChartWitIntensiveCare(r, s));
            ChartAvailable.Add(Properties.Resources.Hospital, (int r, string s) => FillChartWitHospital(r, s));
        }
Esempio n. 15
0
        /// <summary>
        /// Updates the chart with data points.
        /// </summary>
        /// <remarks>
        /// Thread must be started from UI/Main-Thread.
        /// </remarks>
        /// <param name="plotData"></param>
        /// <param name="cartesianChart"></param>
        public void Plot(PlotData plotData, CartesianChart cartesianChart)
        {
            if (plotData == null || cartesianChart == null)
            {
                throw new ArgumentNullException();
            }
            if (plotData.DataPoints == null)
            {
                throw new ArgumentException("There are no data point entries.");
            }

            // assign fields for global use
            this.plotData         = plotData;
            this.cartesianChart   = cartesianChart;
            this.SeriesCollection = cartesianChart.Series;

            ResetChart();

            MakeChart();
        }
Esempio n. 16
0
        public static void GetAnaliticsPoly(CartesianChart cc, DataGrid dgv, double[] data, int x, int y)
        {
            _x        = x;
            analitics = new PredictionM();
            Drawer pen = new Drawer(cc);

            var buffer_data = data.Skip(x).Take(y - x + 1);
            int count       = 0;

            double[] buffer = new double[y - x + 1];
            foreach (var item in buffer_data)
            {
                buffer[count] = Convert.ToDouble(item);
                count++;
            }

            double[] arr_analitics = analitics.GetPolyPrediction(buffer, 0);

            pen.DrawLinerChart(arr_analitics, x, "Аналитика");
            List <Darbin> table = new List <Darbin>();

            for (int i = 0; i < analitics.darbi.Length; i++)
            {
                table.Add(new Darbin {
                    N = (i + 1).ToString(), D = analitics.darbi[i]
                });
            }
            double error = 0;
            double sum   = 0;

            for (int i = 0; i < buffer.Length; i++)
            {
                sum += (Math.Abs(buffer[i] - arr_analitics[i]) / buffer[i]) * 100;
            }
            error = sum / buffer.Length;

            table.Add(new Darbin {
                N = "Средняя ошибка", D = Math.Round(error, 2)
            });
            dgv.ItemsSource = table;
        }
Esempio n. 17
0
        private void refreshGrafikKeuangan()
        {
            ChartKeuangan chartPenjualan = GetChartKeuangan("sp_chartPenjualan");
            ChartKeuangan chartPembelian = GetChartKeuangan("sp_chartPembelian");

            CartesianChart ch = new CartesianChart();

            ch.Foreground = new SolidColorBrush(Colors.Black);
            ch.Series     = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = "Penjualan",
                    Values = new ChartValues <double>(chartPenjualan.keuangan)
                },
                new ColumnSeries
                {
                    Title  = "Pembelian",
                    Values = new ChartValues <double>(chartPembelian.keuangan)
                }
            };

            ch.AxisX.Add(new Axis
            {
                Title     = "Bulan",
                Labels    = chartPenjualan.bulan,
                Separator = new Separator
                {
                    Step = 1
                }
            });

            ch.AxisY.Add(new Axis
            {
                Title          = "Keuangan",
                LabelFormatter = value => value.ToString("C", CultureInfo.CreateSpecificCulture("id-ID"))
            });


            keuanganChart.Children.Add(ch);
        }
        public static void SetCaresianChartOptimizeError(CartesianChart cartesianChart)
        {
            cartesianChart.AxisX.Clear();
            cartesianChart.AxisY.Clear();
            cartesianChart.Series.Clear();

            var chartValues = new ChartValues <double>();
            var labels      = new List <string>();

            foreach (var point in OptimizeErrorPoints)
            {
                chartValues.Add(point.Y);
                labels.Add(point.X.ToString(CultureInfo.InvariantCulture));
            }

            var series = new LiveCharts.Wpf.LineSeries()
            {
                Title  = "Погрешность",
                Values = chartValues
            };


            cartesianChart.Series = new SeriesCollection()
            {
                series
            };

            cartesianChart.AxisX.Add(new LiveCharts.Wpf.Axis
            {
                Title  = "Frequency",
                Labels = labels
            });

            cartesianChart.AxisY.Add(new LiveCharts.Wpf.Axis
            {
                Title          = "Sales",
                LabelFormatter = value => value.ToString(CultureInfo.InvariantCulture)
            });

            cartesianChart.LegendLocation = LegendLocation.Right;
        }
Esempio n. 19
0
 private void plotReset(CartesianChart chart)
 {
     chart.Series = new SeriesCollection
     {
         new LineSeries
         {
             Title  = "BubbleSort",
             Values = new ChartValues <ObservablePoint>()
         },
         new LineSeries
         {
             Title  = "InsertionSort",
             Values = new ChartValues <ObservablePoint>()
         },
         new LineSeries
         {
             Title  = "QuickSort",
             Values = new ChartValues <ObservablePoint>()
         }
     };
 }
Esempio n. 20
0
        public void Deserialize(CartesianChart D_chart)
        {
            if (D_chart.AxisX.Count < 1)
            {
                D_chart.AxisX.Add(new Axis());
            }

            if (D_chart.AxisY.Count < 1)
            {
                D_chart.AxisY.Add(new Axis());
            }


            D_chart.AxisX[0].Foreground       = AxisX;
            D_chart.AxisX[0].Separator.Stroke = AxisX;
            D_chart.AxisX[0].Title            = TitleX;

            D_chart.AxisY[0].Foreground       = AxisY;
            D_chart.AxisY[0].Separator.Stroke = AxisY;
            D_chart.AxisY[0].Title            = TitleY;
        }
Esempio n. 21
0
        private void refreshGrafikJumlahObat()
        {
            ChartJumlahObat chartPenjualan = GetChartJumlahObat("sp_chartPenjualan");
            ChartJumlahObat chartPembelian = GetChartJumlahObat("sp_chartPembelian");

            CartesianChart ch = new CartesianChart();

            ch.Foreground = new SolidColorBrush(Colors.Black);
            ch.Series     = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = "Penjualan",
                    Values = new ChartValues <int>(chartPenjualan.jumlah)
                },
                new ColumnSeries
                {
                    Title  = "Pembelian",
                    Values = new ChartValues <int>(chartPembelian.jumlah)
                }
            };

            ch.AxisX.Add(new Axis
            {
                Title     = "Bulan",
                Labels    = chartPenjualan.bulan,
                Separator = new Separator
                {
                    Step = 1
                }
            });

            ch.AxisY.Add(new Axis
            {
                Title = "Jumlah Obat",
            });


            jumlahObatChart.Children.Add(ch);
        }
Esempio n. 22
0
        public View()
        {
            InitializeComponent();
            Size = new System.Drawing.Size(100, 100);

            var viewModel = new ViewModel();

            cartesianChart = new CartesianChart
            {
                Series = viewModel.Series,

                // out of livecharts properties...
                Location = new System.Drawing.Point(0, 50),
                Size     = new System.Drawing.Size(100, 50),
                Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
            };

            Controls.Add(cartesianChart);

            var b1 = new Button {
                Text = "toggle 1", Location = new System.Drawing.Point(0, 0)
            };

            b1.Click += (object sender, System.EventArgs e) => viewModel.ToogleSeries0();
            Controls.Add(b1);

            var b2 = new Button {
                Text = "toggle 2", Location = new System.Drawing.Point(80, 0)
            };

            b2.Click += (object sender, System.EventArgs e) => viewModel.ToogleSeries1();
            Controls.Add(b2);

            var b3 = new Button {
                Text = "toggle 3", Location = new System.Drawing.Point(160, 0)
            };

            b3.Click += (object sender, System.EventArgs e) => viewModel.ToogleSeries2();
            Controls.Add(b3);
        }
Esempio n. 23
0
        public void GenerateChart(CartesianChart C_General, SDA_Core.Business.Arrays.SensorData data, ComboBox CB_Selected)
        {
            if (CB_Selected.SelectedItem == null)
            {
                return;
            }
            calculate = false;

            int dataColumn = CB_Selected.SelectedIndex;

            C_General.Series = null;

            // Calculos para mostrar cuantos elementos seran mostrados.
            int init = 0;

            if (data.Rows > maxElementsToShow)
            {
                init = data.Rows - maxElementsToShow;
            }

            ChartValues <double> series = new ChartValues <double>();

            for (int i = init; i < data.Rows; ++i)
            {
                series.Add(data.Columns[dataColumn].List[i].Value);
            }

            SeriesCollection SeriesCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Values = series
                },
            };

            C_General.Series = SeriesCollection;

            UpdateChart(C_General, data, dataColumn);
        }
        public static void GetAnaliticsExp(CartesianChart cc, DataGrid dgv, double[] data, int x, int y, double error_need)
        {
            analitics = new PredictionM();
            Drawer pen = new Drawer(cc);

            var buffer_data = data.Skip(x).Take(y - x + 1);
            int count       = 0;

            double[] buffer = new double[y - x + 1];
            foreach (var item in buffer_data)
            {
                buffer[count] = Convert.ToDouble(item);
                count++;
            }

            double alfa  = 0.3;
            double error = 0;

            arr_analitics = analitics.GetExpPrediction(buffer, 0, alfa);
            //do
            //{

            //    double sum = 0;

            //    for (int i = 0; i < buffer.Length; i++)
            //    {
            //        sum += ((buffer[i] - arr_analitics[i])/ buffer[i]) * 100;
            //    }
            //    error = sum / buffer.Length;

            //    List<Darbin> table = new List<Darbin>();
            //    table.Add(new Darbin { N = alfa.ToString(), D = Math.Round(error, 2) });
            //    dgv.Items.Add(table);
            //    alfa += 0.1;

            //} while (error > error_need);
            pen.DrawLinerChart(arr_analitics, x, "Аналитика");
            Darbins = PredictionUpdate.darbins;
        }
        public void InitialiseChart()
        {
            CartesianChart chart = (Controls["chart"] as CartesianChart);

            chart?.Series[0].Values.Clear();
            if (NegligibleAxisSection == null)
            {
                NegligibleAxisSection = new LiveCharts.Wpf.AxisSection()
                {
                    Stroke          = Brushes.Blue,
                    StrokeThickness = 1,
                };
                chart.AxisX[0].Sections.Add(NegligibleAxisSection);
            }
            NegligibleAxisSection.Value      = 0;
            NegligibleAxisSection.Visibility = Visibility.Hidden;
            if (MinimalAxisSection == null)
            {
                MinimalAxisSection = new LiveCharts.Wpf.AxisSection()
                {
                    Stroke          = Brushes.Green,
                    StrokeThickness = 1,
                };
                chart.AxisX[0].Sections.Add(MinimalAxisSection);
            }
            MinimalAxisSection.Value      = 0;
            MinimalAxisSection.Visibility = Visibility.Hidden;
            if (SkinDepthAxisSection == null)
            {
                SkinDepthAxisSection = new LiveCharts.Wpf.AxisSection()
                {
                    Stroke          = Brushes.Red,
                    StrokeThickness = 1,
                };
                chart.AxisY[0].Sections.Add(SkinDepthAxisSection);
            }
            SkinDepthAxisSection.Value      = 0;
            SkinDepthAxisSection.Visibility = Visibility.Hidden;
        }
        public static void DrawMainData(CartesianChart cc1, CartesianChart cc2, double[] data)
        {
            try
            {
                Drawer   pen      = new Drawer(cc1);
                Drawer   pen2     = new Drawer(cc2);
                Drawer   pen3     = new Drawer(cc1);
                MainData maindata = new MainData();

                double logLength    = Math.Ceiling(Math.Log((double)data.Length, 2.0));
                int    paddedLength = (int)Math.Pow(2.0, Math.Min(Math.Max(1.0, logLength), 14.0));

                Complex[] arr_main = new Complex[paddedLength / 2];

                for (int i = 0; i < paddedLength / 2; i++)
                {
                    try
                    {
                        Complex arr = new Complex(data[i], 0);
                        arr_main[i] = arr;
                    }
                    catch
                    {
                        Complex arr = new Complex(0, 0);
                        arr_main[i] = arr;
                    }
                }

                a_spector = maindata.FFTForward(arr_main);
                f_spector = maindata.FFTForwardQ(arr_main);
                pen2.DrawColumnChart(a_spector, "Амплитудный спектр");
                pen.DrawLinerChart(data, "Основные данные");
                pen3.DrawAreas(AnaliticDataVM.ValueLevels, data.Length - 1);
            }
            catch
            {
                MessageBox.Show("Данные не загружены. Пожалуйста загрузите данные в нужном разделе.");
            }
        }
Esempio n. 27
0
        public void Serialize(CartesianChart S_chart)
        {
            if (S_chart.AxisX.Count > 0)
            {
                AxisX  = S_chart.AxisX[0].Foreground;
                TitleX = S_chart.AxisX[0].Title;
            }
            else
            {
                AxisX = new SolidColorBrush(Colors.Black);
            }

            if (S_chart.AxisY.Count > 0)
            {
                AxisY  = S_chart.AxisY[0].Foreground;
                TitleY = S_chart.AxisY[0].Title;
            }
            else
            {
                AxisY = new SolidColorBrush(Colors.Black);
            }
        }
Esempio n. 28
0
        private async void UpdateChart(CartesianChart C_General, SDA_Core.Business.Arrays.SensorData data, int dataColumn)
        {
            // Para asegurarse que otras llamadas de UpdateChart sean terminadas
            calculate = false;
            await Task.Delay(1500);

            calculate = true;

            int    position = C_General.Series[0].Values.Count - 1;
            double newValue = -1;

            while (calculate)
            {
                try
                {
                    if (data.Rows - 1 >= position)
                    {
                        newValue = data.Columns[dataColumn].List[position].Value;
                        C_General.Series[0].Values.Add(newValue);
                        position++;
                    }
                }
                catch
                {
                    await Task.Delay(timeInterval);

                    continue;
                }

                // Solo se muestran 'maxElementsToShow' valores en la gráfica
                if (C_General.Series[0].Values.Count > maxElementsToShow)
                {
                    try { C_General.Series[0].Values.RemoveAt(0); }
                    catch { break; }
                }

                await Task.Delay(timeInterval);
            }
        }
        public static void GetAnaliticsPoly(CartesianChart cc, DataGrid dgv, double[] data, int x, int y, bool darbin, string dn, string dv, string countG)
        {
            _x        = x;
            analitics = new PredictionM();
            Drawer pen = new Drawer(cc);

            var buffer_data = data.Skip(x).Take(y - x + 1);
            int count       = 0;

            double[] buffer = new double[y - x + 1];
            foreach (var item in buffer_data)
            {
                buffer[count] = Convert.ToDouble(item);
                count++;
            }


            double[] arr_analitics = PredictionUpdate.Prediction(buffer.ToList(), 0, darbin, Convert.ToDouble(dn.Replace(".", ",")), Convert.ToDouble(dv.Replace(".", ",")), countG).ToArray();

            pen.DrawLinerChart(arr_analitics, x, "Аналитика");
            //List<Darbin> table = new List<Darbin>();
            //for (int i = 0; i < analitics.darbi.Length; i++)
            //{
            //    table.Add(new Darbin { N = (i + 1).ToString(), D = analitics.darbi[i] });
            //}
            double error = 0;
            double sum   = 0;

            for (int i = 0; i < buffer.Length; i++)
            {
                sum += (Math.Abs(buffer[i] - arr_analitics[i]) / buffer[i]) * 100;
            }
            error = sum / buffer.Length;

            //table.Add(new Darbin { N = "Средняя ошибка", D = Math.Round(error, 2) });
            //dgv.ItemsSource = table;
            Darbins = PredictionUpdate.darbins;
        }
Esempio n. 30
0
        public View()
        {
            InitializeComponent();
            Size = new System.Drawing.Size(100, 100);

            var viewModel = new ViewModel();

            cartesianChart = new CartesianChart
            {
                Series = viewModel.Series,

                // there are already many defined functions in the EasingFunctions static class
                EasingFunction  = LiveChartsCore.EasingFunctions.BackOut,
                AnimationsSpeed = TimeSpan.FromMilliseconds(600),

                // out of livecharts properties...
                Location = new System.Drawing.Point(0, 50),
                Size     = new System.Drawing.Size(100, 50),
                Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
            };

            Controls.Add(cartesianChart);
        }