private void OnAppendData(int pointCount)
 {
     using (sciChart.SuspendUpdates())
     {
         var next = _generator.GetRandomPoints(pointCount);
         _xyDataSeries.Clear();
         _xyDataSeries.Append(next.XData, next.YData);
     }
 }
        private void DisplayEntryDistribution(object sender, RoutedEventArgs e)
        {
            if (!isLoaded)
            {
                return;
            }

            if (globallyFilteredEntries.Count == 0)
            {
                distributionDS.Clear();
                return;
            }


            Dictionary <int, int> freqDist = new Dictionary <int, int>();

            var groupedUsers =
                from entry in globallyFilteredEntries
                group entry by entry.KeyholderID into userGroup
                orderby userGroup.Count()
                select userGroup;

            foreach (var userGroup in groupedUsers)
            {
                if (!freqDist.ContainsKey(userGroup.Count()))
                {
                    freqDist.Add(userGroup.Count(), 1);
                }
                else
                {
                    freqDist[userGroup.Count()]++;
                }
            }

            int[] numberOfusers = new int[freqDist.Last().Key + 1];

            foreach (var fd in freqDist)
            {
                numberOfusers[fd.Key] = fd.Value;
            }

            distributionDS.Clear();
            var xs = Enumerable.Range(0, numberOfusers.Count() - 1);

            for (int i = 0; i < numberOfusers.Count(); i++)
            {
                distributionDS.Append(i, numberOfusers[i]);
            }
        }
Esempio n. 3
0
        private void OnUpdatedData(double randomness, double curviness)
        {
            var someDummyData = CreateSomeScatterData(randomness, curviness);

            _originalData.Clear();
            _originalData.Append(someDummyData.XData, someDummyData.YData);
        }
Esempio n. 4
0
        private void Reset()
        {
            if (g_isRunning)
            {
                Pause();
            }

            using (g_accelX_Surface.SuspendUpdates())
            {
                g_accelX_MeanSeries.Clear();
                g_accelX_VarSeries.Clear();
            }
            using (g_accelY_Surface.SuspendUpdates())
            {
                g_accelY_MeanSeries.Clear();
                g_accelY_VarSeries.Clear();
            }
            using (g_accelZ_Surface.SuspendUpdates())
            {
                g_accelZ_MeanSeries.Clear();
                g_accelZ_VarSeries.Clear();
            }

            g_accelX_XValue = 0;
            g_accelY_XValue = 0;
            g_accelZ_XValue = 0;
        }
Esempio n. 5
0
        public void SetSecurity(string board, string seccode)
        {
            if (Seccode == seccode)
            {
                return;
            }
            TickDataHandler.UnsubscribeFromTicksEvent(TicksToCandles);
            TXmlConnector.SendNewCandles -= ProcessCandles;
            OhlcDataSeries.Clear();
            XyDataSeries.Clear();
            StockChartAnnotations = new AnnotationCollection();
            Board       = board;
            Seccode     = seccode;
            _lastCandle = null;
            Task.Run(() => GetHistory());
            BubbleSeries.Clear();
            GetBubbleData();
            var volumes = TickDataHandler.AddChartSubscription(Board, Seccode, TicksToCandles);

            HorizontalVolumesBuy  = volumes[0];
            HorizontalVolumesSell = volumes[1];
            UpdateWindowInstrument();
            DragStep = Application.Current.Dispatcher
                       .Invoke(() => MainWindowViewModel.SecVm._secList
                               .First(s => s.Board == Board && s.Seccode == Seccode).Minstep);
            GetOrders();
        }
        private void OnUpdatedData(double randomness, double curviness)
        {
            var someDummyData = CreateSomeScatterData(randomness, curviness);

            _originalData.Clear();
            _originalData.Append(someDummyData.XData.Select(x => TimeSpan.FromSeconds(x)), someDummyData.YData);
        }
Esempio n. 7
0
        public override void FilterAll()
        {
            _filteredDataSeries.Clear();

            int    index = 0;
            double animationStepMillisconds = 1;

            Action appendPoint = null;

            Action onAppendCallback = () =>
            {
                // 2.) Append the point
                _filteredDataSeries.Append(_originalDataSeries.XValues[index], _originalDataSeries.YValues[index]);
                _filteredDataSeries.InvalidateParentSurface(RangeMode.ZoomToFit);

                // 3.) Schedule another until complete
                if (++index < _originalDataSeries.Count)
                {
                    // Achieve some rudimentary easing
                    animationStepMillisconds *= 1.05;
                    animationStepMillisconds  = Math.Min(animationStepMillisconds, 10);

                    // Next point
                    appendPoint();
                }
            };

            appendPoint = () =>
            {
                TimedMethod.Invoke(onAppendCallback).After((int)animationStepMillisconds).Go();
            };

            // 1.) Schedule one point to be appended
            appendPoint();
        }
Esempio n. 8
0
 public void RedrawAll()
 {
     //Attention : Permet de déclencher l'update : workaround pas classe du tout
     lineData.Clear();
     lineData.Append(1, 1);
     DataSeries = lineData;
 }
Esempio n. 9
0
        public XyDataSeries <double, double> GetRobotLidarPoints()
        {
            var dataSeries = new XyDataSeries <double, double>();

            if (lidarMap == null)
            {
                return(dataSeries);
            }

            var listX = lidarMap.Select(e => e.X);
            var listY = lidarMap.Select(e => e.Y);

            //int nbSteps = 1000;
            //List<double> listX = new List<double>();
            //List<double> listY = new List<double>();
            //for (int i = 0; i < nbSteps + 1; i++)
            //{
            //    listX.Add(location.X + (4.0f + 2 * rand.Next(-50, 50) / 100.0) * Math.Cos((double)i * (2 * Math.PI / nbSteps)));
            //    listY.Add(location.Y + (4.0f + 2 * rand.Next(-50, 50) / 100.0) * Math.Sin((double)i * (2 * Math.PI / nbSteps)));
            //}
            dataSeries.Clear();
            dataSeries.AcceptsUnsortedData = true;
            dataSeries.Append(listX, listY);
            return(dataSeries);
        }
        public void Dispose()
        {
            if (_xyDataSeries != null)
            {
                _xyDataSeries.Clear();
                _xyDataSeries = null;
            }

            _testRunner.Dispose();
        }
Esempio n. 11
0
        private void Reset()
        {
            if (_isRunning)
            {
                Pause();
            }

            _ds1.Clear();
            _ds2.Clear();
            _ds3.Clear();
        }
        public void Dispose()
        {
            this.sciChart.Dispose();
            if (_xyDataSeries != null)
            {
                _xyDataSeries.Clear();
                _xyDataSeries = null;
            }

            _testRunner.Dispose();
        }
        public void OffsetSeries(XyDataSeries <DateTime, double> series, double offset)
        {
            var originalXData = series.XValues.ToArray();
            var originalYData = series.YValues.ToArray();

            // To Offset the series, clear and recreate data
            using (series.SuspendUpdates())
            {
                series.Clear();
                series.Append(originalXData, originalYData.Select(y => y + offset));
            }
        }
        private void Reset()
        {
            if (_isRunning)
            {
                Pause();
            }

            using (Surface.SuspendUpdates())
            {
                _dataSeries.Clear();
                _t      = 0;
                _yValue = 0;
            }
        }
        private void Reset()
        {
            if (_isRunning)
            {
                Pause();
            }

            _mainSeries.Clear();
            _maLowSeries.Clear();
            _maHighSeries.Clear();

            _maLow.Clear();
            _maHigh.Clear();
        }
        private void Reset()
        {
            if (_isRunning)
            {
                Pause();
            }

            using (Surface.SuspendUpdates())
            {
                _ds1.Clear();
                _ds2.Clear();
                _ds3.Clear();
            }
        }
Esempio n. 17
0
        public override void FilterAll()
        {
            // When FilterAll is called, recreate the FilteredDataSeries and apply the filtering.
            _filteredDataSeries.Clear();
            _filteredDataSeries.Append(_originalDataSeries.XValues[0], _originalDataSeries.YValues[0]);

            const double beta = 0.2;

            // Implementing a simple low pass filter https://kiritchatterjee.wordpress.com/2014/11/10/a-simple-digital-low-pass-filter-in-c/
            for (int i = 1; i < _originalDataSeries.Count; i++)
            {
                double xValue = _originalDataSeries.XValues[i];
                double yValue = beta * _originalDataSeries.YValues[i] + (1 - beta) * _filteredDataSeries.YValues[i - 1];
                _filteredDataSeries.Append(xValue, yValue);
            }
        }
Esempio n. 18
0
        private void Reset()
        {
            if (_isRunning)
            {
                Pause();
            }

            using (Surface.SuspendUpdates())
            {
                _t = 0;
                _xVisibleRange.SetMinMaxDouble(-GrowBy, VisibleRangeMax + GrowBy);

                _ds1.Clear();
                _ds2.Clear();
                _ds3.Clear();
            }
        }
        private void Reset()
        {
            if (_isRunning)
            {
                Pause();
            }

            using (Surface.SuspendUpdates())
            {
                _mainSeries.Clear();
                _maLowSeries.Clear();
                _maHighSeries.Clear();
            }

            _maLow.Clear();
            _maHigh.Clear();
        }
Esempio n. 20
0
        public override void InitExampleForUiTest()
        {
            base.InitExampleForUiTest();

            lock (_syncRoot)
            {
                Stop();

                _series0.Clear();
                _series1.Clear();

                _currentIndex = _totalIndex = 0;

                for (var i = 0; i < 5000; i++)
                {
                    AppendPoint(400);
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Add decoded data into this class.
        /// </summary>
        /// <param name="package">Decoded data package</param>
        public void GetSensorData(Format.DataPackage package)
        {
            Temperature   = package.Temperature;
            BatteryLevel  = package.Battery;
            Pressure      = package.Pressure;
            WindSpeed     = package.WindSpeed;
            WindDirection = package.WindDirection;
            Huminity      = package.Huminity;
            NotifyPropertyChanged("BatteryString");
            Status     = StatusValue.Ok;
            lastUpdate = DateTime.Now;
            if (this.SensorType == SensorInfo.Types.Anemometer)
            {
                WindPlot.Clear();
                WindPlot.Append(ConvertToDouble(WindDirection, Type.WindDirection), ConvertToDouble(WindSpeed, Type.WindSpeed));
                return;
            }
            if (this.SensorType == SensorInfo.Types.Humidity)
            {
                return;
            }

            double[] pressureL = new double[10];
            for (int i = 0; i < 10; i++)
            {
                pressureL[i] = ConvertToDouble(package.PressureList[i], Type.Pressure);
            }
            PressureLine.Append(package.TimeSeries, pressureL);
            lock (locker)
            {
                AddData(ref Pressure3s, package.TimeSeries, package.PressureList, -3);
                NotifyPropertyChanged("PressureAvg3s");
                NotifyPropertyChanged("PressureMax3s");
                NotifyPropertyChanged("PressureMin3s");
                AddData(ref Pressure5m, package.TimeSeries, package.PressureList, -300);
                NotifyPropertyChanged("PressureAvg5m");
                NotifyPropertyChanged("PressureMax5m");
                NotifyPropertyChanged("PressureMin5m");
            }
        }
        public override void InitExampleForUiTest()
        {
            base.InitExampleForUiTest();

            _marketDataService.ClearSubscriptions();

            _xyDataSeries.Clear();
            _ohlcDataSeries.Clear();
            _sma50.Clear();
            _lastPrice = default(PriceBar);

            var marketDataService = new MarketDataService(new DateTime(2000, 08, 01, 12, 00, 00), 5, 20);

            // add initizal data
            InitData(marketDataService);

            // perform zoom extents to restore default VisibleRange
            MainSurface.ZoomExtentsX();

            // add one price bar to update location of annotations
            OnNewPrice(marketDataService.GetNextBar());
        }
Esempio n. 23
0
        public void Dispose()
        {
            if (_mainSeries != null)
            {
                _mainSeries.Clear();
                _mainSeries = null;
            }

            if (_maLowSeries != null)
            {
                _maLowSeries.Clear();
                _maLowSeries = null;
            }

            if (_maHighSeries != null)
            {
                _maHighSeries.Clear();
                _maHighSeries = null;
            }

            _testRunner.Dispose();
        }
Esempio n. 24
0
        private void MainMenu_FileOpen_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "XLSX files (*.xlsx)|*.xlsx|JSON files (*.json)|*.json";

            if (openFileDialog.ShowDialog() == true)
            {
                try
                {
                    string extension = System.IO.Path.GetExtension(openFileDialog.FileName);

                    if (extension == ".xlsx")
                    {
                        LoadDataSource(new Reporter(new XLSXLoader(openFileDialog.FileName)));
                    }
                    else if (extension == ".json")
                    {
                        LoadDataSource(new Reporter(new JSONLoader(openFileDialog.FileName)));
                    }
                    else
                    {
                        throw new Exception();
                    }
                    dataSeries.Clear();

                    ohlcSeries.Clear();
                    StockChart.Annotations.Clear();
                    indicatorChar.Annotations.Clear();
                    ReloadChartSeries();
                    //LineSeries
                }
                catch (Exception er)
                {
                    MessageBox.Show("Произошла ошибка загрузки данных", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Esempio n. 25
0
        private void UpdateXyDataSeries()
        {
            lock (this)
            {
                for (int i = 0; i < 1024; i++)
                {
                    _re[i] = 2.0 * Math.Sin(2 * Math.PI * i / 20) +
                             5 * Math.Sin(2 * Math.PI * i / 10) +
                             2.0 * _random.NextDouble();
                    _im[i] = -10;
                }

                _transform.run(_re, _im);
                for (int i = 0; i < 1024; i++)
                {
                    double mag = Math.Sqrt(_re[i] * _re[i] + _im[i] * _im[i]);
                    _re[i] = 20 * Math.Log10(mag / 1024);
                    _im[i] = i;
                }

                _xyDataSeries.Clear();
                _xyDataSeries.Append(_im, _re);
            }
        }
        private void DisplayEntriesAll(object sender, RoutedEventArgs e)
        {
            if (!isLoaded)
            {
                return;
            }

            if (globallyFilteredEntries.Count == 0)
            {
                entriesAllDS.Clear();
                return;
            }


            Dictionary <DateTime, List <int> > allEntriesDictionary = new Dictionary <DateTime, List <int> >();
            //Dictionary<DateTime, int> allEntriesDictionary = new Dictionary<DateTime, int>();

            long windowTicks = GetBinTimeSpan(entriesAllWindow).Ticks;

            DateTime startingDate = (DateTime)startDate.SelectedDate;
            long     endingTicks  = ((DateTime)endDate.SelectedDate).Date.Ticks + TimeSpan.TicksPerDay;
            int      entryPtr     = 0;
            DateTime key;
            long     keyTicks = globallyFilteredEntries.First().dateTime.Date.Ticks;

            // Calculate a count for each day of week in total date range
            do
            {
                key = new DateTime(keyTicks);
                allEntriesDictionary.Add(key, new List <int>());
                //allEntriesDictionary.Add(key, 0);

                while ((globallyFilteredEntries[entryPtr++].dateTime.Ticks < (keyTicks + windowTicks)) &&
                       (entryPtr < globallyFilteredEntries.Count))
                {
                    allEntriesDictionary[key].Add(globallyFilteredEntries[entryPtr++].KeyholderID);
                    //allEntriesDictionary[key]++;
                    if (entryPtr == globallyFilteredEntries.Count)
                    {
                        break;
                    }
                }
                keyTicks += windowTicks;
            } while ((keyTicks <= endingTicks) && (entryPtr < globallyFilteredEntries.Count));

            entriesAllDS.Clear();
            if ((bool)chkAllEntriesUnique.IsChecked)
            {
                foreach (var periodEntries in allEntriesDictionary)
                {
                    entriesAllDS.Append(periodEntries.Key, periodEntries.Value.Distinct().Count());
                }
            }
            else
            {
                foreach (var periodEntries in allEntriesDictionary)
                {
                    entriesAllDS.Append(periodEntries.Key, periodEntries.Value.Count());
                }
            }
            //var keys = allEntriesDictionary.Keys.ToList();
            //var values = allEntriesDictionary.Values.ToList();
            //entriesAllDS.Append(allEntriesDictionary.Keys, allEntriesDictionary.Values);
        }
        private void DisplayEntriesByDay(object sender, RoutedEventArgs e)
        {
            if (!isLoaded)
            {
                return;
            }
            if (globallyFilteredEntries.Count == 0)
            {
                entriesByDayDS.Clear();
                return;
            }

            Dictionary <DateTime, Dictionary <TimeSpan, List <int> > > allDayGroups = new Dictionary <DateTime, Dictionary <TimeSpan, List <int> > >();

            long     windowTicks = GetBinTimeSpan(entriesByDayWindow).Ticks;
            DateTime dateKey;

            // Then add the ID for each entry falling in a bin
            foreach (var entry in globallyFilteredEntries)
            {
                dateKey = entry.dateTime.Date;
                if (!allDayGroups.ContainsKey(dateKey))
                {
                    allDayGroups.Add(dateKey, CreateDayGroup(windowTicks));
                }
                allDayGroups[dateKey][GetTimeSpanForDay(entry, windowTicks)].Add(entry.KeyholderID);
            }

            // Exclude first and/or last week if requested
            if ((bool)chkEntriesByDayExcludeLast.IsChecked)
            {
                allDayGroups.Remove(allDayGroups.Last().Key);
            }
            if ((bool)chkEntriesByDayExcludeFirst.IsChecked)
            {
                allDayGroups.Remove(allDayGroups.First().Key);
            }

            // Sum up all days
            bool unique = (bool)chkEntriesByDayUnique.IsChecked;
            Dictionary <TimeSpan, int> groupedInDay = new Dictionary <TimeSpan, int>();
            int i = 0;

            while (i * windowTicks < TimeSpan.TicksPerDay)
            {
                groupedInDay.Add(new TimeSpan(i++ *windowTicks), 0);
            }

            foreach (var dayGroupKey in allDayGroups.Keys)
            {
                foreach (var binGroup in allDayGroups[dayGroupKey])
                {
                    if (unique)
                    {
                        groupedInDay[binGroup.Key] += binGroup.Value.Distinct().Count();
                    }
                    else
                    {
                        groupedInDay[binGroup.Key] += binGroup.Value.Count();
                    }
                }
            }

            // Set chart x/y values
            int scaleFactor = 1;

            if ((bool)entriesByDayShowAverage.IsChecked)
            {
                scaleFactor = allDayGroups.Count;
            }

            entriesByDayDS.Clear();

            foreach (var grouping in groupedInDay)
            {
                entriesByDayDS.Append(grouping.Key, grouping.Value / scaleFactor);
            }
        }
        private void DisplayEntriesByWeek(object sender, RoutedEventArgs e)
        {
            if (!isLoaded)
            {
                return;
            }
            if (globallyFilteredEntries.Count == 0)
            {
                entriesByWeekDS.Clear();
                return;
            }

            // Dictionary with each entry holding a weeks worth of data
            Dictionary <string, Dictionary <TimeSpan, List <int> > > allWeekGroups = new Dictionary <string, Dictionary <TimeSpan, List <int> > >();
            long windowTicks = GetBinTimeSpan(entriesByWeekWindow).Ticks;

            DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;

            System.Globalization.Calendar cal = dfi.Calendar;
            string weekGroupsKey;

            foreach (var entry in globallyFilteredEntries)
            {
                weekGroupsKey = entry.dateTime.Year.ToString() + "-" + cal.GetWeekOfYear(entry.dateTime, dfi.CalendarWeekRule, dfi.FirstDayOfWeek).ToString();
                if (!allWeekGroups.ContainsKey(weekGroupsKey))
                {
                    allWeekGroups.Add(weekGroupsKey, CreateWeekGroup(windowTicks));
                }

                allWeekGroups[weekGroupsKey][GetTimeSpanForWeek(entry, windowTicks)].Add(entry.KeyholderID);
            }

            // Exclude first and/or last week if requested
            if ((bool)chkEntriesByWeekExcludeLast.IsChecked)
            {
                allWeekGroups.Remove(allWeekGroups.Last().Key);
            }
            if ((bool)chkEntriesByWeekExcludeFirst.IsChecked)
            {
                allWeekGroups.Remove(allWeekGroups.First().Key);
            }

            // Sum up all weeks
            bool unique = (bool)chkEntriesByWeekUnique.IsChecked;
            Dictionary <TimeSpan, int> groupedInWeek = new Dictionary <TimeSpan, int>();
            int i = 0;

            while (i * windowTicks < 7 * TimeSpan.TicksPerDay)
            {
                groupedInWeek.Add(new TimeSpan(i++ *windowTicks), 0);
            }

            foreach (var weekGroupKey in allWeekGroups.Keys)
            {
                foreach (var binGroup in allWeekGroups[weekGroupKey])
                {
                    if (unique)
                    {
                        groupedInWeek[binGroup.Key] += binGroup.Value.Distinct().Count();
                    }
                    else
                    {
                        groupedInWeek[binGroup.Key] += binGroup.Value.Count();
                    }
                }
            }

            // Set chart x/y values
            int[]    dayOfWeekCount = new int[7];
            int      count          = 0;
            DateTime startingDate   = (DateTime)startDate.SelectedDate;
            DateTime endingDate     = (DateTime)endDate.SelectedDate;

            // Correct for DateTime.MinValue being a Sunday so when TimeSpan key is converted back to date the correct day of week is displayed
            long dayOfWeekOffset = 6 * TimeSpan.TicksPerDay;

            if ((bool)entriesByWeekShowAverage.IsChecked)
            // Calculate a count for each day of week in total date range
            {
                do
                {
                    dayOfWeekCount[(int)((startingDate.AddDays(count)).DayOfWeek)]++;
                } while (startingDate.AddDays(++count) <= endingDate.Date);
            }

            for (int d = 0; d < dayOfWeekCount.Length; d++)
            {
                if (dayOfWeekCount[d] == 0)
                {
                    dayOfWeekCount[d]++;
                }
            }

            entriesByWeekDS.Clear();
            DateTime key;

            foreach (var grouping in groupedInWeek)
            {
                key = new DateTime(grouping.Key.Ticks + dayOfWeekOffset);
                entriesByWeekDS.Append(new DateTime(grouping.Key.Ticks), grouping.Value / dayOfWeekCount[(int)key.DayOfWeek]);
            }
        }
        private void DisplayEntriesByMonth(object sender, RoutedEventArgs e)
        {
            if (!isLoaded)
            {
                return;
            }

            if (globallyFilteredEntries.Count == 0)
            {
                entriesByMonthDS.Clear();
                return;
            }
            // Dictionary with each entry holding a months worth of data
            Dictionary <string, Dictionary <TimeSpan, List <int> > > allMonthGroups = new Dictionary <string, Dictionary <TimeSpan, List <int> > >();
            long windowTicks = GetBinTimeSpan(entriesByMonthWindow).Ticks;

            string monthGroupsKey;

            foreach (var entry in globallyFilteredEntries)
            {
                monthGroupsKey = entry.dateTime.Year.ToString() + "-" + entry.dateTime.Month.ToString();
                if (!allMonthGroups.ContainsKey(monthGroupsKey))
                {
                    allMonthGroups.Add(monthGroupsKey, CreateMonthGroup(windowTicks));
                }

                allMonthGroups[monthGroupsKey][GetTimeSpanForMonth(entry, windowTicks)].Add(entry.KeyholderID);
            }

            // Exclude first and/or last month if requested
            if ((bool)chkEntriesByMonthExcludeLast.IsChecked)
            {
                allMonthGroups.Remove(allMonthGroups.Last().Key);
            }
            if ((bool)chkEntriesByMonthExcludeFirst.IsChecked)
            {
                allMonthGroups.Remove(allMonthGroups.First().Key);
            }

            // Sum up all months
            bool unique = (bool)chkEntriesByMonthUnique.IsChecked;
            Dictionary <TimeSpan, int> groupedInMonth = new Dictionary <TimeSpan, int>();
            int i = 0;

            while (i * windowTicks < 32 * TimeSpan.TicksPerDay)
            {
                groupedInMonth.Add(new TimeSpan(i++ *windowTicks), 0);
            }

            foreach (var monthGroupKey in allMonthGroups.Keys)
            {
                foreach (var binGroup in allMonthGroups[monthGroupKey])
                {
                    if (unique)
                    {
                        groupedInMonth[binGroup.Key] += binGroup.Value.Distinct().Count();
                    }
                    else
                    {
                        groupedInMonth[binGroup.Key] += binGroup.Value.Count();
                    }
                }
            }

            // Set chart x/y values
            int[] dayOfMonthCount = new int[32];
            int   count           = 0;
            bool  showAverage     = (bool)entriesByMonthShowAverage.IsChecked;

            // Calculate a count for each day of month in total date range
            if (showAverage)
            {
                DateTime startingDate = (DateTime)startDate.SelectedDate;
                DateTime endingDate   = (DateTime)endDate.SelectedDate;
                do
                {
                    dayOfMonthCount[(int)((startingDate.AddDays(count)).Day) - 1]++;
                } while (startingDate.AddDays(++count) <= endingDate.Date);
            }

            for (int d = 0; d < dayOfMonthCount.Length; d++)
            {
                if (dayOfMonthCount[d] == 0)
                {
                    dayOfMonthCount[d]++;
                }
            }

            entriesByMonthDS.Clear();
            DateTime key;

            foreach (var grouping in groupedInMonth)
            {
                if (grouping.Key.Ticks >= TimeSpan.TicksPerDay)
                {
                    key = new DateTime(grouping.Key.Ticks - TimeSpan.TicksPerDay);
                    entriesByMonthDS.Append(key, grouping.Value / dayOfMonthCount[(int)key.Day - 1]);
                }
            }
        }
Esempio n. 30
0
 private void ResetData()
 {
     _oxygenData.Clear();
     _temperatureData.Clear();
     _pressureData.Clear();
 }