123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Windows.Forms.DataVisualization.Charting;
- using IntelligentControlForsx.Common;
- using IntelligentControlForsx.Service.AGC;
- using IntelligentControlForsx.Service.AGC.Domain;
- using log4net;
- using WisdomClient.data;
- namespace IntelligentControlForsx.MyControls.agc
- {
- public partial class WindLineChart : UserControl
- {
- private ILog logger = LogManager.GetLogger("AppInfoLog");
- private string actualDataPoint;
- public string ActualDataPoint
- {
- set { actualDataPoint = value; }
- get { return actualDataPoint; }
- }
- private string setDataPoint;
- public string SetDataPoint
- {
- set { setDataPoint = value; }
- get { return setDataPoint; }
- }
- private string title;
- public string Title
- {
- set { title = value; }
- get { return title; }
- }
- public WindLineChart()
- {
- InitializeComponent();
- }
- public void BindPointAndTitle(string actualPoint, string setPoint, string title)
- {
-
- this.actualDataPoint = actualPoint;
- this.setDataPoint = setPoint;
- this.title = title;
- }
- private void LineChart_Load(object sender, EventArgs e)
- {
- chartData.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm";
- chartData.Series[0].XValueType = ChartValueType.DateTime;
- }
- private void chartData_GetToolTipText(object sender, ToolTipEventArgs e)
- {
- if (e.HitTestResult.ChartElementType == ChartElementType.DataPoint)
- {
- try
- {
- int i = e.HitTestResult.PointIndex;
- //DataPoint dp = e.HitTestResult.Series.Points[i];
- DataPoint dp1 = this.chartData.Series[0].Points[i];
- DataPoint dp2 = this.chartData.Series[1].Points[i];
- //分别显示x轴和y轴的数值,其中{1:F3},表示显示的是float类型,精确到小数点后3位。
- // e.Text = string.Format("时间:{0};\n风速:{1:F2};\n功率:{2:F2};", dp1.XValue, dp1.YValues[0], dp2.YValues[0]);
- }
- catch (Exception ex)
- {
- logger.Info(ex.Message);
- }
- }
- }
- public void DataBind(IList<TsData> dataActual, IList<TsData> dataSet)
- {
- this.chartData.Series[0].Points.Clear();
- this.chartData.Series[1].Points.Clear();
- DateTime now = DateTime.Now;
- chartData.ChartAreas[0].AxisX.Minimum = now.AddHours(-8).ToOADate();
- chartData.ChartAreas[0].AxisX.Maximum = now.ToOADate();
- IList<TsData> actualList = dataActual.Distinct(new DataCompare()).ToList();
- IList<TsData> setList = dataSet.Distinct(new DataCompare()).ToList();
- foreach (var td in actualList)
- {
- DateTime dt = CommonMethod.ConvertIntDateTime(td.ts);
- this.chartData.Series[0].Points.AddXY(dt, td.doubleValue.Value);
- }
- foreach (var td in setList)
- {
- DateTime dt = CommonMethod.ConvertIntDateTime(td.ts);
- this.chartData.Series[1].Points.AddXY(dt, td.doubleValue.Value);
- }
-
- logger.Info("AGC曲线控件绑定:实发有功数据量=" + dataActual.Count + ",有功设定数据量=" + dataSet.Count);
- }
- public void ClearTest()
- {
- this.chartData.Series[0].Points.Clear();
- this.chartData.Series[1].Points.Clear();
- }
- private void chartData_DoubleClick(object sender, EventArgs e)
- {
- LineForm form = new LineForm(actualDataPoint, setDataPoint, title);
- form.StartPosition = FormStartPosition.CenterParent;
- form.ShowDialog();
- }
- }
- }
|