protected virtual void UpdateChartTrades <T>(List <T> newTrades, int newTradesCount, int tradesChartDisplayCount, ref ChartValues <T> tradesChart) { if (newTrades == null) { throw new ArgumentNullException(nameof(newTrades)); } if (tradesChart == null) { throw new ArgumentNullException(nameof(tradesChart)); } var tradesChartCount = tradesChart.Count; if (tradesChartCount >= tradesChartDisplayCount) { // For each additional new trade remove the oldest then add the new trade for (int i = 0; i < newTradesCount; i++) { tradesChart.RemoveAt(0); tradesChart.Add(newTrades[i]); } } else { // Get the difference between the number of trades the chart can take and the number it currently holds. var chartDisplayTopUpTradesCount = tradesChartDisplayCount - tradesChartCount; if (newTradesCount > chartDisplayTopUpTradesCount) { // There are more new trades than the chart can take. if (chartDisplayTopUpTradesCount > 0) { // The top up trades can simply be added to the chart as it will take it to the total the chart can hold var chartDisplayTopUpTrades = newTrades.Take(chartDisplayTopUpTradesCount).ToList(); tradesChart.AddRange(chartDisplayTopUpTrades); } for (int i = chartDisplayTopUpTradesCount; i < newTradesCount; i++) { // For each additional new trade remove the oldest then add the new trade tradesChart.RemoveAt(0); tradesChart.Add(newTrades[i]); } } else { // Simply add new trades to current list as it wont be more than the total the chart can take. tradesChart.AddRange(newTrades); } } }
void sb_Completed(object sender, EventArgs e) { Console.WriteLine("Storyboard completed.\nLiczba punktow: {0}", licznik_punktow_animacji); for (int i = licznik_punktow_animacji - 1; i < ARRAY_SIZE; i++) { valuesX[i] = 0; valuesY[i] = 0; valuesZ[i] = 0; } cvX.AddRange(valuesX); cvY.AddRange(valuesY); cvZ.AddRange(valuesZ); }
private void btnstart_Click(object sender, RoutedEventArgs e) { ChartValues <double> chartDatas1 = new ChartValues <double>(); ChartValues <double> chartDatas2 = new ChartValues <double>(); var rnd = new Random(); var datas1 = Enumerable.Range(0, 100).Select(x => ( double )(x + rnd.Next(10))); var datas2 = Enumerable.Range(0, 100).Select(x => ( double )(x / 2 + rnd.Next(5))); chartDatas1.AddRange(datas1); chartDatas2.AddRange(datas2); LineSeries temp1 = new LineSeries(); LineSeries temp2 = new LineSeries(); temp1.Values = chartDatas1; temp2.Values = chartDatas2; temp1.DataLabels = false; temp1.PointGeometrySize = 0; temp1.Fill = Brushes.Transparent; src.Add(temp1); src.Add(temp2); chartmain.Series = src; // 1 : SeriesCollection // 2 : |_ Line Sereis , Column Sereis ... // 3: |_ Chart Data }
private void printData() { cartesianChart1.AxisX.Clear(); cartesianChart1.AxisX.Add(new LiveCharts.Wpf.Axis { Title = "Time", Labels = dataPreparation.dataToPrint.Keys.Select(x => x.ToShortTimeString()).ToList(), }); cartesianChart1.Series.Clear(); var chart = new ChartValues <double>(); double[] doubleArray = new double[dataPreparation.dataToPrint.Values.Count]; dataPreparation.dataToPrint.Values.ToArray().CopyTo(doubleArray, 0); chart.AddRange(doubleArray); SeriesCollection series = new SeriesCollection(); series.Add(new LineSeries() { Title = "Value", Values = chart, AllowDrop = true, PointGeometry = null }); cartesianChart1.Hoverable = false; cartesianChart1.DisableAnimations = true; //cartesianChart1.DataTooltip = null; cartesianChart1.Series = series; }
public void AddNewSeries(IEnumerable <double> datas, IEnumerable <double> labels, string title) { ChartValues <double[]> chartDatas = new ChartValues <double[]>(); this.Dispatcher.BeginInvoke((Action)(() => chtLiveLine.LegendLocation = LegendLocation.Right)); var dts = datas.ToArray(); var lbls = labels.ToArray(); //dts [ 0 ] = dts [ 2 ]; //dts [ 1 ] = dts [ 2 ]; // //ChartValues<double[]> chartDatas = new ChartValues<double[]>(); //chartDatas.AddRange( // Enumerable.Range( 0 , datas.Count() ) // .Where( ( _ , i ) => i % 10 == 0 ) // .Select( x => new double [ 2 ] { lbls [ x ] , dts [ x ] } ) // ); var fixeddata = ClearNoise(datas.ToArray()); chartDatas.AddRange( Range(0, fixeddata.Length) .Where(i => i % 10 == 0) .Select(i => new double [2] { lbls [i], fixeddata[i] })); this.Dispatcher.BeginInvoke(( Action )(() => { SeriesColl.Add(CreateSeries(chartDatas)); this.Dispatcher.BeginInvoke(( Action )(() => chtLiveLine.Series = SeriesColl)); })); }
public void AddNewSeries(IEnumerable <double> datas, IEnumerable <double> labels) { chtLiveLine.LegendLocation = LegendLocation.None; //ChartDatas.Clear(); var dts = datas.ToArray(); var lbls = labels.ToArray(); dts [0] = dts [2]; dts [1] = dts [2]; ChartValues <double[]> chartDatas = new ChartValues <double[]>(); chartDatas.AddRange( Range(0, datas.Count()) .Where((_, i) => i % 10 == 0) .Select(x => new double [2] { lbls [x], dts [x] }) ); this.Dispatcher.BeginInvoke(( Action )(() => { SeriesColl.Add(CreateSeries(chartDatas)); foreach (var item in SeriesColl) { SeriesColl.Add(item); } this.Dispatcher.BeginInvoke(( Action )(() => chtLiveLine.Series = SeriesColl)); })); }
private async Task <ChartValues <DateTimePoint> > GetData() { string _api_function = api_function.Text; string _api_stock_symbol = api_stock_symbol.Text; string _api_output_size = api_output_size.Text; string urlParameters = string.Format("query?function={0}&symbol={1}&outputsize={2}&apikey=WPR105SZICA1KKXP", _api_function, _api_stock_symbol, _api_output_size); Dictionary <string, Dictionary <string, string> > price = await GetData_API.RunAsync(client, urlParameters); int size = price.Count; var array = new DateTimePoint[size]; var values = new ChartValues <DateTimePoint>(); int i = 0; foreach (KeyValuePair <string, Dictionary <string, string> > entry in price) { DateTime datetime = DateTime.Parse(entry.Key); Double price_close = Convert.ToDouble(entry.Value["4. close"]); array[i] = new DateTimePoint(datetime, price_close); i += 1; } Array.Reverse(array); values.AddRange(array); return(values); }
private void AddToLShapeChart(ComparisonRecordInfoWrapper wrappedComparisonInfo) { double startTime = FirstSeconds; double endTime = _maxRecordingTime - LastSeconds; var frametimeTimeWindow = wrappedComparisonInfo.WrappedRecordInfo.Session.GetFrametimeTimeWindow(startTime, endTime, ERemoveOutlierMethod.None); var lShapeQuantiles = _frametimeAnalyzer.GetLShapeQuantiles(); double action(double q) => _frametimeStatisticProvider.GetPQuantileSequence(frametimeTimeWindow, q / 100); var quantiles = lShapeQuantiles.Select(q => new ObservablePoint(q, action(q))); var quantileValues = new ChartValues <ObservablePoint>(); quantileValues.AddRange(quantiles); Application.Current.Dispatcher.BeginInvoke(new Action(() => { ComparisonLShapeCollection.Add( new LineSeries { Values = quantileValues, Stroke = wrappedComparisonInfo.Color, Fill = Brushes.Transparent, StrokeThickness = 1, LineSmoothness = 1, PointGeometrySize = 10, PointGeometry = DefaultGeometries.Triangle, }); })); }
private void AddHeatChartFromFile(Panel heatpanel, IntensityData idata) { LiveCharts.WinForms.CartesianChart heatchart; heatchart = new LiveCharts.WinForms.CartesianChart(); heatchart.Size = new Size(heatSizeX, heatSizeY); heatchart.Anchor = (AnchorStyles.Left | AnchorStyles.Right); heatchart.Left = 0; heatchart.Top = 50; heatchart.DisableAnimations = true; heatchart.Hoverable = false; heatchart.DataTooltip = null; ChartValues <HeatPoint> values = new ChartValues <HeatPoint>(); List <HeatPoint> buffer = new List <HeatPoint>(); for (int i = 0; i < idata.intensityData.Count(); i++) { Backend.Model.AggregatedData agregateddata = idata.intensityData[i]; for (int j = 0; j < agregateddata.aggregatedData.Count(); j++) { buffer.Add(new HeatPoint(j, i, agregateddata.aggregatedData[j])); } } values.AddRange(buffer); HeatSeries hs = new HeatSeries { Values = values, GradientStopCollection = gradient }; allPanelsIntensityData.Add(new Tuple <Panel, IntensityData, HeatSeries>(heatpanel, idata, hs)); heatchart.Series.Add(hs); heatpanel.Controls.Add(heatchart); }
public void SetSignal(int n, DiscreteSignal Signal) { if (Signal == null) { seriesReal[n] = null; seriesImaginary[n] = null; return; } ChartValues <ObservablePoint> valuesReal = new ChartValues <ObservablePoint>(); ChartValues <ObservablePoint> valuesImaginary = new ChartValues <ObservablePoint>(); valuesReal.AddRange( Signal.Values.Select( tuple => new ObservablePoint { X = tuple.X.Real, Y = tuple.Y.Real } ) ); valuesImaginary.AddRange( Signal.Values.Select( tuple => new ObservablePoint { X = tuple.X.Real, Y = tuple.Y.Imaginary } ) ); seriesReal[n] = CreateSeries(n, Signal, valuesReal); seriesImaginary[n] = CreateSeries(n, Signal, valuesImaginary); }
public void SetSignal(int n, DiscreteSignal Signal) { if (Signal == null) { series[n] = null; return; } ChartValues <ObservablePoint> values = new ChartValues <ObservablePoint>(); var aggregated = AggregateHistogram(Signal.Values); values.AddRange( aggregated.Select( tuple => new ObservablePoint { X = tuple.Item1, Y = (double)tuple.Item2 } ) ); series[n] = new ColumnSeries { Title = Signal.Name, Values = values, MaxColumnWidth = 5.0, Fill = ChartColors.List[n] }; }
private void UpdateGameScoreDataSource() { var actualScores = _scores .Select(s => s.ActualScore); actualDragonPercentageLabel.Text = CalculateScorePercentageString(_dragonText, actualScores); actualTigerPercentageLabel.Text = CalculateScorePercentageString(_tigerText, actualScores); var betScores = _scores .Select(s => s.BetScore); betDragonPercentageLabel.Text = CalculateScorePercentageString(_dragonText, betScores); betTigerPercentageLabel.Text = CalculateScorePercentageString(_tigerText, betScores); var betResults = _scores; var gameResults = betResults.Select((r, i) => { if (string.IsNullOrEmpty(_scores[i].BetScore)) { return(r.WinRate); } var betResults1 = betResults.Take(i + 1).Where(r1 => !string.IsNullOrEmpty(r1.BetScore)) .Select(r1 => { r1.Result = r1.ActualScore == r1.BetScore ? _winText : _loseText; return(r1); }); return(r.WinRate = (int)(betResults1.Where(r1 => r1.Result == _winText).Count() / (float)betResults1.Count() * 100)); }).ToList(); _chartValues.Clear(); _chartValues.AddRange(gameResults.Select(r => r ?? double.NaN)); }
/// <summary> /// Converts any collection to chart values /// </summary> /// <typeparam name="T">type to convert</typeparam> /// <param name="values">values to convert</param> /// <returns>a new ChartValues instance containing the passed collection</returns> public static ChartValues <T> AsChartValues <T>(this IEnumerable <T> values) { var l = new ChartValues <T>(); l.AddRange(values); return(l); }
public MainWindow() { InitializeComponent(); var series = new LineSeries() { Title = "Barometric Pressure" }; var data = LoadData(); var values = new ChartValues <WeatherDataRecord>(); values.AddRange(data); series.Values = values; var wdrXY = Mappers.Xy <WeatherDataRecord>(); wdrXY.X(wdr => wdr.Timestamp.Ticks); wdrXY.Y(wdr => (double)wdr.BarometricPressure); MySeriesCollection = new SeriesCollection(wdrXY) { series }; DataContext = this; Coefficient.Content = Utils.GetCoeffectient(data, new DateTime(2013, 01, 01)); }
private void SetFpsThresholdChart(IList <double> frametimes) { if (frametimes == null || !frametimes.Any()) { return; } var thresholdCounts = _frametimeStatisticProvider.GetFpsThresholdCounts(frametimes, ThresholdToggleButtonIsChecked); var thresholdCountValues = new ChartValues <double>(); thresholdCountValues.AddRange(thresholdCounts.Select(val => (double)val / frametimes.Count)); Application.Current.Dispatcher.Invoke(new Action(() => { FPSThresholdCollection = new SeriesCollection { new ColumnSeries { Values = thresholdCountValues, Fill = new SolidColorBrush(Color.FromRgb(34, 151, 243)), DataLabels = true, LabelPoint = p => (frametimes.Count * p.Y).ToString(), MaxColumnWidth = 40 } }; })); }
public BasicColumn() { InitializeComponent(); SeriesCollection = new SeriesCollection { }; txt = logParser.ReadLog("D:/2019-04-16.log"); txt = logParser.FindWorkSections(txt); points = logParser.GetPoints(txt); currentPoints.AddRange(points[0]); SeriesCollection.Add(new ColumnSeries { Title = "Opens", Values = currentPoints }); currentPoints = new ChartValues <int>(); currentPoints.AddRange(points[1]); SeriesCollection.Add(new ColumnSeries { Title = "Closes", Values = currentPoints }); MakeLabels(); DataContext = this; }
private void calculate_button_Click(object sender, RoutedEventArgs e) { double time_max = Double.Parse(time_sim_box.Text); List <double> data = chamber_air.Simulate_time(time_max, Isotope.Radionuclide.Ra_226); List <double> time_base = new List <double>(); double tics = 0; while (tics < time_max) { time_base.Add(tics); tics += chamber_air.Get_timetic(); } ChartValues <double> radon_data = new ChartValues <double>(); radon_data.AddRange(data); calculator_chart.Series.Clear(); calculator_chart.Series.Add(new LineSeries { Values = radon_data, }); calculator_chart.AxisX.Clear(); calculator_chart.AxisX.Add(new Axis { MaxValue = time_max }); }
private void loadPurchaseAndIncomeChart() { var purchaseChartValue = new ChartValues <decimal>(); var IncomeChartValue = new ChartValues <decimal>(); var BillAmountChartValue = new ChartValues <decimal>(); purchaseChartValue.AddRange(StatisticDataList.OrderBy(x => x.Statistic.ID).Select(x => x.Statistic.Price_purchase_total).ToList()); IncomeChartValue.AddRange(StatisticDataList.OrderBy(x => x.Statistic.ID).Select(x => x.Statistic.Income).ToList()); BillAmountChartValue.AddRange(StatisticDataList.OrderBy(x => x.Statistic.ID).Select(x => x.Statistic.Total_tax_included).ToList()); PurchaseAndIncomeSeriesCollection = new SeriesCollection { new LineSeries { Title = "Sale", Values = BillAmountChartValue }, new LineSeries { Title = "Purchase", Values = purchaseChartValue }, new LineSeries { Title = "Income", Values = IncomeChartValue } }; PurchaseAndIncomeLabels = StatisticDataList.OrderBy(x => x.Statistic.ID).Select(x => x.Statistic.Bill_datetime.ToString("MMMM")).ToArray(); //Labels = new[] { "Jan", "Feb", "Mar", "Apr", "May" }; }
public void PrepareChart(IEnumerable <Product> list, string name) { MinPrice = list.Select(x => x.Price.GetDecimal()).Min().ToString(); MaxPrice = list.Select(x => x.Price.GetDecimal()).Max().ToString(); CalculateChangePercent(list); InitializeComponent(); var lineSeries = new LineSeries(); lineSeries.Title = name; var chartValues = new ChartValues <decimal>(); chartValues.AddRange(list.Select(x => x.Price.GetDecimal().Value)); lineSeries.Values = chartValues; SeriesCollection = new SeriesCollection(); SeriesCollection.Add(lineSeries); Labels = list.Select(x => x.CheckDate.ToShortDateString()).ToArray(); YFormatter = value => value.ToString("C"); OnPropertyChanged(nameof(SeriesCollection)); OnPropertyChanged(nameof(Labels)); OnPropertyChanged(nameof(YFormatter)); OnPropertyChanged(nameof(MaxPrice)); OnPropertyChanged(nameof(MinPrice)); }
private void AddToLShapeChart(ComparisonRecordInfoWrapper wrappedComparisonInfo) { double startTime = FirstSeconds; double endTime = LastSeconds; var frametimeTimeWindow = wrappedComparisonInfo.WrappedRecordInfo.Session.GetFrametimeTimeWindow(startTime, endTime, _appConfiguration, ERemoveOutlierMethod.None); var lShapeQuantiles = _frametimeAnalyzer.GetLShapeQuantiles(); double action(double q) => _frametimeStatisticProvider.GetPQuantileSequence(frametimeTimeWindow, q / 100); var quantiles = lShapeQuantiles.Select(q => new ObservablePoint(q, action(q))); var quantileValues = new ChartValues <ObservablePoint>(); quantileValues.AddRange(quantiles); ComparisonLShapeCollection.Add( new LineSeries { Id = wrappedComparisonInfo.WrappedRecordInfo.FileRecordInfo.Id, Values = quantileValues, Stroke = wrappedComparisonInfo.IsHideModeSelected ? Brushes.Transparent : wrappedComparisonInfo.Color, Fill = Brushes.Transparent, StrokeThickness = 1, LineSmoothness = 1, PointGeometrySize = 5, PointGeometry = DefaultGeometries.Square, PointForeground = wrappedComparisonInfo.IsHideModeSelected ? Brushes.Transparent : wrappedComparisonInfo.Color, LabelPoint = chartPoint => string.Format(CultureInfo.InvariantCulture, "{0:0.##}", chartPoint.Y, "ms") }); }
private void ConvertData(ObservableCollection <ContinentPollution> continentPollutions) { List <double> tempPollution = new List <double>(); List <string> tempYears = new List <string>(); for (int i = 0; i < continentPollutions.Count; i++) { tempPollution.Add(continentPollutions[i].Pollution); tempYears.Add(continentPollutions[i].Year.ToString()); } var tempP = new ChartValues <double>(); tempP.AddRange(tempPollution); SeriesCollection sc = new SeriesCollection { new LineSeries { Title = "Pollution", Values = tempP } }; Labels = tempYears.ToArray(); ContinentPollutionData = sc; }
public void AddToPlotdB(IEnumerable <double> x, IEnumerable <double> y, string title, int index) { //modifying the series collection will animate and update the chart ChartValues <ObservablePoint> nove = new ChartValues <ObservablePoint>(); ObservablePoint[] points = new ObservablePoint[x.Count()]; for (var i = 0; i < x.Count(); ++i) { points[i] = new ObservablePoint { X = x.ElementAt(i), Y = 20 * Math.Log10(y.ElementAt(i)) }; } nove.AddRange(points); if (SeriesCollection.Count < index + 1) { SeriesCollection.Add(new LineSeries()); } SeriesCollection.CurrentSeriesIndex = index; if (index == 0 && SeriesCollection.Count > 1) { SeriesCollection.RemoveAt(1); } SeriesCollection[index] = (new LineSeries { Title = title, Values = nove.AsGearedValues().WithQuality(Quality.Medium), LineSmoothness = 0, //0: straight lines, 1: really smooth lines //PointGeometry = Geometry.Parse("m 25 70.36218 20 -28 -20 22 -8 -6 z"), PointGeometry = DefaultGeometries.Circle, PointGeometrySize = 1, Fill = Brushes.Transparent }); }
public void DrawChart(ref ToolStripMenuItem btn, IEnumerable <double> dataSet) { chartValues.Clear(); if (btn.Checked && dataSet.Count() != 0) { chartValues.AddRange(dataSet.Reverse().Take(360).Reverse()); } }
private static ChartValues <ObservablePoint> GetFunctionResult(IFuzzyFunction func) { var result = new ChartValues <ObservablePoint>(); var points = FuzzyFunctionToChartValuesConvertor.GetValues(func); result.AddRange(points); return(result); }
private void Read3() { // double x = 1528.5; // double y = 6.55733501913825e-46; float x; float y; List <(ushort x, ushort y)> ulist = new List <(ushort x, ushort y)>(); List <(float x, float y)> fllist = new List <(float x, float y)>(); var list = ChartValues.ToList(); while (IsReading) { Thread.Sleep(500); ushort[] b = ModbusCommand.command.Operation(Getter.channel_spectral_ch1); ulist.Add((b[0], b[1])); x = ((float)b[0]) / 1000 + 1520; y = Utility.GetSingle(0, b[1]); fllist.Add((x, y)); MeasureModel m = new MeasureModel { ValueX = (double)x, ValueY = (double)y }; list.Add(m); try { list = list.OrderBy(t => t.ValueX).ToList(); ChartValues.Clear(); ChartValues.AddRange(list); } catch (Exception e) { var t = e; } // ChartValues = v1; //ChartValues.Add(new MeasureModel //{ // ValueX = x, // ValueY = y // // DateTime = now, // // Value = _trend //}); // SetAxisLimits(now); // if (ChartValues.Count > 100) ChartValues.RemoveAt(0); } //var x1 = fllist.Select(b => b.x); //var y1 = fllist.Select(b => b.y); //float maxx = x1.Max(); //float minx = x1.Min(); //float maxy = y1.Max(); //float miny = y1.Min(); }
private void createChart2() { var today = DateTime.Today; var month = new DateTime(today.Year, today.Month, 1); var lastMonth = month.AddMonths(-4); var invoices = new double[4]; var receipts = new double[4]; var expenses = new double[4]; Labels2 = new string[4]; for (var i = 0; i < 4; i++) { receipts[i] = ReceiptViewModel.getTotalReceiptsMonthYear(lastMonth.Month, lastMonth.Year) + InvoiceViewModel.getPaidInvoicesbyMonthYear(lastMonth.Month, lastMonth.Year);; invoices[i] = InvoiceViewModel.getTotalSalesMonthYear(lastMonth.Month, lastMonth.Year); expenses[i] = ExpensesViewModel.getTotalExpensesMonthYear(lastMonth.Month, lastMonth.Year); Labels2[i] = lastMonth.Month.ToString(); lastMonth = lastMonth.AddMonths(1); } var totalReceipt = new ChartValues <double>(); totalReceipt.AddRange(receipts); var total = new ChartValues <double>(); total.AddRange(invoices); var totalExpenses = new ChartValues <double>(); totalExpenses.AddRange(expenses); SeriesCollection2 = new SeriesCollection { new ColumnSeries { Title = "Sales", Values = total }, new ColumnSeries { Title = "Receipts", Values = totalReceipt }, new ColumnSeries { Title = "Expenses", Values = totalExpenses } }; Formatter = value => value.ToString("N"); DataContext = this; }
//private string[] lab; private void Update() { double[] stock = InfoArticulos.valoresStock; IEnumerable <double> m = stock; Values.AddRange(m); Lab.AddRange(InfoArticulos.valoresFecha); Chart.Update(true); //DataContext = this; //lab = InfoArticulos.valoresFecha; }
private void SetFpsThresholdChart(IList <double> frametimes) { if (frametimes == null || !frametimes.Any()) { return; } var thresholdCounts = _frametimeStatisticProvider.GetFpsThresholdCounts(frametimes, ThresholdToggleButtonIsChecked); var thresholdCountValues = new ChartValues <double>(); thresholdCountValues.AddRange(thresholdCounts.Select(val => (double)val / frametimes.Count)); var thresholdTimes = _frametimeStatisticProvider.GetFpsThresholdTimes(frametimes, ThresholdToggleButtonIsChecked); var thresholdTimesValues = new ChartValues <double>(); thresholdTimesValues.AddRange(thresholdTimes.Select(val => val / frametimes.Sum())); Application.Current.Dispatcher.Invoke(new Action(() => { if (!ShowThresholdTimes) { YAxisLabel = "Frames"; FPSThresholdCollection = new SeriesCollection { new ColumnSeries { Values = thresholdCountValues, Fill = new SolidColorBrush(Color.FromRgb(34, 151, 243)), DataLabels = true, LabelPoint = p => ThresholdPercentageButtonIsChecked ? (frametimes.Count * p.Y).ToString() : (100 * p.Y).ToString("N1", CultureInfo.InvariantCulture) + "%", MaxColumnWidth = 40 } }; } else { YAxisLabel = "Time"; FPSThresholdCollection = new SeriesCollection { new ColumnSeries { Values = thresholdTimesValues, Fill = new SolidColorBrush(Color.FromRgb(34, 151, 243)), DataLabels = true, LabelPoint = p => ThresholdPercentageButtonIsChecked ? ((frametimes.Sum() * p.Y) * 1E-03).ToString("N1", CultureInfo.InvariantCulture) + "s" : (100 * p.Y).ToString("N1", CultureInfo.InvariantCulture) + "%", MaxColumnWidth = 40 } }; } })); }
public double expcalkawielomian(double a, double b, double[] poly, int v) { var vals = new ChartValues <ObservablePoint>(); //ofstream plik; //string filename("nodes" + std::to_string(v)); //plik.open(filename); double result = 0, x = 0, fx = 0; double h = (b - a) / v; for (int i = 0; i <= v; i++) { x = a + i * h; fx = exphorner(x, poly); vals.Add(new ObservablePoint(x, fx)); points.Add(new ObservablePoint(x, fx)); //plik << x << " " << fx << endl; if (i == 0 || i == v) { result += fx; } else if (i % 2 != 0) { result += 4 * fx; } else { result += 2 * fx; } } result *= (h / 3); nodesPoints.AddRange(vals); var pointsToAdd = nodesPoints.GroupBy(y => y.X).Where(c => c.Count() == 1).Select(z => z.First()).OrderBy(w => w.X).ToList(); values.Add(new ChartValues <ObservablePoint>(pointsToAdd)); //plik.close(); return(result); /*double simp = 0, blad = 0, s = 0, x = 0; * double h = (b - a) / v; * for (int i = 1; i <= v; i++) * { * x = a + i * h; * blad += exphorner(x - (h / 2), poly); * if (i < v) * { * s += (exphorner(x, poly)); * } * } * return (h / 6)*(exphorner(a, poly) + exphorner(b, poly) + 2 * s + 4 * blad);*/ }
private async void AddButton_Click(object sender, EventArgs e) { addButton.Enabled = false; var data = await Task <List <XY> > .Factory.StartNew(() => Crypto.CompareNWithTotient(_size, _size, 100, false)); var newMax = data.Max(p => p.NDouble) > ChartValues.Max(p => p.NDouble); ChartValues.AddRange(data); CalculateRegression(); addButton.Enabled = true; }
public void MyAction() { try { #region Update TxtOutput string txtSalida = string.Empty; string txtEntrada = String.Copy(TxtInput); string salto = "\n"; txtEntrada.Replace(salto, ""); double[] data = TxtInput.Split(';').Select(n => Convert.ToDouble(n)).ToArray(); txtSalida += "Minimum: " + data.Minimum(); txtSalida += salto + "Maximum: " + data.Maximum(); txtSalida += salto + "Count: " + data.Count(); txtSalida += salto + "Mean: " + data.Mean(); txtSalida += salto + "Median: " + data.Median(); txtSalida += salto + "Variance: " + data.Variance(); txtSalida += salto + "StandardDeviation: " + data.StandardDeviation(); txtSalida += salto + "MaximumAbsolute: " + data.MaximumAbsolute(); txtSalida += salto + "MinimumAbsolute: " + data.MinimumAbsolute(); TxtOutput = txtSalida; #endregion #region Update Chart Line ChartValues<double> cv = new ChartValues<double>(); cv.AddRange(data); var lineSerie = new LineSeries { Title = "Values", Values = cv, }; //Bug Series.clear() while (series.Count > 0) { series.RemoveAt(series.Count - 1); } series.Add(lineSerie); #endregion } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }