Esempio n. 1
0
        public TimeSeriesDataPoint Clone()
        {
            TimeSeriesDataPoint newPoint = new TimeSeriesDataPoint();
            newPoint.Value = this.Value;
            newPoint.TimeStamp = this.TimeStamp;
            newPoint.hasStepFromValue = this.hasStepFromValue;
            newPoint.stepFromValue = this.stepFromValue;
            newPoint.hasStepToValue = this.hasStepToValue;
            newPoint.stepToValue = this.stepToValue;

            return newPoint;
        }
Esempio n. 2
0
        public UIElement GetSeriesDataLabel(TimeSeriesDataPoint dataPoint)
        {
            StackPanel root = new StackPanel();
            root.Orientation = Orientation.Horizontal;
            root.Margin = new Thickness(2, 0, 2, 0);

            Ellipse legend = new Ellipse();
            legend.Width = legend.Height = 12;
            legend.Fill = new SolidColorBrush(this.StrokeColor);

            TextBlock block = new TextBlock();
            block.Text = this.Name + ": " + dataPoint.Value.ToString("#0.00");
            block.Margin = new Thickness(2, 0, 0, 0);

            root.Children.Add(legend);
            root.Children.Add(block);

            return root;
        }
Esempio n. 3
0
        public void AddPointsRange(TimeSeriesDataPoint[] points)
        {
            foreach (TimeSeriesDataPoint dp in points)
            {
                dataPoints.Add(dp.TimeStamp, dp);
            }

            if (PlotSizeChanged != null)
            {
                if (!manualRaiseResizeEvent)
                    PlotSizeChanged();
            }
        }
Esempio n. 4
0
        public void AddPoint(TimeSeriesDataPoint point)
        {
            // assuming the new point is always newer data point
            if (dataPoints.Count > 0)
            {
                if (point.TimeStamp <= dataPoints.Keys[dataPoints.Count - 1])
                {
                    //TODO: log some message here
                    return;
                }
            }

            lock (syncLock)
            {
                //assuming point is newer data
                if (isCustomTimeRange)
                {
                    DateTime maxTime = this.CustomEndTime;
                    if (point.TimeStamp > maxTime)
                    {
                        TimeSpan span = point.TimeStamp - maxTime;

                        customTimeOrigin = customTimeOrigin.AddSeconds(span.TotalSeconds);
                        customMinX = 0;
                        customMaxX = GetPointSeconds(point.TimeStamp);

                        List<DateTime> obsoleteDates = new List<DateTime>();

                        foreach (DateTime tempTime in dataPoints.Keys)
                        {
                            if (tempTime < customTimeOrigin)
                            {
                                obsoleteDates.Add(tempTime);
                            }
                            else
                                break;
                        }

                        foreach (DateTime temptime in obsoleteDates)
                        {
                            dataPoints.Remove(temptime);
                        }

                    }
                }
                else
                {
                    // remove the oldest data point
                    if (alwaysRemoveOldPointWhenAdd)
                    {
                        if (dataPoints.Count > 0)
                            dataPoints.RemoveAt(0);
                    }

                }

                dataPoints.Add(point.TimeStamp, point);
            }

            // Raise the plotsize changed event
            if (PlotSizeChanged != null)
            {
                if (!manualRaiseResizeEvent)
                    PlotSizeChanged();
            }
        }
Esempio n. 5
0
        private void ShowCurrentCoValue(List<ColoredPoint> dataPoints, TimeSeriesDataPoint dp)
        {
            if (adorner == null)
                return;

            SeriesLabel.Children.Clear();

            if (adorner.Visibility == Visibility.Visible)
            {

                foreach (ColoredPoint cpt in dataPoints)
                {
                    SeriesLabel.Children.Add(TimeSeriesData.GetColoredDataLabel(cpt));
                }

                TickerLabel.Text = dp.TimeStamp.ToLongTimeString();

            }
        }
Esempio n. 6
0
        private void InitPlotData()
        {
            foreach (TimeSeriesData series in dataSeries)
                series.GeneratePaths();

            Rect plotRect= new Rect();
            bool isFirstSeries = true;
            DateTime customStartTime = DateTime.MaxValue;
            DateTime customEndTime = DateTime.MinValue;

            foreach (TimeSeriesData series in dataSeries)
            {
                Rect rect = series.GetPlotRectangle(0.0);
                if (isFirstSeries)
                {
                    plotRect = rect;
                    isFirstSeries = false;
                }
                else
                {
                    if (plotRect.X > rect.X)
                        plotRect.X = rect.X;

                    if (plotRect.Y > rect.Y)
                        plotRect.Y = rect.Y;

                    if (plotRect.Width < rect.Width)
                        plotRect.Width = rect.Width;

                    if (plotRect.Height < rect.Height)
                        plotRect.Height = rect.Height;
                }

                DateTime origin = series.FromPointSeconds(0);
                if (customStartTime > origin)
                    customStartTime = origin;
            }

            if (dataSeries.Count > 0)
            {
                customEndTime = customStartTime.AddSeconds(plotRect.Width);
                TimeSeriesDataPoint lowerBound = new TimeSeriesDataPoint(customStartTime, plotRect.Y);
                TimeSeriesDataPoint upperBound = new TimeSeriesDataPoint(customEndTime, plotRect.Y + plotRect.Height);
                plotSeries.AddPoint(lowerBound);
                plotSeries.AddPoint(upperBound);

                plotSeries.SetPlotRectangle(plotRect);
                //plotSeries.CustomStartTime = customStartTime;
                //plotSeries.CustomEndTime = customEndTime;
            }
        }
Esempio n. 7
0
        private TimeSeriesDataPoint GetInterpolatedDataPointFromMouseCoordinates(TimeSeriesData Series, Point mousePos)
        {
            TimeSeriesDataPoint dataPoint = new TimeSeriesDataPoint();
            dataPoint.TimeStamp = DateTime.Now;
            dataPoint.Value = double.NaN;

            Point pos = mousePos;
            pos.Y = ChartInteractiveCanvas.ActualHeight - pos.Y;

            GeneralTransform inverse = shapeTransform.Inverse;
            if (inverse != null)
            {
                pos = inverse.Transform(pos);
                DateTime xVal = Series.FromPointSeconds(pos.X);
                double yVal = Series.GetClosedInterpolatedValue(xVal);

                dataPoint.TimeStamp = xVal;
                dataPoint.Value = yVal;

            }

            return dataPoint;
        }