Exemplo n.º 1
0
        public IPlotMetricBuilder AddMetric(string metricNamespace, string metricName)
        {
            var metric = new PlotMetric(metricNamespace, metricName, this);

            metrics.Add(metric);
            return(metric);
        }
Exemplo n.º 2
0
        public Series BuildSeries(PlotMetric metric, IList <Datapoint> dataPoints)
        {
            switch (metric.GraphType)
            {
            case GraphType.Area:
                return(BuildXYSeries(metric, dataPoints, new AreaSeries {
                    StrokeThickness = 1.5d
                }));

            case GraphType.Stair:
                return(BuildXYSeries(metric, dataPoints, new StairStepSeries {
                    StrokeThickness = 1.5d
                }));

            case GraphType.Line:
                return(BuildXYSeries(metric, dataPoints, new LineSeries {
                    StrokeThickness = 1.5d
                }));

            case GraphType.Total:
                return(new TotalSeries(metric, dataPoints));

            default:
                throw new NotImplementedException($"Graph type {metric.GraphType} not supported");
            }
        }
Exemplo n.º 3
0
        public XYAxisSeries BuildXYSeries(PlotMetric metric, IList <Datapoint> dataPoints, XYAxisSeries series)
        {
            series.Title = metric.GetTitle();

            DateTime startTime = dataPoints.Min(x => x.Timestamp).ToUniversalTime();
            DateTime endTime   = dataPoints.Max(x => x.Timestamp).ToUniversalTime();

            IDictionary <DateTime, double> points = metric.GetIncrements(startTime, endTime).ToDictionary(x => x, y => double.NaN);

            foreach (var dataPoint in dataPoints)
            {
                DateTime timestamp = dataPoint.Timestamp.ToUniversalTime();

                if (!points.ContainsKey(timestamp))
                {
                    throw new InvalidOperationException($"Generated time slice array doesn't contain {timestamp}");
                }

                points[timestamp] = dataPoint.StatisticTypeValue(metric.StatisticType);
            }

            series.ItemsSource = points.Select(x => DateTimeAxis.CreateDataPoint(x.Key, x.Value));
            return(series);
        }
Exemplo n.º 4
0
 public TotalSeries(PlotMetric metric, IList <Datapoint> dataPoints)
 {
     this.metric     = metric;
     this.dataPoints = dataPoints;
 }