using SanShared; using Syncfusion.Windows.Forms.Chart; using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BerichtGen { /// /// /// public static class makeGraphic { private static ChartControl getGraph(List input, string type) { Size size = new Size(600, 400); ChartControl chartControl = new ChartControl(); chartControl.Size = size; ChartAxis axis = chartControl.PrimaryYAxis; ChartAxisLayout layout1 = new ChartAxisLayout(); layout1.Spacing = 12; layout1.Axes.Add(axis); chartControl.ChartArea.YLayouts.Add(layout1); ChartSeries mychart = new ChartSeries(type, ChartSeriesType.Line); int counter = 0; foreach (UVcsvStrukture pars in input) { if (type.Equals("Temperatur")) mychart.Points.Add(counter, pars.Temperatur); else if (type.Equals("Druck")) mychart.Points.Add(counter, pars.Druck); else throw new Exception("Kein gültiger Aufruf"); counter++; } mychart.YAxis = axis; switch (type) { case "Temperatur": axis.Title = "°C"; break; case "Druck": axis.Title = "[bar]"; break; } axis.TitleFont = new Font("Segeo UI", 14F); chartControl.LegendsPlacement = ChartPlacement.Outside; chartControl.LegendPosition = ChartDock.Bottom; chartControl.LegendAlignment = ChartAlignment.Center; chartControl.Title.Visible = false; chartControl.Series.Add(mychart); chartControl.Skins = Skins.Metro; axis.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Shift; return chartControl; } /// /// Erstellt die Drucksverlauf kurve /// /// /// /// public static bool GetGraphics(List struktures,string destinationPath) { Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MTIwMjk0QDMxMzcyZTMyMmUzME9BaCs3SUNHQklVTE11ZTZnTGdQcmk2eU4xeWphZDdMYkUrbytOTTRveXc9"); ChartControl tempChart = getGraph(struktures, "Temperatur"); if (tempChart == null) return false; else tempChart.SaveImage(Path.Combine(destinationPath, "linerGraph_temp.jpg")); ChartControl druckChart = getGraph(struktures, "Druck"); if (druckChart == null) return false; else druckChart.SaveImage(Path.Combine(destinationPath, "linerGraph_druck.jpg")); return true; } } }