示例#1
0
        /// <summary>
        /// Mouse Move Event
        /// </summary>
        private void Chart1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // Check if data point selected
            if (selectedDataPoint != null)
            {
                // Mouse coordinates should not be outside of the chart
                int coordinate = e.Y;
                if (coordinate < 0)
                {
                    coordinate = 0;
                }
                if (coordinate > Chart1.Size.Height - 1)
                {
                    coordinate = Chart1.Size.Height - 1;
                }

                // Calculate new Y value from current cursor position
                double yValue = Chart1.ChartAreas["Default"].AxisY.PixelPositionToValue(coordinate);
                yValue = Math.Min(yValue, Chart1.ChartAreas["Default"].AxisY.Maximum);
                yValue = Math.Max(yValue, Chart1.ChartAreas["Default"].AxisY.Minimum);


                if ((yValue <= 0) &&
                    (Chart1.Series["Default"].ChartType == SeriesChartType.Column))
                {
                    yValue = 0.01;
                }

                // Update selected point Y value
                selectedDataPoint.YValues[0] = yValue;


                // Invalidate chart
                Chart1.Invalidate();

                // Force the chart to redraw
                Chart1.Update();
            }
            else
            {
                // Set different shape of cursor over the data points
                HitTestResult hitResult = Chart1.HitTest(e.X, e.Y);
                if (hitResult.ChartElementType == ChartElementType.DataPoint)
                {
                    Chart1.Cursor = Cursors.Hand;
                }
                else
                {
                    Chart1.Cursor = Cursors.Default;
                }
            }
        }
示例#2
0
        public string GeneratePlot(double[] items, string title)
        {
            string file = "";
            chart = new Chart();

            chart.ChartAreas.Add(new ChartArea());
            int i = 1;
            foreach (var item in items)
            {
                SetChart(title, i, item);
                i++;
            }

            DateTime d = DateTime.Now;
            var xxx = String.Format("{0}_{1}_{2}_{3}_{4}_{5}_{6}", d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second, d.Millisecond);
            String chartFilename = Common.Folder.Data + "\\" + xxx + ".bmp";
            chart.Update();
            chart.SaveImage(chartFilename, System.Drawing.Imaging.ImageFormat.Bmp);
            file = chartFilename;

            return file;
        }
示例#3
0
文件: cWell.cs 项目: cyrenaique/HCS
        public Chart GetChart()
        {
            if (ListDescriptors[CurrentDescriptorToDisplay].GetAssociatedType().GetBinNumber() == 1) return null;

            Series CurrentSeries = new Series("ChartSeries" + PosX + "x" + PosY);
            //CurrentSeries.ShadowOffset = 2;

            for (int IdxValue = 0; IdxValue < ListDescriptors[CurrentDescriptorToDisplay].GetAssociatedType().GetBinNumber(); IdxValue++)
                CurrentSeries.Points.Add(ListDescriptors[CurrentDescriptorToDisplay].Getvalue(IdxValue));

            ChartArea CurrentChartArea = new ChartArea("ChartArea" + PosX + "x" + PosY);
            CurrentChartArea.BorderColor = Color.White;

            Chart ChartToReturn = new Chart();
            ChartToReturn.ChartAreas.Add(CurrentChartArea);
               // ChartToReturn.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
            CurrentChartArea.BackColor = Color.White;

            CurrentChartArea.Axes[1].LabelStyle.Enabled = false;
            CurrentChartArea.Axes[1].MajorGrid.Enabled = false;
            CurrentChartArea.Axes[0].Enabled = AxisEnabled.False;
            CurrentChartArea.Axes[1].Enabled = AxisEnabled.False;

            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
              //  CurrentChartArea.Axes[0].Title = ListDescriptors[CurrentDescriptorToDisplay].GetName();
            CurrentSeries.ChartType = SeriesChartType.Line;
            CurrentSeries.Color = Color.Black;
               // CurrentSeries.BorderWidth = 3;
            CurrentSeries.ChartArea = "ChartArea" + PosX + "x" + PosY;

            CurrentSeries.Name = "Series" + PosX + "x" + PosY;
            ChartToReturn.Series.Add(CurrentSeries);

            Title CurrentTitle = new Title(PosX + "x" + PosY);
               // ChartToReturn.Titles.Add(CurrentTitle);

            ChartToReturn.Width = 100;
            ChartToReturn.Height = 48;

            ChartToReturn.Update();
              //  ChartToReturn.Show();

            return ChartToReturn;
        }
示例#4
0
        //=============================================================
        private void Marker(Chart ch, int SerNum, int PointNum, int opt)
        {
            int serlen;
            switch (opt)
            {
                case 0://change
                    ch.Series[SerNum].Points[PointNum].MarkerStyle = MarkerStyle.Cross;
                    ch.Series[SerNum].Points[PointNum].MarkerSize = 5;
                    ch.Series[SerNum].Points[PointNum].MarkerColor = System.Drawing.Color.Red;
                    ch.Update();
                    break;
                case 1://restore point
                    ch.Series[SerNum].Points[PointNum].MarkerStyle = ch.Series[SerNum].MarkerStyle;
                    ch.Series[SerNum].Points[PointNum].MarkerSize = ch.Series[SerNum].MarkerSize;
                    ch.Series[SerNum].Points[PointNum].MarkerColor = ch.Series[SerNum].MarkerColor;
                    ch.Update();
                    break;
                case 2://restore series ?????????????
                    serlen = ch.Series[SerNum].Points.Count;
                    for (int i = 0; i < serlen; i++)
                    {
                        if (ch.Series[SerNum].Points[i].MarkerStyle != ch.Series[SerNum].MarkerStyle)
                            ch.Series[SerNum].Points[i].MarkerStyle = ch.Series[SerNum].MarkerStyle;
                        if (ch.Series[SerNum].Points[i].MarkerSize != ch.Series[SerNum].MarkerSize)
                            ch.Series[SerNum].Points[i].MarkerSize = ch.Series[SerNum].MarkerSize;
                        if (ch.Series[SerNum].Points[i].MarkerColor != ch.Series[SerNum].MarkerColor)
                            ch.Series[SerNum].Points[i].MarkerColor = ch.Series[SerNum].MarkerColor;
                    }
                    ch.Update();

                    break;
                default:
                    break;
            }
        }