private static Plot GetTrendChart(IEnumerable <PlotData> data, string referenceFactor, string timeFactor) { var plot = new Plot(); var orderedGroupingData = data .OrderBy(d => d.Time) .GroupBy(bd => bd.Group); foreach (var grouping in orderedGroupingData) { var(xs, ys) = grouping.Aggregate((xs: new List <double>(), ys: new List <double>()), (seed, group) => { if (@group.Value.HasValue) { seed.ys.Add(group.Value.Value); seed.xs.Add(group.Time.Value.ToOADate()); } return(seed); }, tuple => (tuple.xs.ToArray(), tuple.ys.ToArray())); var naturalSpline = new NaturalSpline(xs, ys, 20); var randomColor = DataGen.RandomColor(new Random()); plot.PlotScatter(xs, ys, randomColor, markerSize: 10, lineWidth: 0); plot.PlotScatter(naturalSpline.interpolatedXs, naturalSpline.interpolatedYs, randomColor, markerSize: 3, label: grouping.Key); } return(plot); }