コード例 #1
0
ファイル: HistoryLines.cs プロジェクト: zzh-git/KS
        private void HistoryLines_Load(object sender, EventArgs e)
        {
            timerChartBind.Interval = GlobalVariables.RefIntvel;
            chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "yyyy-MM-dd HH:mm:ss";
            if (sExcelCells.Length > 0)
            {
                ShowLines();
                this.Text = sTitle + "--历史查询";
            }
            else
            {
                //注意区分五六号机 ZZH
                if (UnitNO == 5)
                {
                    m_dtLineData = GlobalVariables.dtChartDataFive;
                }
                else if (UnitNO == 6)
                {
                    m_dtLineData = GlobalVariables.dtChartDataSix;
                }
                dateTimePickerBegin1.Value = (DateTime)m_dtLineData.Rows[0]["ValueTime"];
                dateTimePickerBegin2.Value = dateTimePickerBegin1.Value;
                dateTimePickerEnd1.Value   = (DateTime)m_dtLineData.Rows[m_dtLineData.Rows.Count - 1]["ValueTime"];
                dateTimePickerEnd2.Value   = dateTimePickerEnd1.Value;

                if (seriesCollection == null)//单个测点曲线
                {
                    chart1.Series[0].XValueType    = System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime;
                    chart1.Series[0].XValueMember  = "ValueTime";
                    chart1.Series[0].YValueType    = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
                    chart1.Series[0].YValueMembers = "F" + labelTag.TagID.ToString();
                    //这里也要区分五六号机 ZZH
                    if (TagValue.GetStrSetValueFive(labelTag.TagID.ToString(), "adjustValue").Contains("F3004"))
                    {
                        chart1.Series[0].LegendText = labelTag.TagDesc + "(绝对)" + "(" + labelTag.TagUnit + ")";
                    }
                    else
                    {
                        chart1.Series[0].LegendText = labelTag.TagDesc + "(" + labelTag.TagUnit + ")";
                    }
                }
                else//双曲线
                {
                    Series seriesNew = null;
                    chart1.Series.Clear();
                    foreach (Series series in seriesCollection)
                    {
                        seriesNew               = chart1.Series.Add(series.YValueMembers);
                        seriesNew.LegendText    = series.LegendText;
                        seriesNew.XValueType    = series.XValueType;
                        seriesNew.XValueMember  = series.XValueMember;
                        seriesNew.YValueType    = series.YValueType;
                        seriesNew.YValueMembers = series.YValueMembers;
                        sExcelCells            += series.YValueMembers + ",";
                        seriesNew.Color         = series.Color;
                        seriesNew.ChartType     = SeriesChartType.Line;
                    }
                    sExcelCells = sExcelCells.Trim(',');
                }

                chart1.DataSource = m_dtLineData;
                chart1.DataBind();
                timerChartBind.Enabled = true;
                this.Text = sTitle + "--实时曲线";
            }
        }