Grafik wird erzeugt
This commit is contained in:
22
SanSystem/UCInliner.Designer.cs
generated
22
SanSystem/UCInliner.Designer.cs
generated
@@ -70,7 +70,7 @@
|
|||||||
this.label11 = new System.Windows.Forms.Label();
|
this.label11 = new System.Windows.Forms.Label();
|
||||||
this.label10 = new System.Windows.Forms.Label();
|
this.label10 = new System.Windows.Forms.Label();
|
||||||
this.label9 = new System.Windows.Forms.Label();
|
this.label9 = new System.Windows.Forms.Label();
|
||||||
this.button2 = new System.Windows.Forms.Button();
|
this.btn_create_graph = new System.Windows.Forms.Button();
|
||||||
this.tabControl1.SuspendLayout();
|
this.tabControl1.SuspendLayout();
|
||||||
this.tabPage2.SuspendLayout();
|
this.tabPage2.SuspendLayout();
|
||||||
this.groupBox3.SuspendLayout();
|
this.groupBox3.SuspendLayout();
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
//
|
//
|
||||||
// tabPage2
|
// tabPage2
|
||||||
//
|
//
|
||||||
this.tabPage2.Controls.Add(this.button2);
|
this.tabPage2.Controls.Add(this.btn_create_graph);
|
||||||
this.tabPage2.Controls.Add(this.button1);
|
this.tabPage2.Controls.Add(this.button1);
|
||||||
this.tabPage2.Controls.Add(this.ftpProgress);
|
this.tabPage2.Controls.Add(this.ftpProgress);
|
||||||
this.tabPage2.Controls.Add(this.btn_transfer_ftp);
|
this.tabPage2.Controls.Add(this.btn_transfer_ftp);
|
||||||
@@ -546,15 +546,15 @@
|
|||||||
this.label9.TabIndex = 0;
|
this.label9.TabIndex = 0;
|
||||||
this.label9.Text = "Harz";
|
this.label9.Text = "Harz";
|
||||||
//
|
//
|
||||||
// button2
|
// btn_create_graph
|
||||||
//
|
//
|
||||||
this.button2.Location = new System.Drawing.Point(595, 426);
|
this.btn_create_graph.Location = new System.Drawing.Point(608, 457);
|
||||||
this.button2.Name = "button2";
|
this.btn_create_graph.Name = "btn_create_graph";
|
||||||
this.button2.Size = new System.Drawing.Size(95, 61);
|
this.btn_create_graph.Size = new System.Drawing.Size(138, 67);
|
||||||
this.button2.TabIndex = 31;
|
this.btn_create_graph.TabIndex = 32;
|
||||||
this.button2.Text = "button2";
|
this.btn_create_graph.Text = "UVGraphic erzeugen";
|
||||||
this.button2.UseVisualStyleBackColor = true;
|
this.btn_create_graph.UseVisualStyleBackColor = true;
|
||||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
this.btn_create_graph.Click += new System.EventHandler(this.btn_create_graph_Click);
|
||||||
//
|
//
|
||||||
// UCInliner
|
// UCInliner
|
||||||
//
|
//
|
||||||
@@ -623,6 +623,6 @@
|
|||||||
private System.Windows.Forms.Button btn_transfer_ftp;
|
private System.Windows.Forms.Button btn_transfer_ftp;
|
||||||
private System.Windows.Forms.ProgressBar ftpProgress;
|
private System.Windows.Forms.ProgressBar ftpProgress;
|
||||||
private System.Windows.Forms.Button button1;
|
private System.Windows.Forms.Button button1;
|
||||||
private System.Windows.Forms.Button button2;
|
private System.Windows.Forms.Button btn_create_graph;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using System.IO;
|
|||||||
using SanShared;
|
using SanShared;
|
||||||
using FluentFTP;
|
using FluentFTP;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using Syncfusion.Windows.Forms.Chart;
|
||||||
|
|
||||||
namespace SanSystem
|
namespace SanSystem
|
||||||
{
|
{
|
||||||
@@ -205,5 +206,99 @@ namespace SanSystem
|
|||||||
FrmLinerChart frmLinerChart = new FrmLinerChart();
|
FrmLinerChart frmLinerChart = new FrmLinerChart();
|
||||||
frmLinerChart.ShowDialog();
|
frmLinerChart.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ChartControl getGraph(string csvFile)
|
||||||
|
{
|
||||||
|
Size size = new Size(800, 400);
|
||||||
|
|
||||||
|
ChartControl chartControl = new ChartControl();
|
||||||
|
chartControl.Size = size;
|
||||||
|
|
||||||
|
ChartAxis axis = chartControl.PrimaryYAxis;
|
||||||
|
ChartAxis axis0 = new ChartAxis(ChartOrientation.Vertical);
|
||||||
|
ChartAxis axis1 = new ChartAxis(ChartOrientation.Vertical);
|
||||||
|
|
||||||
|
ChartAxisLayout layout1 = new ChartAxisLayout();
|
||||||
|
ChartAxisLayout layout2 = new ChartAxisLayout();
|
||||||
|
|
||||||
|
chartControl.Axes.Add(axis0);
|
||||||
|
chartControl.Axes.Add(axis1);
|
||||||
|
|
||||||
|
layout1.Spacing = 12;
|
||||||
|
layout2.Spacing = 12;
|
||||||
|
layout1.Axes.Add(axis);
|
||||||
|
layout2.Axes.Add(axis0);
|
||||||
|
layout2.Axes.Add(axis1);
|
||||||
|
|
||||||
|
chartControl.ChartArea.YLayouts.Add(layout1);
|
||||||
|
chartControl.ChartArea.YLayouts.Add(layout2);
|
||||||
|
|
||||||
|
ChartSeries temperaturChart = new ChartSeries("Temperatur", ChartSeriesType.Line);
|
||||||
|
ChartSeries druckChart = new ChartSeries("Druck", ChartSeriesType.Line);
|
||||||
|
if (!File.Exists(csvFile)) return null;
|
||||||
|
string[] input = File.ReadAllLines(csvFile);
|
||||||
|
int counter = 0;
|
||||||
|
foreach (string pars in input)
|
||||||
|
{
|
||||||
|
string[] parts = pars.Split(',');
|
||||||
|
if (parts[0].Equals("Group1") || parts[1].Equals("(END)")) continue;
|
||||||
|
double temperatur = double.Parse(parts[1].Replace('.', ','));
|
||||||
|
double druck = double.Parse(parts[2].Replace('.', ','));
|
||||||
|
|
||||||
|
temperaturChart.Points.Add(counter, temperatur);
|
||||||
|
druckChart.Points.Add(counter, druck);
|
||||||
|
counter++;
|
||||||
|
|
||||||
|
}
|
||||||
|
temperaturChart.YAxis = axis;
|
||||||
|
druckChart.YAxis = axis0;
|
||||||
|
|
||||||
|
axis.Title = "°C";
|
||||||
|
axis.TitleFont = new Font("Segeo UI", 14F);
|
||||||
|
|
||||||
|
axis0.Title = "[bar]";
|
||||||
|
axis0.TitleFont = new Font("Segeo UI", 14F);
|
||||||
|
|
||||||
|
chartControl.LegendsPlacement = ChartPlacement.Outside;
|
||||||
|
chartControl.LegendPosition = ChartDock.Bottom;
|
||||||
|
chartControl.LegendAlignment = ChartAlignment.Center;
|
||||||
|
chartControl.Title.Visible = false;
|
||||||
|
|
||||||
|
ChartAxis chartAxis = new ChartAxis();
|
||||||
|
chartAxis.Orientation = ChartOrientation.Horizontal;
|
||||||
|
chartAxis.Range = new MinMaxInfo(0, 6, 1);
|
||||||
|
chartAxis.DrawGrid = false;
|
||||||
|
chartAxis.LineType.Width = 1F;
|
||||||
|
chartAxis.LineType.ForeColor = Color.Black;
|
||||||
|
chartControl.Axes.Add(chartAxis);
|
||||||
|
|
||||||
|
chartControl.Series.Add(temperaturChart);
|
||||||
|
chartControl.Series.Add(druckChart);
|
||||||
|
chartControl.Skins = Skins.Metro;
|
||||||
|
|
||||||
|
|
||||||
|
axis1.OpposedPosition = true;
|
||||||
|
axis.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Shift;
|
||||||
|
axis0.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Shift;
|
||||||
|
axis1.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Shift;
|
||||||
|
|
||||||
|
return chartControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btn_create_graph_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Stopwatch watch = new Stopwatch();
|
||||||
|
|
||||||
|
string myPath = Path.Combine(destinationPath, "Trend");
|
||||||
|
IEnumerable<string> files = Directory.EnumerateFiles(myPath, "*.csv", SearchOption.AllDirectories);
|
||||||
|
|
||||||
|
ChartControl chart = getGraph(files.Last());
|
||||||
|
if (chart == null) MessageBox.Show("Konnte CSV nicht finden!");
|
||||||
|
else
|
||||||
|
chart.SaveImage(Path.Combine(destinationPath, "linerGraph.jpg"));
|
||||||
|
|
||||||
|
watch.Stop();
|
||||||
|
MessageBox.Show((watch.ElapsedTicks) + " s");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user