コード例 #1
0
ファイル: TChartDataLoader.cs プロジェクト: dloney/Pisces
 public void DrawTimeSeries(SeriesList list, string title, string subTitle,
                            bool undoZoom, bool multiLeftAxis = false, bool multiYear = true)
 {
     CreateSeries(list, title, subTitle, undoZoom, multiLeftAxis);
     for (int i = 0; i < list.Count; i++)
     {
         FillTimeSeries(list[i], chart1[i]);
     }
     FormatBottomAxisStandard(multiYear);
     chart1.Refresh();
 }
コード例 #2
0
        /// <summary>
        /// 时间为横轴绘制曲线
        /// </summary>
        /// <param name="tChart1"></param>
        /// <param name="tmp_line"></param>
        /// <param name="tmp_Yvalue"></param>
        /// <param name="XValue"></param>
        private void AddLine(TChart tChart1, Line tmp_line, double[] tmp_Yvalue, DateTime[] XValue)
        {
            tChart1.Aspect.View3D           = false; //是否3D显示
            tmp_line.Marks.Gradient.Visible = true;  //显示网格
            tmp_line.Marks.Visible          = false;

            tmp_line.Marks.Gradient.StartColor = Color.FromArgb(255, 215, 0);//网格颜色设置
            tmp_line.Marks.Gradient.EndColor   = Color.White;
            tmp_line.Marks.Symbol.Visible      = true;

            tmp_line.Add(XValue, tmp_Yvalue);
            tmp_line.Pointer.Visible      = true;
            tmp_line.Pointer.Style        = Steema.TeeChart.Styles.PointerStyles.SmallDot;
            tmp_line.Pointer.Color        = Color.Black;
            tChart1.Axes.Left.Automatic   = false;
            tChart1.Axes.Left.Minimum     = getMin(tmp_Yvalue) - 1;
            tChart1.Axes.Left.Maximum     = getMax(tmp_Yvalue) + 1;
            tChart1.Axes.Left.Increment   = 0.4;                                                                           //纵坐标增量
            tChart1.Page.MaxPointsPerPage = 0;
            tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneMonth); //横坐标按月增量
            int len = XValue.Length;

            tChart1.Axes.Bottom.SetMinMax(XValue[0], XValue[len - 1]);
            tChart1.Refresh();
            tChart1.Axes.Bottom.Labels.MultiLine = false;
            tmp_line.XValues.DateTime            = true;
        }
コード例 #3
0
 private void clearPic(TChart tchart)
 {
     xvalue1 = 0;
     yvalue1 = 0;
     xvalue2 = 0;
     yvalue2 = 0;
     tchart.Refresh();
 }
コード例 #4
0
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     points1.GetVertAxis.Automatic = checkBox1.Checked;
     if (!points1.GetVertAxis.Automatic)
     {
         points1.GetVertAxis.SetMinMax(-10, 30);
     }
     tChart1.Refresh();
 }
コード例 #5
0
 private void PaintRec(TChart tchart, int x1, int y1, int x2, int y2)
 {
     g = tchart.CreateGraphics();
     g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
     g.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
     g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
     tchart.Refresh();
     g.DrawRectangle(new Pen(Color.Red, 2), x1, y1, Math.Abs(x1 - x2), Math.Abs(y1 - y2));
     //g.DrawLine(new Pen(Color.Red, 2), x1, y1, x2, y2);
 }
コード例 #6
0
        private void AnimateSeries(TChart chart)
        {
            double   newY;
            DateTime newX;

            // 重绘
            chart.AutoRepaint = false;

            /// <summary>
            /// 绘画坐标点超过50个时将实时更新X时间坐标
            /// </summary>
            while (fastLine1.Count > DEFAULT_DATA_SHOW_COUNT)
            {
                // 删除第一个点
                fastLine1.Delete(0);
                // 重新设置X轴的最大值和最小值
                fastLine1.GetHorizAxis.SetMinMax(DateTime.Now.AddSeconds(-110), DateTime.Now.AddSeconds(10));
            }

            newX = DateTime.Now;
            newY = rnd.Next(500);
            if (Math.Abs(newY) > 1.0e+4)
            {
                newY = 0.0;
            }
            fastLine1.Add(newX, newY / 100);

            // 往DGV中填充数据
            _dgvData.Rows.Add(newY / 100 + "%", DateTime.Now);
            // 预警值
            var dWarnValue = _WarnValue;

            // 当某点的Y坐标超过某一值时
            if (newY / 100 > dWarnValue)
            {
                _dgvData.Rows[_dgvData.Rows.Count - 1].DefaultCellStyle.BackColor = Color.Red;
            }
            // 定位滚动条
            _dgvData.FirstDisplayedScrollingRowIndex = _dgvData.Rows.Count - 1;

            // 重绘
            chart.AutoRepaint = true;
            chart.Refresh();
        }
コード例 #7
0
        public void MouseTchartInit(TChart tchart, bool ismesure)
        {
            if (ismesure)
            {
                tchart.MouseDown += new System.Windows.Forms.MouseEventHandler(mouse_down);
                tchart.MouseUp   += new System.Windows.Forms.MouseEventHandler(mouse_up);
                tchart.MouseMove += new System.Windows.Forms.MouseEventHandler(mouse_move);
            }
            else
            {
                tip1.Hide(tchart);
                tip2.Hide(tchart);
                tchart.Refresh();

                tchart.MouseDown -= new System.Windows.Forms.MouseEventHandler(mouse_down);
                tchart.MouseUp   -= new System.Windows.Forms.MouseEventHandler(mouse_up);
                tchart.MouseMove -= new System.Windows.Forms.MouseEventHandler(mouse_move);
            }
        }
コード例 #8
0
        private void AddBar(TChart tChart1, Bar tmp_bar, double[] tmp_Yvalue, double[] XValue)
        {
            tChart1.Aspect.View3D          = false;
            tmp_bar.Marks.Gradient.Visible = true;
            tmp_bar.Marks.Visible          = false;                          //标签卡不显示

            tmp_bar.Marks.Gradient.StartColor = Color.FromArgb(255, 215, 0); //网格颜色设置
            tmp_bar.Marks.Gradient.EndColor   = Color.White;
            tmp_bar.Marks.Symbol.Visible      = true;

            tmp_bar.Add(XValue, tmp_Yvalue);
            tChart1.Axes.Left.Minimum     = getMin(tmp_Yvalue) - 1;
            tChart1.Axes.Left.Maximum     = getMax(tmp_Yvalue) + 1;
            tChart1.Axes.Left.Increment   = 0; //纵坐标增量
            tChart1.Page.MaxPointsPerPage = 0;
            tChart1.Axes.Bottom.Increment = 0; //横坐标增量

            int len = XValue.Length;

            tChart1.Axes.Bottom.SetMinMax(XValue[0], XValue[len - 1]);
            tChart1.Refresh();
        }
コード例 #9
0
ファイル: FormCalibration.cs プロジェクト: zjyu1/ASCAN
        private void initControls(System.Windows.Forms.Panel panel, float widthPos, float subpanelwidth)
        {
            subPanle          = new System.Windows.Forms.Panel();
            subPanle.Parent   = panel;
            subPanle.Width    = (int)subpanelwidth;
            subPanle.Height   = panel.Height;
            subPanle.Location = new Point((int)widthPos, panel.Location.Y);

            textPanle          = new System.Windows.Forms.Panel();
            textPanle.Parent   = subPanle;
            textPanle.Width    = (int)subpanelwidth;
            textPanle.Height   = (int)(panel.Height * 0.04);
            textPanle.Location = new Point(0, panel.Location.Y);

            showPanle        = new System.Windows.Forms.Panel();
            showPanle.Parent = subPanle;
            showPanle.Width  = (int)subpanelwidth;
            int i = showPanle.Width;

            showPanle.Height   = panel.Height - textPanle.Height;
            showPanle.Location = new Point(0, textPanle.Location.Y + textPanle.Height);

            textBox           = new TextBox();
            textBox.Multiline = false;
            textBox.ReadOnly  = true;
            textBox.BackColor = Color.FromArgb(192, 255, 192);
            textBox.BackColor = Color.White;
            textBox.Font      = new Font("微软雅黑", 10f);
            textBox.Text      = assignName;
            textBox.Parent    = textPanle;
            textBox.Dock      = DockStyle.Fill;
            textBox.Margin    = new Padding(0);
            textBox.TextAlign = HorizontalAlignment.Center;

            newTchart = new TChart();
            newTchart.Axes.Left.Minimum   = 0;
            newTchart.Axes.Bottom.Minimum = 0;
            newTchart.Aspect.View3D       = false;
            newTchart.Header.Visible      = false;

            newTchart.BackColor          = Color.White;
            newTchart.Parent             = showPanle;
            newTchart.Dock               = DockStyle.Fill;
            newTchart.Legend.Visible     = false;
            newTchart.Walls.Visible      = false;
            newTchart.Zoom.Allow         = false;
            newTchart.Panel.MarginUnits  = PanelMarginUnits.Percent;
            newTchart.Panel.MarginTop    = 0D;
            newTchart.Panel.MarginBottom = 0D;
            newTchart.Panel.MarginRight  = 0D;
            newTchart.Panel.MarginLeft   = 0D;
            newTchart.Margin             = new Padding(0);
            newTchart.Header.Visible     = false;
            newTchart.Axes.Bottom.SetMinMax(0, 100);
            newTchart.Axes.Bottom.Increment      = (30 - 20) / 10;
            newTchart.Axes.Bottom.Labels.Visible = true;
            newTchart.Axes.Bottom.Visible        = false;
            newTchart.Axes.Bottom.Grid.Visible   = false;
            newTchart.Axes.Left.Grid.Visible     = false;
            newTchart.Axes.Left.SetMinMax(0, 200);
            newTchart.Axes.Left.Inverted = true;
            newTchart.Axes.Left.Visible  = false;

            switch (this.type)
            {
            case calibStripType.PAstrip:
            {
                newTchart.Zoom.Allow               = false;
                newTchart.Axes.Left.Visible        = false;
                newTchart.Axes.Left.Labels.Visible = false;
                break;
            }

            case calibStripType.Scale:
            {
                newTchart.Zoom.Allow               = false;
                newTchart.Axes.Left.Visible        = true;
                newTchart.Axes.Left.Labels.Visible = true;
                newTchart.Series.Add(new Steema.TeeChart.Styles.Map());        //Add a series of map just to show the axes of left
                break;
            }
            }

            newTchart.Refresh();
        }
コード例 #10
0
        /// <summary>
        /// 根据DataGridView中选中列数据绘制柱状图
        /// </summary>
        /// <param name="tChart1"></param>
        /// <param name="tmp_bar"></param>
        /// <param name="dgv"></param>
        private void AddBar(TChart tChart1, Bar tmp_bar, DataGridView dgv, int Xindex)
        {
            int j = 0;

            flagtime        = false;
            dgv.MultiSelect = false;
            double   tmp_value = 0;
            DateTime tmp_times;

            j = dgv.CurrentCell.ColumnIndex;
            int count = dgv.Rows.Count;

            double[]   tmp_Yvalue = new double[count - 1];
            DateTime[] tmp_time   = new DateTime[count - 1];
            string[]   XValue     = new string[count - 1];
            for (int i = 0; i < dgv.Rows.Count - 1; i++)//y轴数据列
            {
                if (j != 0)
                {
                    if (double.TryParse(dgv.Rows[i].Cells[j].Value.ToString(), out tmp_value))
                    {
                        if (dgv.Rows[i].Cells[j].Value.ToString() != "" && dgv.Rows[i].Cells[j].Value != null)
                        {
                            tmp_Yvalue[i] = Convert.ToDouble(dgv.Rows[i].Cells[j].Value.ToString());
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择数据列!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        for (int s = 0; s < dgv.Rows.Count - 1; s++)
                        {
                            tmp_Yvalue[s] = 0;
                        }
                        break;
                    }
                }
            }
            for (int i = 0; i < dgv.Rows.Count - 1; i++)//x轴是否为时间列
            {
                if (j != 0)
                {
                    if (DateTime.TryParse(dgv.Rows[i].Cells[Xindex].Value.ToString(), out tmp_times))
                    {
                        if (dgv.Rows[i].Cells[Xindex].Value.ToString() != "" && dgv.Rows[i].Cells[Xindex].Value != null)
                        {
                            tmp_time[i] = Convert.ToDateTime(dgv.Rows[i].Cells[Xindex].Value.ToString());
                        }
                        flagtime = true;
                    }
                    else
                    {
                        flagtime = false;
                        break;
                    }
                }
            }
            for (int i = 0; i < dgv.Rows.Count - 1; i++)//x轴不为时间列
            {
                if (j != 0)
                {
                    if (!flagtime)
                    {
                        if (dgv.Rows[i].Cells[Xindex].Value.ToString() != "" && dgv.Rows[i].Cells[Xindex].Value != null)
                        {
                            XValue[i] = dgv.Rows[i].Cells[Xindex].Value.ToString();
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            tChart1.Aspect.View3D          = false; //是否3D显示
            tmp_bar.Marks.Gradient.Visible = true;  //显示网格
            tmp_bar.Marks.Visible          = false;

            tmp_bar.Marks.Gradient.StartColor = Color.FromArgb(255, 215, 0);//网格颜色设置
            tmp_bar.Marks.Gradient.EndColor   = Color.White;
            tmp_bar.Marks.Symbol.Visible      = true;
            if (flagtime)
            {
                tmp_bar.Add(tmp_time, tmp_Yvalue);
                DateTime mindt = getMin(tmp_time);
                DateTime maxdt = getMax(tmp_time);
                tChart1.Axes.Bottom.SetMinMax(mindt, maxdt);
            }
            else
            {
                for (int m = 0; m < tmp_Yvalue.Length; m++)
                {
                    tmp_bar.Add(tmp_Yvalue[m], XValue[m]);
                }
                int len = XValue.Length;
                tChart1.Axes.Bottom.SetMinMax(0, len);
            }
            tChart1.Axes.Bottom.MaximumOffset = 0;
            tChart1.Axes.Bottom.MinimumOffset = 0;
            tChart1.Axes.Left.Automatic       = false;
            tChart1.Axes.Left.Minimum         = getMin(tmp_Yvalue) - 1;
            tChart1.Axes.Left.Maximum         = getMax(tmp_Yvalue) + 1;
            tChart1.Axes.Bottom.Automatic     = false;
            tChart1.Axes.Left.Increment       = 0; //纵坐标增量
            tChart1.Axes.Bottom.Increment     = 0; //横坐标增量

            tChart1.Refresh();
            tChart1.Axes.Bottom.Labels.MultiLine = false;
        }
コード例 #11
0
        private void AddLine(TChart tChart1, Line tmp_line, string[] tmp_Yvalue, string[] XValue)
        {
            int      len = tmp_Yvalue.Length;
            double   tmp_yvalue;
            DateTime tmp_time;

            double[]   tmp_Yvalue1 = new double[len];
            DateTime[] tmp_Xvalue  = new DateTime[len];
            bool       ftime       = false;

            for (int i = 0; i < tmp_Yvalue.Length; i++)//y轴为数据轴,否则设为0
            {
                if (double.TryParse(tmp_Yvalue[i], out tmp_yvalue))
                {
                    tmp_Yvalue1[i] = tmp_yvalue;
                }
                else
                {
                    tmp_Yvalue1[i] = 0;
                }
            }
            for (int i = 0; i < XValue.Length; i++)//y轴为数据轴,否则设为0
            {
                if (DateTime.TryParse(XValue[i], out tmp_time))
                {
                    tmp_Xvalue[i] = tmp_time;
                    ftime         = true;
                }
                else
                {
                    ftime = false;
                    break;
                }
            }
            tChart1.Aspect.View3D           = false; //是否3D显示
            tmp_line.Marks.Gradient.Visible = true;  //显示网格
            tmp_line.Marks.Visible          = false;

            tmp_line.Marks.Gradient.StartColor = Color.FromArgb(255, 215, 0);//网格颜色设置
            tmp_line.Marks.Gradient.EndColor   = Color.White;
            tmp_line.Marks.Symbol.Visible      = true;
            if (ftime)
            {
                tmp_line.Add(tmp_Xvalue, tmp_Yvalue1);
            }
            else
            {
                for (int j = 0; j < tmp_Yvalue1.Length; j++)
                {
                    tmp_line.Add(tmp_Yvalue1[j], XValue[j]);
                }
            }
            tmp_line.Pointer.Visible      = true;
            tmp_line.Pointer.Style        = Steema.TeeChart.Styles.PointerStyles.SmallDot;
            tmp_line.Pointer.Color        = Color.Black;
            tChart1.Axes.Left.Automatic   = false;
            tChart1.Axes.Left.Minimum     = getMin(tmp_Yvalue1) - 1;
            tChart1.Axes.Left.Maximum     = getMax(tmp_Yvalue1) + 1;
            tChart1.Axes.Bottom.Automatic = false;
            tChart1.Axes.Bottom.Increment = 0; //横坐标增量

            tChart1.Axes.Left.Increment = 0;   //纵坐标增量

            int lenx = XValue.Length;

            tChart1.Axes.Bottom.SetMinMax(0, lenx - 1);
            tChart1.Refresh();

            tChart1.Axes.Bottom.Labels.MultiLine = false;
        }
コード例 #12
0
        /// <summary>
        /// 向TChart添加曲线,根据选择列定义纵轴
        /// </summary>
        /// <param name="tChart1"></param>
        /// <param name="tmp_line"></param>
        /// <param name="dgv"></param>
        /// <param name="Xindex">自定义横轴所在列</param>
        private void AddLine(TChart tChart1, Line tmp_line, DataGridView dgv, int Xindex)//Xindex表示X轴所在列
        {
            int j = 0;

            dgv.MultiSelect = false;
            double   tmp_value = 0;
            DateTime tmp_times;

            j = dgv.CurrentCell.ColumnIndex;
            int count = dgv.Rows.Count;

            double[]   tmp_Yvalue = new double[count - 1];
            DateTime[] tmp_time   = new DateTime[count - 1];
            string[]   XValue     = new string[count - 1];
            for (int i = 0; i < dgv.Rows.Count - 1; i++)//y轴数据列
            {
                if (j != 0)
                {
                    if (double.TryParse(dgv.Rows[i].Cells[j].Value.ToString(), out tmp_value))
                    {
                        if (dgv.Rows[i].Cells[j].Value.ToString() != "" && dgv.Rows[i].Cells[j].Value != null)
                        {
                            tmp_Yvalue[i] = Convert.ToDouble(dgv.Rows[i].Cells[j].Value.ToString());
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择数据列!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        for (int s = 0; s < dgv.Rows.Count - 1; s++)
                        {
                            tmp_Yvalue[s] = 0;
                        }
                        break;
                    }
                }
            }
            for (int i = 0; i < dgv.Rows.Count - 1; i++)//x轴是否为时间列
            {
                if (j != 0)
                {
                    if (DateTime.TryParse(dgv.Rows[i].Cells[Xindex].Value.ToString(), out tmp_times))
                    {
                        if (dgv.Rows[i].Cells[Xindex].Value.ToString() != "" && dgv.Rows[i].Cells[Xindex].Value != null)
                        {
                            tmp_time[i] = Convert.ToDateTime(dgv.Rows[i].Cells[Xindex].Value.ToString());
                        }
                        flagtime = true;
                    }
                    else
                    {
                        flagtime = false;
                        break;
                    }
                }
            }
            for (int i = 0; i < dgv.Rows.Count - 1; i++)//x轴不为时间列
            {
                if (j != 0)
                {
                    if (!flagtime)
                    {
                        if (dgv.Rows[i].Cells[Xindex].Value.ToString() != "" && dgv.Rows[i].Cells[Xindex].Value != null)
                        {
                            XValue[i] = dgv.Rows[i].Cells[Xindex].Value.ToString();
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            tChart1.Aspect.View3D           = false; //是否3D显示
            tmp_line.Marks.Gradient.Visible = true;  //显示网格
            tmp_line.Marks.Visible          = false;

            tmp_line.Marks.Gradient.StartColor = Color.FromArgb(255, 215, 0);//网格颜色设置
            tmp_line.Marks.Gradient.EndColor   = Color.White;
            tmp_line.Marks.Symbol.Visible      = true;
            if (flagtime)//横轴为时间列
            {
                tmp_line.XValues.DateTime = true;
                tmp_line.Add(tmp_time, tmp_Yvalue);
                tChart1.Axes.Bottom.Increment             = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneMonth);//横坐标按月增量
                tChart1.Axes.Bottom.Labels.DateTimeFormat = "yyyy-MM-dd";
                tChart1.Axes.Bottom.Automatic             = true;
                sdt = getMin(tmp_time).AddDays(-1);
                edt = getMax(tmp_time).AddDays(1);
                tChart1.Axes.Bottom.SetMinMax(sdt, edt);
            }
            else
            {
                for (int m = 0; m < tmp_Yvalue.Length; m++)
                {
                    tmp_line.Add(tmp_Yvalue[m], XValue[m]);
                }
                int len = XValue.Length;
                tChart1.Axes.Bottom.SetMinMax(0, len);
            }
            tmp_line.Pointer.Visible    = true;
            tmp_line.Pointer.Style      = Steema.TeeChart.Styles.PointerStyles.SmallDot;
            tmp_line.Pointer.Color      = Color.Black;
            tChart1.Axes.Left.Automatic = false;
            tChart1.Axes.Left.Minimum   = getMin(tmp_Yvalue) - 1;
            tChart1.Axes.Left.Maximum   = getMax(tmp_Yvalue) + 1;

            tChart1.Axes.Left.Increment = 0;//纵坐标增量
            //  tChart1.Page.MaxPointsPerPage = 0;
            /// tChart1.Axes.Bottom.Increment = 0;//横坐标增量
            tChart1.Axes.Bottom.Labels.MultiLine = false;
            tChart1.Refresh();
        }