public void createReportChart(string fileName, string path) { ChartProperties chart=new ChartProperties(); chart.Series = new List<ChartSerieProperties>(); chart.XAxisType = XAxisTypeEnum.datetime; try { foreach (CustomReportDataString tag in SelectedTags) { if (tag.MinData) { chart.Series.Add(getItemChartProperties(tag,"min"," (Мин)")); } if (tag.MaxData) { chart.Series.Add(getItemChartProperties(tag, "max", " (Макс)")); } if (tag.AvgData) { chart.Series.Add(getItemChartProperties(tag, "avg", " (Средн)")); } } chart.Axes = new List<ChartAxisProperties>(); ChartAxisProperties ax=new ChartAxisProperties(); ax.Auto = true; ax.Index = 0; chart.Axes.Add(ax); ax=new ChartAxisProperties(); ax.Auto = true; ax.Index = 1; chart.Axes.Add(ax); chart.toXML(path + fileName); } catch (Exception e) { Logger.error(String.Format("createReportChart {0}:\n {1}", e.Message, e.StackTrace)); } }
public static ChartProperties fromXML(string fileName) { try { XmlSerializer mySerializer = new XmlSerializer(typeof(ChartProperties)); // To read the file, create a FileStream. FileStream myFileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); ; // Call the Deserialize method and cast to the object type. ChartProperties data = (ChartProperties)mySerializer.Deserialize(myFileStream); myFileStream.Close(); if (data.Axes.Count == 0) { data.Axes = new List<ChartAxisProperties>(); ChartAxisProperties main=new ChartAxisProperties(); main.Auto = true; main.Index = 0; ChartAxisProperties sec=new ChartAxisProperties(); sec.Auto = true; sec.Index = 1; data.Axes.Add(main); data.Axes.Add(sec); } return data; } catch (Exception e) { Logger.error(String.Format("Чтение файла {0}, Исключение: {1}", fileName, e.Message)); return null; } }