Exemple #1
0
 //zoom functionality.
 private void zoomToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Charting.Axis XAXIS = chart1.ChartAreas[0].AxisX;
     XAXIS.ScaleView.Zoom(chart1.ChartAreas[0].CursorX.SelectionStart, chart1.ChartAreas[0].CursorX.SelectionEnd);
     chart1.ChartAreas[0].CursorX.SelectionStart = double.NaN;
     chart1.ChartAreas[0].CursorX.SelectionEnd   = double.NaN;
 }
        private void cbAxisType_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (cbAxisType.SelectedIndex)
            {
                case 0: //Primary Axis
                    ptrXAxis = ptrChartArea.AxisX;
                    ptrYAxis = ptrChartArea.AxisY;
                    break;

                case 1:  //Secondary Axis
                    ptrXAxis = ptrChartArea.AxisX2;
                    ptrYAxis = ptrChartArea.AxisY2;
                    break;
            }
            txtXLimit.Text = string.Format("[{0} to {1}]",
                FormatDouble(ptrXAxis.Minimum),
                FormatDouble(ptrXAxis.Maximum));

            txtYLimit.Text = string.Format("[{0} to {1}]",
                FormatDouble(ptrYAxis.Minimum),
                FormatDouble(ptrYAxis.Maximum));

            txtXMin.Text = ptrXAxis.ScaleView.ViewMinimum.ToString();
            txtXMax.Text = ptrXAxis.ScaleView.ViewMaximum.ToString();
            txtYMin.Text = ptrYAxis.ScaleView.ViewMinimum.ToString();
            txtYMax.Text = ptrYAxis.ScaleView.ViewMaximum.ToString();
        }
 /// <summary>
 /// Sets interval properties for the axis. 
 /// Note that we use the Axis object's interval properties, and not the properties of its label,
 /// and major tick mark and grid line objects
 /// </summary>
 public void SetAxisInterval(Axis axis, double interval, DateTimeIntervalType intervalType, double intervalOffset, DateTimeIntervalType intervalOffsetType )
 {
     // Set interval-related properties
     axis.Interval = interval;
     axis.IntervalType = intervalType;
     axis.IntervalOffset = intervalOffset;
     axis.IntervalOffsetType = intervalOffsetType;
 }
        // CONSTRUCTORS

        // <summary>
        // Initializes a new instance of the FancyControls.Data.Axis class.
        // </summary>
        // <param name="axis">
        // An axis to config.
        // </param>
        internal Axis(System.Windows.Forms.DataVisualization.Charting.Axis axis)
        {
            this.axis           = axis;
            this.text           = null;
            this.titleAlignment = (TitleAlignment)axis.TitleAlignment;

            this.ArrowStyle    = AxisArrowStyle.Lines;
            this.axis.Crossing = 0;
            this.GridLineWidth = 0;
        }
        //“zoomAxis” properly displays results when user inputs numbers; for zooming graph manually
        private void zoomAxis(System.Windows.Forms.DataVisualization.Charting.Axis mAxis, double _newMin, double _newMax)
        {
            //takes two double variables, uses Math for min and max values; positions and scales the size
            double newMax = Math.Max(_newMax, _newMin);
            double newMin = Math.Min(_newMax, _newMin);

            mAxis.Minimum            = Math.Min(mAxis.Minimum, newMin);
            mAxis.Maximum            = Math.Min(mAxis.Maximum, newMax);
            mAxis.ScaleView.Position = newMin;
            mAxis.ScaleView.Size     = newMax - newMin;
        }
        private void FillChart()
        {
            rankingSeriesChart.Series[0].Points.DataBindY(Parameters.z);
            System.Windows.Forms.DataVisualization.Charting.Axis axisX = rankingSeriesChart.ChartAreas[0].AxisX;
            double axisLabelPos = 0.5;

            for (int i = 0; i < 5; i++)
            {
                axisX.CustomLabels.Add(axisLabelPos, axisLabelPos + 1, Parameters.labels[i]);
                axisLabelPos = axisLabelPos + 1.0;
            }
        }
    private void AddCustomLabelToAxis(Axis axis) {
      CustomLabel trainingLabel = new CustomLabel();
      trainingLabel.Text = TrainingLabelText;
      trainingLabel.FromPosition = TrainingAxisValue - TrainingTestBorder;
      trainingLabel.ToPosition = TrainingAxisValue + TrainingTestBorder;
      axis.CustomLabels.Add(trainingLabel);

      CustomLabel testLabel = new CustomLabel();
      testLabel.Text = TestLabelText;
      testLabel.FromPosition = TestAxisValue - TrainingTestBorder;
      testLabel.ToPosition = TestAxisValue + TrainingTestBorder;
      axis.CustomLabels.Add(testLabel);
    }
        public MonitorChart(Chart c, string name)
        {
            m_chart = c;

            // some shortcuts
            m_area = m_chart.ChartAreas[0];
            m_series = m_chart.Series[0];
            m_points = m_series.Points;
            m_axisX = m_area.AxisX;
            m_axisY = m_area.AxisY;

            m_annotations = new Dictionary<int, List<Annotation>>();
            m_name = name;
            Init();
        }
        private void btOK_Click(object sender, EventArgs e)
        {
            bool inputValid = true;

            //Sanity Check
            if (!ValidateInput(txtXMin)) { inputValid = false; }
            if (!ValidateInput(txtXMax)) { inputValid = false; }
            if (!ValidateInput(txtYMin)) { inputValid = false; }
            if (!ValidateInput(txtYMax)) { inputValid = false; }
            if (!inputValid)
            {
                MessageBox.Show("Invalid input values!", this.Text,
                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Limit Check
            double xStart = Convert.ToDouble(txtXMin.Text);
            double xEnd = Convert.ToDouble(txtXMax.Text);
            double yStart = Convert.ToDouble(txtYMin.Text);
            double yEnd = Convert.ToDouble(txtYMax.Text);

            //Perform ZOOM
            double XMin = ptrXAxis.ValueToPixelPosition(xStart);
            double XMax = ptrXAxis.ValueToPixelPosition(xEnd);
            double YMin = ptrYAxis.ValueToPixelPosition(yStart);
            double YMax = ptrYAxis.ValueToPixelPosition(yEnd);

            ptrXAxis.ScaleView.Zoom(xStart, xEnd);
            ptrYAxis.ScaleView.Zoom(yStart, yEnd);

            //Swtich to next axis
            ptrXAxis = (ptrXAxis == ptrChartArea.AxisX) ? ptrChartArea.AxisX2 : ptrChartArea.AxisX;
            ptrYAxis = (ptrYAxis == ptrChartArea.AxisY) ? ptrChartArea.AxisY2 : ptrChartArea.AxisY;
            ptrXAxis.ScaleView.Zoom(ptrXAxis.PixelPositionToValue(XMin), ptrXAxis.PixelPositionToValue(XMax));
            ptrYAxis.ScaleView.Zoom(ptrYAxis.PixelPositionToValue(YMin), ptrYAxis.PixelPositionToValue(YMax));

            DialogResult = DialogResult.OK;
        }
 internal static RectangleF GetBoundariesOfDataCore(Axis axisX, Axis axisY, bool justVisible)
 {
     double left;
     double right;
     double bottom;
     double top;
     axisX.GetMinMax(out left, out right, justVisible);
     if (axisX.IsReversed)
     {
         var temp = left;
         left = right;
         right = temp;
     }
     axisY.GetMinMax(out bottom, out top, justVisible);
     if (axisY.IsReversed)
     {
         var temp = top;
         top = bottom;
         bottom = temp;
     }
     return ExtentsFromDataCoordinates(left, top, right, bottom);
 }
        private Axis CreateAxisX( ChartSpan span )
        {
            Axis axis = new Axis();

            switch ( span ) {
                case ChartSpan.Day:
                    axis.Interval = 2;
                    axis.IntervalOffsetType = DateTimeIntervalType.Hours;
                    axis.IntervalType = DateTimeIntervalType.Hours;
                    break;
                case ChartSpan.Week:
                    axis.Interval = 12;
                    axis.IntervalOffsetType = DateTimeIntervalType.Hours;
                    axis.IntervalType = DateTimeIntervalType.Hours;
                    break;
                case ChartSpan.Month:
                    axis.Interval = 3;
                    axis.IntervalOffsetType = DateTimeIntervalType.Days;
                    axis.IntervalType = DateTimeIntervalType.Days;
                    break;
                case ChartSpan.Season:
                    axis.Interval = 7;
                    axis.IntervalOffsetType = DateTimeIntervalType.Days;
                    axis.IntervalType = DateTimeIntervalType.Days;
                    break;
                case ChartSpan.Year:
                case ChartSpan.All:
                    axis.Interval = 1;
                    axis.IntervalOffsetType = DateTimeIntervalType.Months;
                    axis.IntervalType = DateTimeIntervalType.Months;
                    break;
            }

            axis.LabelStyle.Format = "MM/dd HH:mm";
            axis.LabelStyle.Font = Font;
            axis.MajorGrid.LineColor = Color.FromArgb( 192, 192, 192 );

            return axis;
        }
Exemple #12
0
        /// <summary>
        /// Sets up the look and style of the chart, Areas.
        /// </summary>
        /// <param name="title">Title of the chart.</param>
        private void ChartAreas(string title)
        {
            var axisX = new System.Windows.Forms.DataVisualization.Charting.Axis
            {
                Interval = 1,
            };

            var axisY = new System.Windows.Forms.DataVisualization.Charting.Axis
            {
                Minimum = 0,
                Maximum = 110,
                Title   = title,
            };

            var chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea
            {
                AxisX = axisX,
                AxisY = axisY,
            };

            this.chart1.ChartAreas.Add(chartArea1);
        }
Exemple #13
0
        /// <summary>
        /// Function to add text as an annotation to the chart.
        /// </summary>
        /// <param name="text">The text that we wish to display.</param>
        /// <param name="AxisX">X-Axis that the text annotation is to use for co-ordinates.</param>
        /// <param name="AxisY">Y-Axis that the text annotation is to use for co-ordinates.</param>
        /// <param name="X">X value for the start of the text.</param>
        /// <param name="Y">Y value for the start of the text.</param>
        /// <param name="output">The chart that the line annotation is being added to.</param>
        private void addTextAnnotation(string text, Axis AxisX, Axis AxisY, double X, double Y, Chart output)
        {
            //Create a new line annotation.
            TextAnnotation textAnnotation = new TextAnnotation();

            //Set each property to the parameters passed in.
            textAnnotation.AxisX = AxisX;
            textAnnotation.AxisY = AxisY;
            textAnnotation.Y = Y;
            textAnnotation.X = X;
            textAnnotation.Text = text;

            //Turn off relative size to get graph-oriented co-ordinates and set the aesthetic properties.
            textAnnotation.IsSizeAlwaysRelative = false;
            textAnnotation.ForeColor = myForeColor;
            textAnnotation.Font = myFont;

            //Add the annotation to the chart.
            output.Annotations.Add(textAnnotation);
        }
		private static void SetupAxisX(Axis axis, GraphConfiguration configuration)
		{
			SetupAxis(axis, configuration.AxisXConfiguration);

			axis.Interval = configuration.AxisXConfiguration.Interval ?? 1;

			switch (configuration.AxisXConfiguration.AxisXLabelFilter.Value)
			{
				case AxisXLabelFilter.All:
					break;

				case AxisXLabelFilter.AllDays:
					axis.IntervalType = DateTimeIntervalType.Days;
					break;

				case AxisXLabelFilter.StartOfMonth:
					axis.IntervalType = DateTimeIntervalType.Months;
					break;

				case AxisXLabelFilter.StartOfWeek:
					axis.IntervalType       = DateTimeIntervalType.Weeks;
					axis.IntervalOffsetType = DateTimeIntervalType.Days;
					axis.IntervalOffset     = configuration.FirstWeekDay - DayOfWeek.Sunday;
					break;

				default:
					throw new ArgumentException(
						"Invalid AxisXLabelFilter value",
						configuration.AxisXConfiguration.AxisXLabelFilter.ToString()
					);
			}
		}
Exemple #15
0
 public static void SetRange(this Dvc.Axis ca, TimeInterval time)
 {
     ca.Minimum = time.Begin.ToOADate();
     ca.Maximum = time.End.ToOADate();
 }
        internal void UpdateChart(LiveDataProcessor ldpa)
        {
            //画四条水平的线,
            //openLine.basePrice;
            //openLine.highPrice;
            //openLine.lowPrice;
            //openLine.volatilePrice;
            //[Database]
            //ConnectStr="Data Source=localhost;Initial Catalog=stockpolicy;Integrated Security=false;User ID=sa;Password=sa123$%^"

            //等待异步
            if (this.InvokeRequired)
            {
                //委托
                this.Invoke(new UpdateDelegate(UpdateChart), new object[] { ldpa });
            }
            else
            {
                this.uc_stockdetail.setStockName(_si.Code, _si.Name);
                #region 原始数据
                try
                {
                    //添加
                    chart_tick.Series.Add(SeriesRowColumn);

                    double max = th.high;
                    double min = th.low;
                    if (Math.Abs(max - th.lastclose) > Math.Abs(th.lastclose - min))
                    {
                        min  = th.lastclose - (max - th.lastclose) - 500;
                        max += 500;
                    }
                    else
                    {
                        max  = th.lastclose + (th.lastclose - min) + 500;
                        min -= 500;
                    }

                    System.Windows.Forms.DataVisualization.Charting.Axis y = new System.Windows.Forms.DataVisualization.Charting.Axis();
                    //设置Y轴的最大值
                    y.Maximum = max;
                    //设置Y轴的最小值
                    y.Minimum = min;
                    //显示网格线
                    y.MajorGrid.Enabled = true;
                    //设置网格之前的间隔
                    y.MajorGrid.Interval = th.lastclose - min;
                    //设置网格线的颜色
                    y.MajorGrid.LineColor = Color.Red;
                    //设置网格线的宽度
                    y.MajorGrid.LineWidth = 2;
                    //显示网格线
                    y.MinorGrid.Enabled = true;
                    //把chart中划分为7个区域
                    y.MinorGrid.Interval = (th.lastclose - min) / 7;
                    //设置网格线的颜色
                    y.MinorGrid.LineColor   = Color.Red;
                    y.MajorTickMark.Enabled = false;
                    y.MinorGrid.LineWidth   = 1;
                    y.MinorGrid.Enabled     = true;
                    y.Interval          = y.MinorGrid.Interval;
                    y.LabelStyle.Format = "0.00";
                    y.LabelStyle.Font   = new Font("system", 11);
                    System.Windows.Forms.DataVisualization.Charting.Axis y2 = new System.Windows.Forms.DataVisualization.Charting.Axis();
                    y2.Maximum  = Math.Round((max - th.lastclose) / th.lastclose, 4);
                    y2.Minimum  = -y2.Maximum;
                    y2.Interval = y2.Maximum / 7;
                    //不设置Y2轴的网格线属性
                    y2.MajorGrid.Enabled = false;
                    //不显示Y2轴的网格线特征
                    y2.MinorGrid.Enabled            = false;
                    y2.LabelStyle.Format            = "0.00%";
                    y2.MajorTickMark.Enabled        = false;
                    y2.MinorTickMark.Enabled        = false;
                    y2.LabelStyle.Font              = new Font("system", 11);
                    chart_tick.ChartAreas[0].AxisY  = y;
                    chart_tick.ChartAreas[0].AxisY2 = y2;
                    //显示Y轴的辅助线
                    chart_tick.ChartAreas[0].AxisY2.Enabled = AxisEnabled.True;
                    //不显示X轴的网格线属性
                    chart_tick.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
                    //不显示X轴的网格线特征
                    chart_tick.ChartAreas[0].AxisX.MinorGrid.Enabled = false;
                    //不设置X轴的边距设置
                    chart_tick.ChartAreas[0].AxisX.IsMarginVisible = false;
                    chart_tick.ChartAreas[0].AxisX.IsMarginVisible = false;
                    chart_tick.ChartAreas[0].CursorX.LineColor     = Color.Blue;
                    chart_tick.ChartAreas[0].CursorY.LineColor     = Color.Blue;

                    chart_tick.ChartAreas[0].CursorX.IsUserEnabled          = true;
                    chart_tick.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
                    chart_tick.ChartAreas[0].AxisX.ScrollBar.Enabled        = true;
                    chart_tick.ChartAreas[0].CursorX.IsUserEnabled          = true;
                    chart_tick.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
                    chart_tick.ChartAreas[0].AxisX.ScaleView.Zoomable       = true;
                    //将滚动内嵌到坐标轴中
                    chart_tick.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;
                    // 设置滚动条的大小
                    chart_tick.ChartAreas[0].AxisX.ScrollBar.Size = 10;
                    // 设置滚动条的按钮的风格,下面代码是将所有滚动条上的按钮都显示出来
                    chart_tick.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
                }
                catch { }
                #endregion

                #region 分时
                try
                {
                    //清除chart1中数据
                    this.chart_fengshi.Series.Clear();

                    chart_fengshi.Series.Add(SeriesFenShiColumn);
                    //获取或设置数据的名称
                    chart_fengshi.Series[0].Name = string.Empty;
                    //new一个y轴的方法
                    double lastclose = ldpa.Bar1M.Bars.First().Value.Close;

                    if (Math.Abs(FenShiMax - lastclose) > Math.Abs(lastclose - FenShiMin))
                    {
                        FenShiMin  = lastclose - (FenShiMax - lastclose) - 500;
                        FenShiMax += 500;
                    }
                    else
                    {
                        FenShiMax  = lastclose + (lastclose - FenShiMin) + 500;
                        FenShiMin -= 500;
                    }

                    System.Windows.Forms.DataVisualization.Charting.Axis y = new System.Windows.Forms.DataVisualization.Charting.Axis();
                    y.Maximum              = FenShiMax;
                    y.Minimum              = FenShiMin;
                    y.LineColor            = Color.Red;
                    y.MajorGrid.LineColor  = Color.Red;
                    y.MajorGrid.Interval   = lastclose - FenShiMin;
                    y.LabelStyle.ForeColor = Color.Red;

                    y.MinorGrid.Enabled       = true;
                    y.MinorGrid.Interval      = (lastclose - FenShiMin) / 7;
                    y.MinorGrid.LineColor     = Color.Red;
                    y.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
                    y.MajorTickMark.Enabled   = false;
                    y.MinorGrid.LineWidth     = 1;
                    y.MinorGrid.Enabled       = true;
                    y.Interval          = y.MinorGrid.Interval;
                    y.LabelStyle.Format = "0.00";
                    //y轴上的值
                    chart_fengshi.ChartAreas[0].AxisY = y;


                    System.Windows.Forms.DataVisualization.Charting.Axis y2 = new System.Windows.Forms.DataVisualization.Charting.Axis();
                    y2.Maximum               = Math.Round((FenShiMax - lastclose) / lastclose, 4);
                    y2.Minimum               = -y2.Maximum;
                    y2.Interval              = y2.Maximum / 7;
                    y2.MajorGrid.Enabled     = false;
                    y2.MinorGrid.Enabled     = false;
                    y2.LabelStyle.Format     = "0.00%";
                    y2.MajorTickMark.Enabled = false;
                    y2.MinorTickMark.Enabled = false;
                    y2.LineColor             = Color.Red;
                    y2.LabelStyle.ForeColor  = Color.Red;

                    chart_fengshi.ChartAreas[0].AxisY2         = y2;
                    chart_fengshi.ChartAreas[0].AxisY2.Enabled = AxisEnabled.True;

                    //new一个x轴的方法
                    System.Windows.Forms.DataVisualization.Charting.Axis x = new System.Windows.Forms.DataVisualization.Charting.Axis();
                    //设置x的最小值为0
                    x.Minimum = 0;
                    //设置x的最大值为240
                    x.Maximum = SeriesFenShiColumn.Points.Count - 1;
                    //表示取消x轴的网格线
                    x.IsMarginVisible         = false;
                    x.LineColor               = Color.Red;
                    x.MajorGrid.Interval      = 120;
                    x.MajorGrid.LineColor     = Color.Red;
                    x.MajorGrid.LineDashStyle = ChartDashStyle.Dot;
                    x.LabelStyle.ForeColor    = Color.Red;
                    x.MinorGrid.Interval      = 30;
                    x.MinorGrid.LineColor     = Color.Red;
                    x.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
                    x.Interval          = x.MinorGrid.Interval;
                    x.MinorGrid.Enabled = true;

                    chart_fengshi.ChartAreas[0].AxisX = x;
                    //背景颜色
                    chart_fengshi.ChartAreas[0].BackColor = Color.White;
                    //Y轴光标间隔
                    chart_fengshi.ChartAreas[0].CursorY.Interval = 0.001;
                    //X轴光标间隔
                    chart_fengshi.ChartAreas[0].CursorX.Interval               = 0.001;
                    chart_fengshi.ChartAreas[0].CursorX.IsUserEnabled          = true;
                    chart_fengshi.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
                    chart_fengshi.ChartAreas[0].AxisX.ScaleView.Zoomable       = true;
                    //将滚动内嵌到坐标轴中
                    chart_fengshi.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;
                    // 设置滚动条的大小
                    chart_fengshi.ChartAreas[0].AxisX.ScrollBar.Size = 10;
                    // 设置滚动条的按钮的风格,下面代码是将所有滚动条上的按钮都显示出来
                    chart_fengshi.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
                    // 设置自动放大与缩小的最小量
                    chart_fengshi.ChartAreas[0].AxisX.ScaleView.SmallScrollSize    = double.NaN;
                    chart_fengshi.ChartAreas[0].AxisX.ScaleView.SmallScrollMinSize = 1;
                }
                catch { }
                #endregion
                #region 5分钟K
                try
                {
                    this.chart_5m.Series.Clear();
                    chart_5m.Series.Add(Series5Column);
                    double lastclose = ldpa.Bar5M.Bars.First().Value.Close;
                    if (Math.Abs(FiveMax - lastclose) > Math.Abs(lastclose - FiveMin))
                    {
                        FiveMin = lastclose - (FiveMax - lastclose);
                    }
                    else
                    {
                        FiveMax = lastclose + (lastclose - FiveMin);
                    }

                    System.Windows.Forms.DataVisualization.Charting.Axis x = new System.Windows.Forms.DataVisualization.Charting.Axis();
                    x.Minimum = 0;

                    x.Maximum                 = ldpa.Bar5M.Bars.Count - 1;
                    x.IsMarginVisible         = false;
                    x.LineColor               = Color.Red;
                    x.MajorGrid.Interval      = 120;
                    x.MajorGrid.LineColor     = Color.Red;
                    x.MajorGrid.LineDashStyle = ChartDashStyle.Dot;
                    x.LabelStyle.ForeColor    = Color.Red;
                    x.MinorGrid.Interval      = 30;
                    x.MinorGrid.LineColor     = Color.Red;
                    x.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
                    x.Interval                = x.MinorGrid.Interval;
                    x.MinorGrid.Enabled       = true;

                    System.Windows.Forms.DataVisualization.Charting.Axis y = new System.Windows.Forms.DataVisualization.Charting.Axis();
                    y.Maximum              = FiveMax;
                    y.Minimum              = FiveMin;
                    y.LineColor            = Color.Red;
                    y.MajorGrid.LineColor  = Color.Red;
                    y.MajorGrid.Interval   = lastclose - FiveMin;
                    y.LabelStyle.ForeColor = Color.Red;

                    y.MinorGrid.Enabled       = true;
                    y.MinorGrid.Interval      = (lastclose - FiveMin) / 7;
                    y.MinorGrid.LineColor     = Color.Red;
                    y.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
                    y.MajorTickMark.Enabled   = false;
                    y.MinorGrid.LineWidth     = 1;
                    y.MinorGrid.Enabled       = true;
                    y.Interval          = y.MinorGrid.Interval;
                    y.LabelStyle.Format = "0.00";

                    System.Windows.Forms.DataVisualization.Charting.Axis y2 = new System.Windows.Forms.DataVisualization.Charting.Axis();
                    y2.Maximum                            = Math.Round((FiveMax - lastclose) / lastclose, 4);
                    y2.Minimum                            = -y2.Maximum;
                    y2.Interval                           = y2.Maximum / 7;
                    y2.MajorGrid.Enabled                  = false;
                    y2.MinorGrid.Enabled                  = false;
                    y2.LabelStyle.Format                  = "0.00%";
                    y2.MajorTickMark.Enabled              = false;
                    y2.MinorTickMark.Enabled              = false;
                    y2.LineColor                          = Color.Red;
                    y2.LabelStyle.ForeColor               = Color.Red;
                    chart_5m.ChartAreas[0].AxisY          = y;
                    chart_5m.ChartAreas[0].AxisX          = x;
                    chart_5m.ChartAreas[0].AxisY2         = y2;
                    chart_5m.ChartAreas[0].AxisY2.Enabled = AxisEnabled.True;
                    chart_5m.ChartAreas[0].BackColor      = Color.White;

                    chart_5m.ChartAreas[0].CursorX.IsUserEnabled          = true;
                    chart_5m.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
                    chart_5m.ChartAreas[0].AxisX.ScaleView.Zoomable       = true;
                    //将滚动内嵌到坐标轴中
                    chart_5m.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;
                    // 设置滚动条的大小
                    chart_5m.ChartAreas[0].AxisX.ScrollBar.Size = 10;
                    // 设置滚动条的按钮的风格,下面代码是将所有滚动条上的按钮都显示出来
                    chart_5m.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
                    // 设置自动放大与缩小的最小量
                    chart_5m.ChartAreas[0].AxisX.ScaleView.SmallScrollSize    = double.NaN;
                    chart_5m.ChartAreas[0].AxisX.ScaleView.SmallScrollMinSize = 1;

                    chart_5m.ChartAreas[0].CursorY.IsUserEnabled          = true;
                    chart_5m.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
                    chart_5m.ChartAreas[0].AxisY.ScaleView.Zoomable       = true;
                    //将滚动内嵌到坐标轴中
                    chart_5m.ChartAreas[0].AxisY.ScrollBar.IsPositionedInside = true;
                    // 设置滚动条的大小
                    chart_5m.ChartAreas[0].AxisY.ScrollBar.Size = 10;
                    // 设置滚动条的按钮的风格,下面代码是将所有滚动条上的按钮都显示出来
                    chart_5m.ChartAreas[0].AxisY.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
                    // 设置自动放大与缩小的最小量
                    chart_5m.ChartAreas[0].AxisY.ScaleView.SmallScrollSize    = double.NaN;
                    chart_5m.ChartAreas[0].AxisY.ScaleView.SmallScrollMinSize = 1;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                #endregion
                #region 1分钟K
                try
                {
                    this.chart1.Series.Clear();
                    chart1.Series.Add(Series1Column);

                    double lastclose = ldpa.Bar1M.Bars.First().Value.Close;
                    if (Math.Abs(OneMax - lastclose) > Math.Abs(lastclose - OneMin))
                    {
                        OneMin  = lastclose - (OneMax - lastclose) - 500;
                        OneMax += 500;
                    }
                    else
                    {
                        OneMax  = lastclose + (lastclose - OneMin) + 500;
                        OneMin -= 500;
                    }

                    System.Windows.Forms.DataVisualization.Charting.Axis x = new System.Windows.Forms.DataVisualization.Charting.Axis();
                    x.Minimum = 0;

                    x.Maximum                 = Series1Column.Points.Count - 1;
                    x.IsMarginVisible         = false;
                    x.LineColor               = Color.Red;
                    x.MajorGrid.Interval      = 120;
                    x.MajorGrid.LineColor     = Color.Red;
                    x.MajorGrid.LineDashStyle = ChartDashStyle.Dot;
                    x.LabelStyle.ForeColor    = Color.Red;
                    x.MinorGrid.Interval      = 30;
                    x.MinorGrid.LineColor     = Color.Red;
                    x.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
                    x.Interval                = x.MinorGrid.Interval;
                    x.MinorGrid.Enabled       = true;

                    System.Windows.Forms.DataVisualization.Charting.Axis y = new System.Windows.Forms.DataVisualization.Charting.Axis();
                    y.Maximum              = OneMax;
                    y.Minimum              = OneMin;
                    y.LineColor            = Color.Red;
                    y.MajorGrid.LineColor  = Color.Red;
                    y.MajorGrid.Interval   = lastclose - OneMin;
                    y.LabelStyle.ForeColor = Color.Red;

                    y.MinorGrid.Enabled       = true;
                    y.MinorGrid.Interval      = (lastclose - OneMin) / 7;
                    y.MinorGrid.LineColor     = Color.Red;
                    y.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
                    y.MajorTickMark.Enabled   = false;
                    y.MinorGrid.LineWidth     = 1;
                    y.MinorGrid.Enabled       = true;
                    y.Interval          = y.MinorGrid.Interval;
                    y.LabelStyle.Format = "0.00";

                    System.Windows.Forms.DataVisualization.Charting.Axis y2 = new System.Windows.Forms.DataVisualization.Charting.Axis();
                    y2.Maximum                          = Math.Round((OneMax - lastclose) / lastclose, 4);
                    y2.Minimum                          = -y2.Maximum;
                    y2.Interval                         = y2.Maximum / 7;
                    y2.MajorGrid.Enabled                = false;
                    y2.MinorGrid.Enabled                = false;
                    y2.LabelStyle.Format                = "0.00%";
                    y2.MajorTickMark.Enabled            = false;
                    y2.MinorTickMark.Enabled            = false;
                    y2.LineColor                        = Color.Red;
                    y2.LabelStyle.ForeColor             = Color.Red;
                    chart1.ChartAreas[0].AxisY          = y;
                    chart1.ChartAreas[0].AxisX          = x;
                    chart1.ChartAreas[0].AxisY2         = y2;
                    chart1.ChartAreas[0].AxisY2.Enabled = AxisEnabled.True;
                    chart1.ChartAreas[0].BackColor      = Color.White;

                    chart1.ChartAreas[0].CursorX.IsUserEnabled          = true;
                    chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
                    chart1.ChartAreas[0].AxisX.ScaleView.Zoomable       = true;
                    //将滚动内嵌到坐标轴中
                    chart1.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;
                    // 设置滚动条的大小
                    chart1.ChartAreas[0].AxisX.ScrollBar.Size = 10;
                    // 设置滚动条的按钮的风格,下面代码是将所有滚动条上的按钮都显示出来
                    chart1.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
                    // 设置自动放大与缩小的最小量
                    chart1.ChartAreas[0].AxisX.ScaleView.SmallScrollSize    = double.NaN;
                    chart1.ChartAreas[0].AxisX.ScaleView.SmallScrollMinSize = 1;

                    chart1.ChartAreas[0].CursorY.IsUserEnabled          = true;
                    chart1.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
                    chart1.ChartAreas[0].AxisY.ScaleView.Zoomable       = true;
                    //将滚动内嵌到坐标轴中
                    chart1.ChartAreas[0].AxisY.ScrollBar.IsPositionedInside = true;
                    // 设置滚动条的大小
                    chart1.ChartAreas[0].AxisY.ScrollBar.Size = 10;
                    // 设置滚动条的按钮的风格,下面代码是将所有滚动条上的按钮都显示出来
                    chart1.ChartAreas[0].AxisY.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
                    // 设置自动放大与缩小的最小量
                    chart1.ChartAreas[0].AxisY.ScaleView.SmallScrollSize    = double.NaN;
                    chart1.ChartAreas[0].AxisY.ScaleView.SmallScrollMinSize = 1;
                }
                catch //(Exception ex)
                {
                    // MessageBox.Show(ex.ToString());
                }
                #endregion
            }
        }
 private TextAnnotation CreateTextAnnotation(string name, int classIndex, Axis axisX, Axis axisY, double x, double y, ContentAlignment alignment) {
   TextAnnotation annotation = new TextAnnotation();
   annotation.Text = name;
   annotation.AllowMoving = true;
   annotation.AllowResizing = false;
   annotation.AllowSelecting = false;
   annotation.IsSizeAlwaysRelative = true;
   annotation.ClipToChartArea = chart.ChartAreas[0].Name;
   annotation.Tag = classIndex;
   annotation.AxisX = axisX;
   annotation.AxisY = axisY;
   annotation.Alignment = alignment;
   annotation.X = x;
   annotation.Y = y;
   return annotation;
 }
		private Axis CreateAxisY( int minorInterval, int majorInterval ) {

			Axis axis = new Axis();

			axis.LabelStyle.Font = Font;
			axis.IsStartedFromZero = true;
			axis.Interval = majorInterval;
			axis.MajorGrid.LineColor = Color.FromArgb( 192, 192, 192 );
			axis.MinorGrid.Enabled = true;
			axis.MinorGrid.Interval = minorInterval;
			axis.MinorGrid.LineDashStyle = ChartDashStyle.Dash;
			axis.MinorGrid.LineColor = Color.FromArgb( 224, 224, 224 );

			return axis;
		}
Exemple #19
0
        // updates the plot of ping vs time after it has been created
        private void updateChart(long ping)
        {
            // get reference to axes and series - these will come in handy
            axisX = chartPings.ChartAreas[0].AxisX;
            axisY = chartPings.ChartAreas[0].AxisY;
            pingSeries = chartPings.Series[0];

            updateYAxis();

            axisX.Minimum = DateTime.Now.Subtract(new TimeSpan(0, 0, (int)(traceInterval * nDataPts))).ToOADate();
            axisX.Maximum = DateTime.Now.ToOADate();

            // add current data point
            dates.Add(DateTime.Now);
            pings.Add(ping);

            // plot red for timeouts
            if (ping == -1)
            {

                // first ping is a timeout
                if (pings.Count == 1)
                    pingSeries.Points.AddXY(dates.Last(), -1);
                else
                    pingSeries.Points.AddXY(dates.Last(), pingSeries.Points.Last().YValues[0]);

                // color data points red for timeout
                DataPoint last = pingSeries.Points.Last(); // most recent data point
                last.MarkerStyle = MarkerStyle.Square;
                last.MarkerColor = Color.Red;
            }
            else
            {
                pingSeries.Points.AddXY(dates.Last(), pings.Last());
                DataPoint last = pingSeries.Points.Last(); // most recent data point

                // color code the data points
                if (ping <= 200 && ping != -1)
                    last.Color = Color.Lime;
                if (ping > 200 && ping <= 500)
                    last.Color = Color.Yellow;
                else if (ping > 500)
                    last.Color = Color.Red;
            }

            // show at most nDataPts
            while (pingSeries.Points.Count > nDataPts)
                pingSeries.Points.RemoveAt(0);

            if (pingSeries.Points.Count == nDataPts)
            {
                axisX.Minimum = pingSeries.Points[0].XValue;
                axisX.Maximum = pingSeries.Points.Last().XValue;
            }
        }
Exemple #20
0
 private static bool ApplyTo(Axis c)
 {
     c.LabelStyle.ForeColor = ForeColor;
     return false;
 }
 /// <summary>
 /// Lock/unlock PlaneWidget on specified axis.
 /// </summary>
 /// <param name="axis">axis to lock/unlock</param>
 /// <param name="state">0 to turn off, 1 to turn on</param>
 public void ChangePlaneGadetActivity(Axis axis, int state)
 {
     PlaneWidget widget = null;
     switch (axis)
     {
         case (Axis.X): widget = PlaneWidgetX; break;
         case (Axis.Y): widget = PlaneWidgetY; break;
         case (Axis.Z): widget = PlaneWidgetZ; break;
     }
     if (state == 0)
         widget.InteractionOff();
     if (state == 1)
         widget.InteractionOn();
 }
 public PlaneWidget(Axis axis)
 {
     Axis = axis;
 }
		private static void SetupAxis(Axis axis, AxisConfiguration configuration)
		{
			SetupGrid(axis.MajorGrid, configuration.MajorGrid);
			SetupGrid(axis.MinorGrid, configuration.MinorGrid);

			axis.LabelStyle.Enabled = configuration.ShowLabels ?? false;

			if (axis.LabelStyle.Enabled)
			{
				axis.Enabled        = AxisEnabled.True;
				axis.Title          = configuration.AxisTitleName ?? String.Empty;
				axis.TitleAlignment = StringAlignment.Far;
			}
			else
			{
				axis.Enabled        = AxisEnabled.False;
			}
		}
 /// <summary>
 /// Sets interval properties for the axis. 
 /// Note that we use the Axis object's interval properties, and not the properties of its label,
 /// and major tick mark and grid line objects
 /// </summary>
 public void SetAxisInterval(Axis axis, double interval, DateTimeIntervalType intervalType)
 {
     SetAxisInterval(axis, interval, intervalType, 0, DateTimeIntervalType.Auto);
 }
 private static void GetViewMinMax(Axis axis, out double viewMin, out double viewMax)
 {
     viewMin = axis.ScaleView.ViewMinimum;
     viewMax = axis.ScaleView.ViewMaximum;
 }
Exemple #26
0
        // initializes the plot of ping vs time.
        private void initChart()
        {
            int dx = nDataPts / nGridPts;   // grid spacing
            chartPings.Visible = true;

            // get reference to plot axes
            axisX = chartPings.ChartAreas[0].AxisX;
            axisY = chartPings.ChartAreas[0].AxisY;

            if (AXIS_Y_MAXIMUM>0) {
                axisY.Maximum = AXIS_Y_MAXIMUM;
                }

            // establish the grid and labels
            axisX.LabelStyle.Interval = dx * traceInterval;
            axisX.MajorGrid.Interval = dx * traceInterval;
            axisX.MajorTickMark.Interval = dx * traceInterval;
        }
        /// <summary>
        ///     Handles the zoom for the provided axis
        /// </summary>
        /// <param name="axis"></param>
        /// <param name="mouseLocation"></param>
        /// <param name="minValue"></param>
        /// <param name="maxValue"></param>
        /// <param name="zoomIn"></param>
        private void HandleZoomforAxis(Axis axis, int mouseLocation, double minValue, double maxValue, bool zoomIn)
        {
            double min = axis.ScaleView.ViewMinimum;
            double max = axis.ScaleView.ViewMaximum;

            double start, end;

            if (zoomIn)
            {
                start = Math.Floor(min + (axis.PixelPositionToValue(mouseLocation) - min)/2);
                end = Math.Floor(max - (max - axis.PixelPositionToValue(mouseLocation))/2);
            }
            else
            {
                start = Math.Floor(min - (axis.PixelPositionToValue(mouseLocation) - min));
                end = Math.Floor(max + (max - axis.PixelPositionToValue(mouseLocation)));
            }

            if (start <= minValue || end >= maxValue)
            {
                ResetZoom();
            }
            else
            {
                start = Math.Max(minValue, start);
                end = Math.Min(maxValue, end);

                if (start < end)
                {
                    axis.ScaleView.Zoom(start, end);
                }
            }
        }
 private void SetCustomAxisLabels(Axis axis, int dimension) {
   axis.CustomLabels.Clear();
   if (categoricalMapping.ContainsKey(dimension)) {
     int position = 1;
     foreach (var pair in categoricalMapping[dimension].Where(x => seriesCache.ContainsKey(x.Value))) {
       string labelText = pair.Key.ToString();
       CustomLabel label = new CustomLabel();
       label.ToolTip = labelText;
       if (labelText.Length > 25)
         labelText = labelText.Substring(0, 25) + " ... ";
       label.Text = labelText;
       label.GridTicks = GridTickTypes.TickMark;
       label.FromPosition = position - 0.5;
       label.ToPosition = position + 0.5;
       axis.CustomLabels.Add(label);
       position++;
     }
   } else if (dimension > 0 && Content.GetValue(0, dimension) is TimeSpanValue) {
     this.chart.ChartAreas[0].RecalculateAxesScale();
     Axis correspondingAxis = this.chart.ChartAreas[0].Axes.Where(x => x.Name == axis.Name).SingleOrDefault();
     if (correspondingAxis == null)
       correspondingAxis = axis;
     for (double i = correspondingAxis.Minimum; i <= correspondingAxis.Maximum; i += correspondingAxis.LabelStyle.Interval) {
       TimeSpan time = TimeSpan.FromSeconds(i);
       string x = string.Format("{0:00}:{1:00}:{2:00}", (int)time.Hours, time.Minutes, time.Seconds);
       axis.CustomLabels.Add(i - correspondingAxis.LabelStyle.Interval / 2, i + correspondingAxis.LabelStyle.Interval / 2, x);
     }
   } else if (chart.ChartAreas[BoxPlotChartAreaName].AxisX == axis) {
     double position = 1.0;
     foreach (Series series in chart.Series) {
       if (series.Name != BoxPlotSeriesName) {
         string labelText = series.Points[0].XValue.ToString();
         CustomLabel label = new CustomLabel();
         label.FromPosition = position - 0.5;
         label.ToPosition = position + 0.5;
         label.GridTicks = GridTickTypes.TickMark;
         label.Text = labelText;
         axis.CustomLabels.Add(label);
         position++;
       }
     }
   }
 }
        private void SetPosition(Axis axis, double position)
        {
            if (double.IsNaN(position))
            {
                return;
            }

            if (axis.AxisName == AxisName.X)
            {
                this.tbXPosition.Text = position.ToString();
                this.tbXData.Text = this.chartDataInfo.Series["Default"].Points[(int)position].YValues[0].ToString();
            }
            else
            {
                this.tbYPosition.Text = position.ToString();
                this.tbYData.Text = position.ToString();
            }
        }
Exemple #30
0
        /// <summary>
        /// Function to add a line annotation to the desired chart in the format which is followed by
        /// all the line annotations in this add-on.
        /// </summary>
        /// <param name="AxisX">X-Axis that the line annotation is to use for co-ordinates.</param>
        /// <param name="AxisY">Y-Axis that the line annotation is to use for co-ordinates.</param>
        /// <param name="X">X value for the start of the line.</param>
        /// <param name="Y">Y value for the start of the line.</param>
        /// <param name="Width">Width of the line.</param>
        /// <param name="Height">Height of the line.</param>
        /// <param name="output">The chart that the line annotation is being added to.</param>
        private void addLineAnnotation(Axis AxisX, Axis AxisY, double X, double Y, double Width, double Height, Chart output)
        {
            //Create a new line annotation.
            LineAnnotation lineAnnotation = new LineAnnotation();

            //Set each property to the parameters passed in.
            lineAnnotation.AxisX = AxisX;
            lineAnnotation.AxisY = AxisY;
            lineAnnotation.Y = Y;
            lineAnnotation.X = X;
            lineAnnotation.Height = Height;
            lineAnnotation.Width = Width;

            //Turn off relative size to get graph-oriented co-ordinates and set the line color.
            lineAnnotation.IsSizeAlwaysRelative = false;
            lineAnnotation.LineColor = myLineColor;

            //Add the annotation to the chart.
            output.Annotations.Add(lineAnnotation);
        }
Exemple #31
0
    private void SetupAxis(Axis axis, double minValue, double maxValue, int ticks, double? fixedAxisMin, double? fixedAxisMax) {
      if (minValue < maxValue) {
        double axisMin, axisMax, axisInterval;
        ChartUtil.CalculateAxisInterval(minValue, maxValue, ticks, out axisMin, out axisMax, out axisInterval);
        axis.Minimum = fixedAxisMin ?? axisMin;
        axis.Maximum = fixedAxisMax ?? axisMax;
        axis.Interval = (axis.Maximum - axis.Minimum) / ticks;
      }

      try {
        chart.ChartAreas[0].RecalculateAxesScale();
      }
      catch (InvalidOperationException) {
        // Can occur if eg. axis min == axis max
      }
    }
 // sets an axis to automatic or restrains it to its current values
 // this is used that none of the set values is changed when jitter is applied, so that the chart stays the same
 private void SetAutomaticUpdateOfAxis(Axis axis, bool enabled) {
   if (enabled) {
     axis.Maximum = double.NaN;
     axis.Minimum = double.NaN;
     axis.MajorGrid.Interval = double.NaN;
     axis.MajorTickMark.Interval = double.NaN;
     axis.LabelStyle.Interval = double.NaN;
   } else {
     axis.Minimum = axis.Minimum;
     axis.Maximum = axis.Maximum;
     axis.MajorGrid.Interval = axis.MajorGrid.Interval;
     axis.MajorTickMark.Interval = axis.MajorTickMark.Interval;
     axis.LabelStyle.Interval = axis.LabelStyle.Interval;
   }
 }
        // Set Cursor Position to Edit control.
        private void SetPosition( Axis axis, double position )
        {
            if( double.IsNaN( position ) )
                return;

            if( axis.AxisName == AxisName.X )
            {
                // Convert Double to DateTime.
                DateTime dateTimeX = DateTime.FromOADate( position );

                // Set X cursor position to edit Control
                CursorX.Text = dateTimeX.ToString("ddd, dd MMM");
            }
            else
            {
                // Set Y cursor position to edit Control
                CursorY.Text = position.ToString();
            }
        }
 private void SetCustomAxisLabels(Axis axis, int dimension) {
   axis.CustomLabels.Clear();
   if (categoricalMapping.ContainsKey(dimension)) {
     foreach (var pair in categoricalMapping[dimension]) {
       string labelText = pair.Key.ToString();
       CustomLabel label = new CustomLabel();
       label.ToolTip = labelText;
       if (labelText.Length > 25)
         labelText = labelText.Substring(0, 25) + " ... ";
       label.Text = labelText;
       label.GridTicks = GridTickTypes.TickMark;
       label.FromPosition = pair.Value - 0.5;
       label.ToPosition = pair.Value + 0.5;
       axis.CustomLabels.Add(label);
     }
   } else if (dimension > 0 && Content.GetValue(0, dimension) is TimeSpanValue) {
     this.chart.ChartAreas[0].RecalculateAxesScale();
     for (double i = axis.Minimum; i <= axis.Maximum; i += axis.LabelStyle.Interval) {
       TimeSpan time = TimeSpan.FromSeconds(i);
       string x = string.Format("{0:00}:{1:00}:{2:00}", time.Hours, time.Minutes, time.Seconds);
       axis.CustomLabels.Add(i - axis.LabelStyle.Interval / 2, i + axis.LabelStyle.Interval / 2, x);
     }
   }
 }
        private void Grapher_Load(object sender, EventArgs e)
        {
            State.Wait();

            try
            {
                DataChart = new Chart();
                DataChart.Name = "StockChart";
                DataChart.ChartAreas.Add("StockArea");

                this.Controls.Add(DataChart);
                DataChart.Dock = DockStyle.Fill;

                //DataChart.Series.Add(Stock[StockFile.STOCKTYPE.OVERVIEW]);

                this.UpdateGraph(DateTime.MinValue, DateTime.MaxValue);

                //don't know if the constructors are needed for structs, but meh for now
                ViewStart = new DateTime();
                ViewEnd = new DateTime();
                //I feel that using Series.Last() right now is a cheap move, but getting it to work is more important
                try
                {
                    ViewStart = DateTime.FromOADate(DataChart.Series[(int)StockFile.STOCKTYPE.OVERVIEW].Points.Last().XValue);
                    ViewEnd = DateTime.FromOADate(DataChart.Series[(int)StockFile.STOCKTYPE.OVERVIEW].Points.First().XValue);
                }
                catch //shouldn't be called, but will prevent that error
                {
                    ViewStart = DateTime.MinValue;
                    ViewEnd = DateTime.MaxValue;
                }

                if (ViewEnd < ViewStart)
                {
                    DateTime temp = ViewStart;
                    ViewStart = ViewEnd;
                    ViewEnd = temp;
                }

                DataChart.Palette = ChartColorPalette.Pastel;
                DataChart.ChartAreas[0].AlignmentStyle = AreaAlignmentStyles.PlotPosition;
                DataChart.MouseClick += new MouseEventHandler(Graph_MouseClick);
                Axis tempAxis = new Axis(DataChart.ChartAreas[0], AxisName.X);
                tempAxis.IntervalType = DateTimeIntervalType.Auto;
                tempAxis.Title = "Date";
                tempAxis.IsStartedFromZero = false;

                DataChart.ChartAreas[0].AxisX = tempAxis;

                tempAxis = new Axis(DataChart.ChartAreas[0], AxisName.Y);
                tempAxis.IsStartedFromZero = false;
                tempAxis.Title = "Value";

                DataChart.ChartAreas[0].AxisY = tempAxis;

                this.Text = Stock.StockName + @" :: Grapher";

                this.Width = (int)(Screen.GetWorkingArea(this.Location).Size.Width * 0.6f);
                this.Height = (int)(Screen.GetWorkingArea(this.Location).Size.Height * 0.6f);

                if (GrapherControl == null)
                    GrapherControl = new GraphControl(this);
                GrapherControl.Owner = this;
                GrapherControl.TopMost = true;
                GrapherControl_Move(); //updates location

                GrapherControl.Show();

                MouseToolTip = new ToolTip();
                //this.Controls.Add(MouseToolTip.);
            }
            catch (Exception Grapher_Load_e)
            {
                MessageBox.Show(Grapher_Load_e.ToString());
            }

            State.Clear();
        }