public IObservable <GroupedPhotometryDataFrame> Process(IObservable <GroupedPhotometryDataFrame> source) { return(Observable.Defer(() => { GroupedData[] groups = null; return source.Do(input => { if (groups == null || groups.Length != input.Groups.Length) { groups = new GroupedData[input.Groups.Length]; for (int i = 0; i < groups.Length; i++) { groups[i].Name = input.Groups[i].Name; var labels = groups[i].Labels = new string[input.Groups[i].Activity.Length]; var data = groups[i].Data = new IPointListEdit[input.Groups[i].Activity.Length]; for (int j = 0; j < data.Length; j++) { data[j] = new PointPairList(); labels[j] = GraphHelper.GetRegionLabel(ref input.Groups[i].Activity[j].Region); } } } for (int i = 0; i < groups.Length; i++) { for (int j = 0; j < groups[i].Data.Length; j++) { groups[i].Data[j].Add(input.Timestamp, input.Groups[i].Activity[j].Value); } } }).Finally(() => { if (groups == null) { return; } var graph = new RollingGraph(); InitializeGraphPane(graph); graph.PaneCount = groups.Length; for (int i = 0; i < groups.Length; i++) { var group = groups[i]; var pane = graph.MasterPane.PaneList[i]; for (int j = 0; j < group.Data.Length; j++) { pane.AddCurve(group.Labels[j], group.Data[j], graph.GetNextColor(), SymbolType.None); } pane.Legend.FontSpec.Size = ScaleSize; pane.YAxis.Title.Text = group.Name; pane.YAxis.Title.IsVisible = true; } SaveGraph(graph); }); })); }
public IObservable <PhotometryDataFrame> Process(IObservable <PhotometryDataFrame> source) { return(Observable.Defer(() => { string[] labels = null; IPointListEdit[] data = null; return source.Do(input => { if (data == null || data.Length != input.Activity.Length) { labels = new string[input.Activity.Length]; data = new IPointListEdit[input.Activity.Length]; for (int i = 0; i < data.Length; i++) { data[i] = new PointPairList(); labels[i] = GraphHelper.GetRegionLabel(ref input.Activity[i].Region); } } for (int i = 0; i < data.Length; i++) { data[i].Add(input.Timestamp, input.Activity[i].Value); } }).Finally(() => { if (data == null) { return; } var graph = new RollingGraph(); InitializeGraphPane(graph); graph.PaneCount = data.Length; for (int i = 0; i < data.Length; i++) { var pane = graph.MasterPane.PaneList[i]; pane.AddActivity(labels[i], data[i], graph.GetNextColor()); } SaveGraph(graph); }); })); }