Exemple #1
0
        public static TimeSeriesPlotInfo Create(
            TimeSeries series = null,
            Type seriesType   = null,
            string title      = null,
            Color?color       = null,
            Func <DateValue, Color> colorFunction = null,
            Func <Color, string> legendFunction   = null,
            MarkerType markerType = MarkerType.None,
            LineStyle lineStyle   = LineStyle.None,
            int plotOrder         = 0)
        {
            TimeSeriesPlotInfo result = new TimeSeriesPlotInfo
            {
                Series     = series,
                SeriesType = seriesType ?? typeof(FunctionSeries),
                LineStyle  = lineStyle,
                Marker     = markerType
            };

            if (color != null)
            {
                result.Color = color.Value;
            }
            if (colorFunction != null)
            {
                result.ColorFunction = colorFunction;
            }
            if (result.Color == null &&
                result.ColorFunction == null)
            {
                result.Color = Color.Blue;
            }

            if (!string.IsNullOrEmpty(title))
            {
                result.Title = title;
            }
            if (legendFunction != null)
            {
                result.LegendTitleFunction = legendFunction;
            }
            if (string.IsNullOrEmpty(result.Title) &&
                result.LegendTitleFunction == null)
            {
                result.Title = string.IsNullOrEmpty(series?.Name)
                    ? "NO NAME"
                    : series.Name;
            }

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Plots the autocorrelation function in a plot view.
        /// </summary>
        /// <param name="plotInfo"></param>
        /// <param name="span"></param>
        /// <param name="steps"></param>
        /// <returns></returns>
        public static PlotView GetAutocorrelationFunctionPlotView(
            TimeSeriesPlotInfo plotInfo,
            TimeSpan span,
            int steps)
        {
            TimeSeries ts = plotInfo.Series;
            CorrelationAnalysisParameters parameters = new CorrelationAnalysisParameters()
            {
                Span = span,
                NumberOfSpansInthePast   = 0,
                NumberOfSpansIntheFuture = steps
            };

            FunctionSeries series = new FunctionSeries
            {
                MarkerType = plotInfo.Marker,
                Color      = OxyColor.FromArgb(plotInfo.Color.A, plotInfo.Color.R, plotInfo.Color.G, plotInfo.Color.B),
                Title      = plotInfo.Title,
            };

            DoCorrelationAnalysis(ts, ts, parameters)
            .Where(pair => pair.TemporalGap.Ticks > 0)
            .OrderBy(pair => pair.TemporalGap.Ticks)
            .ForEach(pair =>
            {
                double x        = (int)pair.TemporalGap.DivideBy(span);
                DataPoint point = new DataPoint(x, pair.Correlation);
                series.Points.Add(point);
            });
            PlotModel model = new PlotModel();

            model.Series.Add(series);
            return(new PlotView
            {
                Model = model,
                Dock = DockStyle.Fill,
                Visible = true,
            });
        }