示例#1
0
        public void DisplayChart(Chart dchart)
        {
            if (dchart.Series.Count == 0)
            {
                var series = new Series("Chart")
                                 {
                                     ChartType = SeriesChartType.Line,
                                     Color = System.Drawing.Color.MediumPurple,
                                     BorderWidth = 2
                                 };
                MethodInvoker action = delegate { dchart.Series.Add(series); };
                dchart.Invoke(action);

            }
            else
            {

                MethodInvoker action = delegate
                                           {
                                               dchart.Series[0].Points.AddXY(MaxDt.ToShortDateString(), Strategyperformance.EntireTradesSum);
                                               dchart.Legends[0].Enabled = false;
                                           };
                dchart.Invoke(action);
            }
        }
示例#2
0
        private void ScopeConfig_Load(object sender, EventArgs e)
        {
            LineStyleCn.Items.Add(SeriesChartType.Line.ToString());
            LineStyleCn.Items.Add(SeriesChartType.Spline.ToString());
            LineStyleCn.DefaultCellStyle.NullValue = SeriesChartType.Line.ToString();

            for (int i = 0; i < SeriesCount; i++)
            {
                ConfigDGView.Rows.Add();
                ConfigDGView.Rows[i].Cells[0].Value = true;
                ConfigDGView.Rows[i].Cells[1].Value = "Series" + (i + 1).ToString();

                ConfigDGView.Rows[i].Cells[4].Value = (2).ToString();
            }

            ScopeChart.Invoke(new EventHandler(delegate
            {
                for (int i = 0; i < SeriesCount; i++)
                {
                    ((DataGridViewComboBoxCell)ConfigDGView.Rows[i].Cells[2]).Style.NullValue =
                        ScopeChart.Series[i].ChartType.ToString();
                    Bitmap BI  = new Bitmap(ConfigDGView.Columns[3].Width, ConfigDGView.Rows[0].Height);
                    Graphics g = Graphics.FromImage(BI);
                    g.Clear(ScopeChart.Series[i].Color);
                    ConfigDGView.Rows[i].Cells[3].Value = BI;

                    SeriesColorConfig.Add(ScopeChart.Series[i].Color);
                }
            }));
            ConfigDGView.Size = new Size(534, 300);
            ColorBtn.Size     = new System.Drawing.Size(ConfigDGView.Size.Width, ColorBtn.Size.Height);
            ColorBtn.Location = new Point(0, ConfigDGView.Size.Height + ConfigDGView.Location.Y);

            this.Size = new Size(545, 340 + ColorBtn.Height);
        }
示例#3
0
 public ScopeConfig(System.Windows.Forms.DataVisualization.Charting.Chart SC)
 {
     InitializeComponent();
     SC.Invoke(new EventHandler(delegate
     {
         SeriesCount = SC.Series.Count;
         ScopeChart  = SC;
     }));
 }
示例#4
0
        public void ChartClear(object tChart)
        {
            Chart chart = (Chart)tChart;

            if (chart.InvokeRequired)
            {
                SetchartClearCallback d = new SetchartClearCallback(ChartClear);
                chart.Invoke(d, new object[] { chart });
            }
            else
            {
                chart.Series.Clear();
            }
        }
        /// <summary>
        /// Main loop for the thread that adds data to the chart.
        /// The main purpose of this function is to Invoke AddData
        /// function every 1000ms (1 second).
        /// </summary>
        private void AddDataThreadLoop()
        {
            try
            {
                while (true)
                {
                    // Invoke method must be used to interact with the chart
                    // control on the form!
                    chart1.Invoke(addDataDel);

                    // Thread is inactive for 200ms
                    Thread.Sleep(200);
                }
            }
            catch
            {
                // Thread is aborted
            }
        }
示例#6
0
 private void PlotXYAppend(Chart chart, Series dataSeries, double x, double y)
 {
     chart.Invoke(new PlotXYDelegate(dataSeries.Points.AddXY), new Object[] { x, y });
 }
示例#7
0
        void updateChart(Chart chart, int i, Double[] points)
        {
            if (chart.InvokeRequired)
            {
                chart.Invoke(new updateChartDelegate(updateChart), new object[] { chart, i, points });
            }
            else
            {
                if (chart.Series[i].Points.Count > 0)
                    chart.Series[i].Points.Clear();

                for (int j = 0; j < points.Length; j++)
                    chart.Series[i].Points.Add(points[j]);
            }
        }
示例#8
0
        void updateChart(Chart chart, int series, Double[] points, bool saveImage, String path)
        {
            if (chart.InvokeRequired)
            {
                chart.Invoke(new updateChartSaveImageDelegate(updateChart), new object[] { chart, series, points, saveImage, path });
            }
            else
            {
                updateChart(chart, series, points);

                if (saveImage)
                {
                    String file = String.Format(filePath + "\\{0}\\{1}.png", path, counter_power++);
                    (new System.IO.FileInfo(file)).Directory.Create();
                    chart.SaveImage(file, ChartImageFormat.Png);
                }

                //for (int j = 0; j < chart.Series.Count; j++)
                //    chart.Series[j].Points.Clear();
            }
        }
示例#9
0
 void resetChart(Chart chart, int from, int to)
 {
     if (chart.InvokeRequired)
     {
         chart.Invoke(new resetChartDelegate(resetChart), new object[] { chart, from, to });
     }
     else
     {
         for (int j = from; j < to; j++)
             chart.Series[j].Points.Clear();
     }
 }
示例#10
0
 void resetChart(Chart chart, int from, int to, bool saveImage, String path)
 {
     if (chart.InvokeRequired)
     {
         chart.Invoke(new resetChartSaveImageDelegate(resetChart), new object[] { chart, from, to, saveImage, path });
     }
     else
     {
         if (saveImage)
         {
             String file = String.Format(filePath + "\\{0}\\{1}.png", path, counter_day++);
             (new System.IO.FileInfo(file)).Directory.Create();
             chart.SaveImage(file, ChartImageFormat.Png);
         }
         resetChart(chart, from, to);
     }
 }
示例#11
0
        private void point2Chart(PointD newPoint, Chart chartName)
        {
            if (chartName.InvokeRequired)
                chartName.Invoke(new AddDataToChartDelegate(this.point2Chart), new object[] { newPoint, chartName });
            else
            {
                chartName.Series["Series1"].Points.AddXY(newPoint.X, newPoint.Y);

                if (chartName.Series["Series1"].Points.Count > pointsInChart)
                {
                    chartName.Series["Series1"].Points.RemoveAt(0);
                }

                chartName.ChartAreas["ChartArea1"].AxisX.Minimum = chartName.Series["Series1"].Points[0].XValue;
                chartName.ChartAreas["ChartArea1"].AxisX.Maximum = chartName.Series["Series1"].Points[chartName.Series["Series1"].Points.Count-1].XValue;

            }
        }
示例#12
0
        public void DrawLine(object oChart, plotData temp, string seriName, LineType lineType)
        {
            Chart chart = (Chart)oChart;

            if (chart.InvokeRequired)
            {
                SetDrawLineCallBack d = DrawLine;
                chart.Invoke(d, new object[] { chart, temp, seriName, lineType });
            }
            else
            {
                //绑定数据
                int index = chart.Series.Count;


                chart.Series.Add(seriName);

                Series currentSeries = chart.Series[index];
                //chart.Titles[index].Alignment = System.Drawing.ContentAlignment.TopRight;
                currentSeries.XValueType = ChartValueType.Single;  //设置X轴上的值类型
                //currentSeries.Label = "#VAL";                //设置显示X Y的值
                //currentSeries.LabelForeColor = Color.Black;
                currentSeries.ToolTip   = "#VALX:#VAL";             //鼠标移动到对应点显示数值
                currentSeries.ChartType = SeriesChartType.FastLine; //图类型(折线)
                //currentSeries.ChartType = SeriesChartType.Line;    //图类型(折线)
                currentSeries.IsValueShownAsLabel = false;
                currentSeries.LegendText          = seriName;
                currentSeries.IsVisibleInLegend   = true;
                //chart.Legends[seriName].Enabled = true;
                //chart.Legends[seriName].MaximumAutoSize = 15;
                //chart.Series[0].IsValueShownAsLabel = true;

                // currentSeries.LabelForeColor = Color.Black;

                // currentSeries.CustomProperties = "DrawingStyle = Cylinder";
                currentSeries.Points.DataBindXY(temp.xData, temp.yData);

                switch (lineType)
                {
                case LineType.Fre:
                    for (int i = 1; i < 10; i++)
                    {
                        CustomLabel label = new CustomLabel();
                        label.Text       = (i * 5).ToString() + "Ghz";
                        label.ToPosition = i * 10000000000;
                        chart.ChartAreas[0].AxisX.CustomLabels.Add(label);
                        label.GridTicks = GridTickTypes.Gridline;
                    }
                    break;

                case LineType.Time:
                    for (int i = 1; i < 10; i++)
                    {
                        CustomLabel label = new CustomLabel();
                        label.Text       = (i * 1).ToString() + "ns";
                        label.ToPosition = (float)i * 2;
                        chart.ChartAreas[0].AxisX.CustomLabels.Add(label);
                        label.GridTicks = GridTickTypes.Gridline;
                    }
                    break;
                }

                //chart.Visible = true;
            }
        }