Trend Chart 구현
This commit is contained in:
@@ -22,6 +22,17 @@ namespace friction
|
|||||||
public float m_fDiffByVel;
|
public float m_fDiffByVel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct CHART
|
||||||
|
{
|
||||||
|
public float HUMIDITY;
|
||||||
|
public float TEMPERATURE;
|
||||||
|
public float RPN;
|
||||||
|
|
||||||
|
override public string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("Humi({0}) Temp({1}) RPN({2})", HUMIDITY, TEMPERATURE, RPN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DataTable m_Data = new DataTable();
|
DataTable m_Data = new DataTable();
|
||||||
@@ -138,9 +149,41 @@ namespace friction
|
|||||||
m_ActiveColumns.Add(m_ColumnsNames[i]);
|
m_ActiveColumns.Add(m_ColumnsNames[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSelectedMaterial(string strSpring, string strTable)
|
||||||
|
{
|
||||||
|
m_strCurSpring = strSpring;
|
||||||
|
m_strCurTable = strTable;
|
||||||
|
}
|
||||||
|
|
||||||
//GetCalc("ABS", "ABS");
|
public string GetCurSpring()
|
||||||
|
{
|
||||||
|
return m_strCurSpring;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetCurTable()
|
||||||
|
{
|
||||||
|
return m_strCurTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CHART> GetHumidityChart(string strSpring, string strTable)
|
||||||
|
{
|
||||||
|
string strQuery = string.Format("[{0}]='{1}' and [{2}]='{3}'", m_ColumnMap["spring"], strSpring, m_ColumnMap["table"], strTable);
|
||||||
|
DataRow[] rows = m_Data.Select(strQuery);
|
||||||
|
|
||||||
|
List<CHART> result = new List<CHART>();
|
||||||
|
foreach(DataRow r in rows)
|
||||||
|
{
|
||||||
|
result.Add(new CHART
|
||||||
|
{
|
||||||
|
HUMIDITY = (float)r[m_ColumnMap["humidity"]],
|
||||||
|
TEMPERATURE = (float)r[m_ColumnMap["temp"]],
|
||||||
|
RPN = (float)r[m_ColumnMap["rpn"]],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace friction
|
|||||||
m_ResultPanel = new PanelResult(this);
|
m_ResultPanel = new PanelResult(this);
|
||||||
m_AnalysisPanel = new PanelAnalysis(this);
|
m_AnalysisPanel = new PanelAnalysis(this);
|
||||||
m_RadarGraphPanel = new PanelRadarGraph(this);
|
m_RadarGraphPanel = new PanelRadarGraph(this);
|
||||||
m_TrendGraphPanel = new PanelTrendGraph(this);
|
m_TrendGraphPanel = new PanelTrendGraph(this, m_DataHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenPanel(DockContent panel)
|
private void OpenPanel(DockContent panel)
|
||||||
|
|||||||
64
PanelTrendGraph.Designer.cs
generated
64
PanelTrendGraph.Designer.cs
generated
@@ -28,23 +28,85 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
this.trendChart = new LiveCharts.WinForms.CartesianChart();
|
||||||
|
this.rbHumidity = new System.Windows.Forms.RadioButton();
|
||||||
|
this.rbTemp = new System.Windows.Forms.RadioButton();
|
||||||
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.groupBox1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
// trendChart
|
||||||
|
//
|
||||||
|
this.trendChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.trendChart.Location = new System.Drawing.Point(8, 59);
|
||||||
|
this.trendChart.Name = "trendChart";
|
||||||
|
this.trendChart.Size = new System.Drawing.Size(742, 603);
|
||||||
|
this.trendChart.TabIndex = 0;
|
||||||
|
this.trendChart.Text = "trendChart";
|
||||||
|
//
|
||||||
|
// rbHumidity
|
||||||
|
//
|
||||||
|
this.rbHumidity.Appearance = System.Windows.Forms.Appearance.Button;
|
||||||
|
this.rbHumidity.AutoSize = true;
|
||||||
|
this.rbHumidity.Checked = true;
|
||||||
|
this.rbHumidity.Location = new System.Drawing.Point(6, 19);
|
||||||
|
this.rbHumidity.Name = "rbHumidity";
|
||||||
|
this.rbHumidity.Size = new System.Drawing.Size(64, 22);
|
||||||
|
this.rbHumidity.TabIndex = 1;
|
||||||
|
this.rbHumidity.TabStop = true;
|
||||||
|
this.rbHumidity.Text = "Humidity";
|
||||||
|
this.rbHumidity.UseVisualStyleBackColor = true;
|
||||||
|
this.rbHumidity.CheckedChanged += new System.EventHandler(this.rbHumidity_CheckedChanged);
|
||||||
|
//
|
||||||
|
// rbTemp
|
||||||
|
//
|
||||||
|
this.rbTemp.Appearance = System.Windows.Forms.Appearance.Button;
|
||||||
|
this.rbTemp.AutoSize = true;
|
||||||
|
this.rbTemp.Location = new System.Drawing.Point(76, 20);
|
||||||
|
this.rbTemp.Name = "rbTemp";
|
||||||
|
this.rbTemp.Size = new System.Drawing.Size(87, 22);
|
||||||
|
this.rbTemp.TabIndex = 1;
|
||||||
|
this.rbTemp.Text = "Temperature";
|
||||||
|
this.rbTemp.UseVisualStyleBackColor = true;
|
||||||
|
this.rbTemp.CheckedChanged += new System.EventHandler(this.rbTemp_CheckedChanged);
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
this.groupBox1.Controls.Add(this.rbHumidity);
|
||||||
|
this.groupBox1.Controls.Add(this.rbTemp);
|
||||||
|
this.groupBox1.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||||
|
this.groupBox1.Location = new System.Drawing.Point(8, 3);
|
||||||
|
this.groupBox1.Name = "groupBox1";
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(322, 50);
|
||||||
|
this.groupBox1.TabIndex = 2;
|
||||||
|
this.groupBox1.TabStop = false;
|
||||||
|
//
|
||||||
// PanelTrendGraph
|
// PanelTrendGraph
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(284, 261);
|
this.ClientSize = new System.Drawing.Size(762, 674);
|
||||||
this.ControlBox = false;
|
this.ControlBox = false;
|
||||||
|
this.Controls.Add(this.groupBox1);
|
||||||
|
this.Controls.Add(this.trendChart);
|
||||||
this.HideOnClose = true;
|
this.HideOnClose = true;
|
||||||
this.Name = "PanelTrendGraph";
|
this.Name = "PanelTrendGraph";
|
||||||
this.ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.Document;
|
this.ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.Document;
|
||||||
this.TabText = "Trend Graph";
|
this.TabText = "Trend Graph";
|
||||||
this.Text = "Trend Graph";
|
this.Text = "Trend Graph";
|
||||||
|
this.groupBox1.ResumeLayout(false);
|
||||||
|
this.groupBox1.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private LiveCharts.WinForms.CartesianChart trendChart;
|
||||||
|
private System.Windows.Forms.RadioButton rbHumidity;
|
||||||
|
private System.Windows.Forms.RadioButton rbTemp;
|
||||||
|
private System.Windows.Forms.GroupBox groupBox1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,18 +8,161 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using WeifenLuo.WinFormsUI.Docking;
|
using WeifenLuo.WinFormsUI.Docking;
|
||||||
|
using LiveCharts;
|
||||||
|
using LiveCharts.Wpf;
|
||||||
|
using LiveCharts.WinForms;
|
||||||
|
using LiveCharts.Defaults;
|
||||||
|
|
||||||
namespace friction
|
namespace friction
|
||||||
{
|
{
|
||||||
public partial class PanelTrendGraph : DockContent
|
public partial class PanelTrendGraph : DockContent
|
||||||
{
|
{
|
||||||
MainForm m_Owner = null;
|
MainForm m_Owner = null;
|
||||||
|
DataHandler m_DataHandler = null;
|
||||||
|
|
||||||
public PanelTrendGraph(MainForm owner)
|
public PanelTrendGraph(MainForm owner, DataHandler data)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
m_Owner = owner;
|
m_Owner = owner;
|
||||||
|
m_DataHandler = data;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
trendChart.AxisX.Add(new Axis
|
||||||
|
{
|
||||||
|
Title = "Humidity",
|
||||||
|
});
|
||||||
|
|
||||||
|
trendChart.AxisY.Add(new Axis
|
||||||
|
{
|
||||||
|
Title = "RPN",
|
||||||
|
MinValue = 0,
|
||||||
|
MaxValue = 10,
|
||||||
|
});
|
||||||
|
|
||||||
|
trendChart.LegendLocation = LegendLocation.Right;
|
||||||
|
|
||||||
|
trendChart.DataClick += TrendChart_DataClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TrendChart_DataClick(object sender, ChartPoint chartPoint)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateGraph()
|
||||||
|
{
|
||||||
|
var Chart = m_DataHandler.GetHumidityChart(m_DataHandler.GetCurSpring(), m_DataHandler.GetCurTable());
|
||||||
|
|
||||||
|
//ChartValues<ScatterPoint> Points = new ChartValues<ScatterPoint>();
|
||||||
|
string strTitle = "";
|
||||||
|
double dMin = 0;
|
||||||
|
double dMax = 0;
|
||||||
|
if (rbHumidity.Checked == true)
|
||||||
|
{
|
||||||
|
strTitle = "Humidity";
|
||||||
|
|
||||||
|
trendChart.AxisX[0].Title = strTitle;
|
||||||
|
|
||||||
|
ChartValues<ScatterPoint>[] Points = {
|
||||||
|
new ChartValues<ScatterPoint>(),
|
||||||
|
new ChartValues<ScatterPoint>(),
|
||||||
|
new ChartValues<ScatterPoint>() };
|
||||||
|
|
||||||
|
foreach (var pnt in Chart)
|
||||||
|
{
|
||||||
|
if(pnt.TEMPERATURE < 0)
|
||||||
|
Points[0].Add(new ScatterPoint(pnt.HUMIDITY, pnt.RPN));
|
||||||
|
else if(pnt.TEMPERATURE > 30)
|
||||||
|
Points[2].Add(new ScatterPoint(pnt.HUMIDITY, pnt.RPN));
|
||||||
|
else
|
||||||
|
Points[1].Add(new ScatterPoint(pnt.HUMIDITY, pnt.RPN));
|
||||||
|
}
|
||||||
|
|
||||||
|
System.Windows.Media.SolidColorBrush[] brushes = {
|
||||||
|
System.Windows.Media.Brushes.DodgerBlue.Clone(),
|
||||||
|
System.Windows.Media.Brushes.Green.Clone(),
|
||||||
|
System.Windows.Media.Brushes.IndianRed.Clone() };
|
||||||
|
foreach (var brush in brushes)
|
||||||
|
brush.Opacity = 0.75;
|
||||||
|
|
||||||
|
trendChart.Series = new SeriesCollection
|
||||||
|
{
|
||||||
|
new ScatterSeries
|
||||||
|
{
|
||||||
|
Title = "~ 0℃",
|
||||||
|
Values = Points[0],
|
||||||
|
Fill = brushes[0],
|
||||||
|
},
|
||||||
|
new ScatterSeries
|
||||||
|
{
|
||||||
|
Title = "0℃ ~ 30℃",
|
||||||
|
Values = Points[1],
|
||||||
|
Fill = brushes[1],
|
||||||
|
},
|
||||||
|
new ScatterSeries
|
||||||
|
{
|
||||||
|
Title = "30℃ ~",
|
||||||
|
Values = Points[2],
|
||||||
|
Fill = brushes[2],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
dMin = Chart.Min(r => r.HUMIDITY - 1);
|
||||||
|
dMax = Chart.Max(r => r.HUMIDITY - 1);
|
||||||
|
}
|
||||||
|
else if(rbTemp.Checked == true)
|
||||||
|
{
|
||||||
|
strTitle = "Temperature";
|
||||||
|
|
||||||
|
trendChart.AxisX[0].Title = strTitle;
|
||||||
|
|
||||||
|
ChartValues<ScatterPoint>[] Points = {
|
||||||
|
new ChartValues<ScatterPoint>(),
|
||||||
|
new ChartValues<ScatterPoint>() };
|
||||||
|
|
||||||
|
foreach (var pnt in Chart)
|
||||||
|
{
|
||||||
|
if(pnt.HUMIDITY <= 60)
|
||||||
|
Points[0].Add(new ScatterPoint(pnt.TEMPERATURE, pnt.RPN, 2));
|
||||||
|
else
|
||||||
|
Points[1].Add(new ScatterPoint(pnt.TEMPERATURE, pnt.RPN, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
trendChart.Series = new SeriesCollection
|
||||||
|
{
|
||||||
|
new ScatterSeries
|
||||||
|
{
|
||||||
|
Title = "~ 60%",
|
||||||
|
Values = Points[0],
|
||||||
|
Foreground = System.Windows.Media.Brushes.SkyBlue,
|
||||||
|
},
|
||||||
|
new ScatterSeries
|
||||||
|
{
|
||||||
|
Title = "60% ~",
|
||||||
|
Values = Points[1],
|
||||||
|
Foreground = System.Windows.Media.Brushes.DarkBlue,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
dMin = Chart.Min(r => r.TEMPERATURE - 1);
|
||||||
|
dMax = Chart.Max(r => r.TEMPERATURE - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
trendChart.AxisX[0].MinValue = dMin;
|
||||||
|
trendChart.AxisX[0].MaxValue = dMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rbHumidity_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UpdateGraph();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rbTemp_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UpdateGraph();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,23 @@
|
|||||||
<HintPath>packages\EPPlus.4.1.0\lib\net40\EPPlus.dll</HintPath>
|
<HintPath>packages\EPPlus.4.1.0\lib\net40\EPPlus.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="LiveCharts, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\LiveCharts.0.9.6\lib\net45\LiveCharts.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="LiveCharts.WinForms, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\LiveCharts.WinForms.0.9.6\lib\net45\LiveCharts.WinForms.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="LiveCharts.Wpf, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\LiveCharts.Wpf.0.9.6\lib\net45\LiveCharts.Wpf.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="PresentationFramework" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xaml" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
@@ -48,6 +63,8 @@
|
|||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="WindowsBase" />
|
||||||
|
<Reference Include="WindowsFormsIntegration" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="DataHandler.cs" />
|
<Compile Include="DataHandler.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user