Example #1
0
            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();
                }
            }
Example #2
0
        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));
        }
Example #3
0
 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)));