public IEnumerable <ChartInfo> Read(OutputData data) { var series = OutputData.GetAllSeries(data); try { using (var file = new FileStream(path, FileMode.Open)) { using (var reader = new StreamReader(file)) { var graphs = new List <ChartInfo>(); var title = data.Title; var line = reader.ReadLine(); if (line != null && line != Strings.TemplateGraphTag) { throw new FormatException(); } bool endOfStream = reader.EndOfStream; while (!endOfStream) { line = reader.ReadLine(); if (line != Strings.TemplatePrimaryTag) { throw new FormatException(); } var primarySeries = readSeries(reader, series, out endOfStream); var secondarySeries = readSeries(reader, series, out endOfStream); foreach (var s in primarySeries) { s.ShowInSecondaryVerticalAxis = false; } foreach (var s in secondarySeries) { s.ShowInSecondaryVerticalAxis = true; } var chartSeries = primarySeries.Union(secondarySeries); graphs.Add(new ChartInfo(title, SeriesInfo.GetSeriesCollectionName(chartSeries), chartSeries)); } return(graphs); } } } catch (NullReferenceException) { throw new FormatException(); } }
public static IEnumerable <ChartInfo> Read(string path, OutputData data) { if (path == null) { throw new ArgumentNullException(nameof(path)); } if (data == null) { throw new ArgumentNullException(nameof(data)); } return(new _GraphTemplateStream(path).Read(data)); }
public static IEnumerable <SeriesInfo> GetAllSeries(OutputData data) => data.Headers.Skip(1) .Select((header, index) => new SeriesInfo(header, data.Headers.ElementAt(0), data.Units.ElementAt(index + 1), data.Datum.ElementAt(0), data.Datum.ElementAt(index + 1)));