コード例 #1
1
        /// <summary>
        /// Draw a horizontal line on chart.
        /// </summary>
        /// <param name="sender">Source Chart.</param>
        /// <param name="y">YAxis value.</param>
        /// <param name="lineColor">Line color.</param>
        /// <param name="name">Annotation name.</param>
        /// <param name="lineWidth">Line width</param>
        /// <param name="lineStyle">Line style</param>
        public static void DrawHorizontalLine(this Chart sender, double y,
            Drawing.Color lineColor, string name = "",
            int lineWidth = 1, ChartDashStyle lineStyle = ChartDashStyle.Solid)
        {
            HorizontalLineAnnotation horzLine = new HorizontalLineAnnotation();
            string chartAreaName = sender.ChartAreas[0].Name;
            horzLine.ClipToChartArea = chartAreaName;
            horzLine.AxisXName = chartAreaName + "\\rX";
            horzLine.YAxisName = chartAreaName + "\\rY";
            horzLine.IsInfinitive = true;
            horzLine.IsSizeAlwaysRelative = false;

            horzLine.Y = y;
            horzLine.LineColor = lineColor;
            horzLine.LineWidth = lineWidth;
            horzLine.LineDashStyle = lineStyle;
            sender.Annotations.Add(horzLine);

            if (!string.IsNullOrEmpty(name)) horzLine.Name = name;
        }
コード例 #2
1
ファイル: AnnotationStyles.cs プロジェクト: YiYingChuang/LinQ
        private void Annotation_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            Chart1.Annotations.Clear();

            AnnotationStyle.Items.Clear();
            AnnotationStyle.Enabled = false;

            AnnotationStyle1.Items.Clear();
            AnnotationStyle1.Enabled = false;
            AnnotationStyle2.Items.Clear();
            AnnotationStyle2.Visible = false;

            if(Annotation.SelectedItem.ToString() == "Line")
            {
                LineAnnotation annotation = new LineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Height = -25;
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);

            }
            else if(Annotation.SelectedItem.ToString() == "Vertical Line")
            {
                VerticalLineAnnotation annotation = new VerticalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Height = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);

            }
            else if(Annotation.SelectedItem.ToString() == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = new HorizontalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);
            }
            else if(Annotation.SelectedItem.ToString() == "Polyline")
            {
                PolylineAnnotation annotation = new PolylineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width = 30;

                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 0;
                points[2].Y = 100;

                points[3].X = 100;
                points[3].Y = 100;

                points[4].X = 0;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);

                SetLineControls(false);
            }
            else if(Annotation.SelectedItem.ToString() == "Text")
            {
                TextAnnotation annotation = new TextAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text = "I am a TextAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;

                Chart1.Annotations.Add(annotation);
                SetTextControls();

            }
            else if(Annotation.SelectedItem.ToString() == "Rectangle")
            {
                RectangleAnnotation annotation = new RectangleAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text = "I am a\nRectangleAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);

                SetTextControls();
                SetColorLineControls();
                AnnotationStyle1.SelectedIndex = 2;
            }
            else if(Annotation.SelectedItem.ToString() == "Ellipse")
            {
                EllipseAnnotation annotation = new EllipseAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text = "I am an EllipseAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;
                annotation.LineWidth = 2;
                annotation.Height = 35;
                annotation.Width = 60;

                Chart1.Annotations.Add(annotation);

                SetTextControls();
                SetColorLineControls();
                AnnotationStyle1.SelectedIndex = 2;

            }
            else if(Annotation.SelectedItem.ToString() == "Arrow")
            {
                ArrowAnnotation annotation = new ArrowAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Height = -25;
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);

                SetArrowControls();

            }
            else if(Annotation.SelectedItem.ToString() == "Border3D")
            {
                Border3DAnnotation annotation = new Border3DAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text = "I am a Border3DAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);
                annotation.Height = 40;
                annotation.Width = 50;

                Chart1.Annotations.Add(annotation);

                SetBorder3DControls();

            }
            else if(Annotation.SelectedItem.ToString() == "Callout")
            {
                CalloutAnnotation annotation = new CalloutAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text = "I am a\nCalloutAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 10);;
                annotation.Height = 35;
                annotation.Width = 50;

                Chart1.Annotations.Add(annotation);

                SetCalloutControls();

            }
            else if(Annotation.SelectedItem.ToString() == "Polygon")
            {
                PolygonAnnotation annotation = new PolygonAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width = 30;

                annotation.BackColor = Color.FromArgb(128, Color.Orange);

                // define relative value points for a polygon
                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 100;
                points[2].Y = 100;

                points[3].X = 0;
                points[3].Y = 100;

                points[4].X = 50;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);

                SetColorControl();
                SetColorLineControls();

            }
            else if(Annotation.SelectedItem.ToString() == "Image")
            {
                if(Chart1.Images.IndexOf("MyBmp") < 0)
                {
                    Bitmap Bmp = new Bitmap(200, 75);
                    Graphics g = Graphics.FromImage(Bmp);
                    g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, Bmp.Width, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleGoldenrod), Bmp.Width/2, 0, Bmp.Width/2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleVioletRed), 0, 0, Bmp.Width/2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.DarkOrange)), 0, Bmp.Height/2, Bmp.Width, Bmp.Height/2);
                    g.DrawString("I am an ImageAnnotation", new Font("Arial", 12),
                        new SolidBrush(Color.Black),
                        new Rectangle( 0, 0, Bmp.Width, Bmp.Height));

                    g.Dispose();

                    Chart1.Images.Add(new NamedImage("MyBmp", Bmp));
                }

                ImageAnnotation annotation = new ImageAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Image = "MyBmp";

                Chart1.Annotations.Add(annotation);
                StyleLabel1.Text = "";
                StyleLabel2.Text = "";
            }
        }
コード例 #3
0
ファイル: BaseChartControl.cs プロジェクト: aum-inv/AUM
 protected void createXYLineAnnotation()
 {
     yLines.Clear();
     foreach (ChartArea c in chart.ChartAreas)
     {
         HorizontalLineAnnotation yLine = new HorizontalLineAnnotation();
         yLine.AxisX = c.AxisX;
         yLine.AxisY = c.AxisY2;
         yLine.IsSizeAlwaysRelative = false;
         yLine.AnchorY         = 0;
         yLine.IsInfinitive    = true;
         yLine.ClipToChartArea = c.Name;
         yLine.LineColor       = Color.Gray;
         yLine.LineWidth       = 1;
         chart.Annotations.Add(yLine);
         yLines.Add(yLine);
     }
     yLineLabel.Text        = "";
     yLineLabel.Visible     = false;
     yLineLabel.AutoSize    = true;
     yLineLabel.BackColor   = Color.Gray;
     yLineLabel.ForeColor   = Color.White;
     yLineLabel.BorderStyle = BorderStyle.None;
     yLineLabel.Height      = 15;
     yLineLabel.Font        = new System.Drawing.Font("맑은 고딕", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     chart.Controls.Add(yLineLabel);
 }
コード例 #4
0
        private void StockChart_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (AddTrendline.IsChecked == false)
            {
                return;
            }
            var yCalc      = StockChart.YAxis.GetCurrentCoordinateCalculator();
            var mousePoint = e.GetPosition(StockChart.ModifierSurface as UIElement);
            var yDataValue = yCalc.GetDataValue(mousePoint.Y);
            var annotation = new HorizontalLineAnnotation
            {
                Stroke          = new SolidColorBrush(Colors.Orange),
                StrokeThickness = 1,
                Y1         = yDataValue,
                IsEditable = true
            };

            //annotation.StrokeDashArray = new DoubleCollection { 10, 5 };
            annotation.AnnotationLabels.Add(new AnnotationLabel {
                LabelPlacement = LabelPlacement.Axis, Foreground = Brushes.White
            });
            StockChart.Annotations.Add(annotation);

            var popup = new Popup();

            popup.PopupAnimation = PopupAnimation.Fade;
            popup.Placement      = PlacementMode.Center;
        }
コード例 #5
0
ファイル: SubChartArea.cs プロジェクト: yooce/TradingChart
        /// <summary>
        /// 従ChartAreaを準備します。
        /// </summary>
        /// <param name="chart">チャートコントロール</param>
        public override void SetUp(Chart chart)
        {
            // 分割線
            Splitter             = new HorizontalLineAnnotation();
            Splitter.AllowMoving = true;
            Splitter.LineWidth   = 2;
            Splitter.LineColor   = Palette.SplitterColor;
            Splitter.X           = 0;
            Splitter.Width       = 100;

            // X軸
            AxisX.ScrollBar.Enabled     = false;
            AxisX.MajorTickMark.Enabled = false;
            AxisX.MajorGrid.LineColor   = Palette.GridColor;

            // Y軸
            AxisY2.MajorGrid.LineColor   = Palette.GridColor;
            AxisY2.ScrollBar.Enabled     = false;
            AxisY2.ScrollBar.ButtonStyle = ScrollBarButtonStyles.None;
            AxisY2.Crossing = 0.0;
            AxisY2.LabelAutoFitMaxFontSize = 8;
            AxisY2.LabelAutoFitMinFontSize = 8;

            base.SetUp(chart);
        }
コード例 #6
0
        private void SetAnnotationStyle2()
        {
            if (AnnotationStyle2 == null || AnnotationStyle2.SelectedIndex == -1)
            {
                return;
            }

            if (Annotation.SelectedItem.Value == "Line")
            {
                LineAnnotation annotation = (LineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Vertical Line")
            {
                VerticalLineAnnotation annotation = (VerticalLineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = (HorizontalLineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Polyline")
            {
                PolylineAnnotation annotation = (PolylineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Rectangle")
            {
                RectangleAnnotation annotation = (RectangleAnnotation)Chart1.Annotations[0];

                annotation.LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle2.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Ellipse")
            {
                EllipseAnnotation annotation = (EllipseAnnotation)Chart1.Annotations[0];

                annotation.LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle2.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle2.SelectedItem.Value);
            }
        }
コード例 #7
0
 private void AddAnnotationForChartRevenueDetail()
 {
     an                 = new HorizontalLineAnnotation();
     an.AxisX           = chartRevenueRouteDetail.ChartAreas[0].AxisX;
     an.AxisY           = chartRevenueRouteDetail.ChartAreas[0].AxisY;
     an.ClipToChartArea = chartRevenueRouteDetail.ChartAreas[0].Name;
     an.LineColor       = Color.Red;
     an.LineWidth       = 3;
     an.IsInfinitive    = true;
     chartRevenueRouteDetail.Annotations.Add(an);
 }
        private void AddThresholds()
        {
            chart.Annotations.Clear();
            int classIndex = 1;
            IClassificationProblemData problemData = Content.ProblemData;
            var    classValues = Content.Model.ClassValues.ToArray();
            Axis   y           = chart.ChartAreas[0].AxisY;
            Axis   x           = chart.ChartAreas[0].AxisX;
            string name;

            foreach (double threshold in Content.Model.Thresholds)
            {
                if (!double.IsInfinity(threshold))
                {
                    HorizontalLineAnnotation annotation = new HorizontalLineAnnotation();
                    annotation.AllowMoving     = true;
                    annotation.AllowResizing   = false;
                    annotation.LineWidth       = 2;
                    annotation.LineColor       = Color.Red;
                    annotation.IsInfinitive    = true;
                    annotation.ClipToChartArea = chart.ChartAreas[0].Name;
                    annotation.Tag             = classIndex; //save classIndex as Tag to avoid moving the threshold accross class bounderies
                    annotation.AxisX           = chart.ChartAreas[0].AxisX;
                    annotation.AxisY           = y;
                    annotation.Y = threshold;

                    name = problemData.GetClassName(classValues[classIndex - 1]);
                    TextAnnotation beneathLeft  = CreateTextAnnotation(name, classIndex, x, y, x.Minimum, threshold, ContentAlignment.TopLeft);
                    TextAnnotation beneathRight = CreateTextAnnotation(name, classIndex, x, y, x.Maximum, threshold, ContentAlignment.TopRight);

                    name = problemData.GetClassName(classValues[classIndex]);
                    TextAnnotation aboveLeft  = CreateTextAnnotation(name, classIndex, x, y, x.Minimum, threshold, ContentAlignment.BottomLeft);
                    TextAnnotation aboveRight = CreateTextAnnotation(name, classIndex, x, y, x.Maximum, threshold, ContentAlignment.BottomRight);

                    chart.Annotations.Add(annotation);
                    chart.Annotations.Add(beneathLeft);
                    chart.Annotations.Add(aboveLeft);
                    chart.Annotations.Add(beneathRight);
                    chart.Annotations.Add(aboveRight);

                    beneathLeft.ResizeToContent();
                    beneathRight.ResizeToContent();
                    aboveLeft.ResizeToContent();
                    aboveRight.ResizeToContent();

                    beneathRight.Width = -beneathRight.Width;
                    aboveLeft.Height   = -aboveLeft.Height;
                    aboveRight.Height  = -aboveRight.Height;
                    aboveRight.Width   = -aboveRight.Width;

                    classIndex++;
                }
            }
        }
コード例 #9
0
        public Forecast(string filter, DateTime start_date, DateTime end_date)
        {
            InitializeComponent();
            SfChart chart = new SfChart();

            chart.Title.Text = "Cumulative savings";

            //Initializing primary axis
            CategoryAxis primaryAxis = new CategoryAxis();

            primaryAxis.Title.Text = "Date";
            chart.PrimaryAxis      = primaryAxis;

            //Initializing secondary Axis
            NumericalAxis secondaryAxis = new NumericalAxis();

            secondaryAxis.Title.Text = "Savings";
            chart.SecondaryAxis      = secondaryAxis;

            ViewDates view = new ViewDates(filter, start_date, end_date);



            //Initializing column series
            ColumnSeries series = new ColumnSeries();

            series.ItemsSource  = view.Data;
            series.XBindingPath = "Date";
            series.YBindingPath = "value";
            series.Label        = "Dollars";

            series.DataMarker    = new ChartDataMarker();
            series.EnableTooltip = true;
            chart.Legend         = new ChartLegend();

            chart.Series.Add(series);
            double Y1 = App.Database.GetStashTarget(filter);

            if (Y1 != 0)
            {
                HorizontalLineAnnotation horizontal = new HorizontalLineAnnotation()
                {
                    Y1 = Y1
                };

                chart.SecondaryAxis = new NumericalAxis()
                {
                    Minimum = 10, Maximum = Y1 + 10
                };
                chart.ChartAnnotations.Add(horizontal);
            }
            this.Content = chart;
        }
コード例 #10
0
        private void AnnotationStyle2_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (Annotation.SelectedItem.ToString() == "Line")
            {
                LineAnnotation annotation = (LineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Vertical Line")
            {
                VerticalLineAnnotation annotation = (VerticalLineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = (HorizontalLineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Polyline")
            {
                PolylineAnnotation annotation = (PolylineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Rectangle")
            {
                RectangleAnnotation annotation = (RectangleAnnotation)Chart1.Annotations[0];

                annotation.LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle2.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Ellipse")
            {
                EllipseAnnotation annotation = (EllipseAnnotation)Chart1.Annotations[0];

                annotation.LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle2.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle2.SelectedItem.ToString());
            }
        }
コード例 #11
0
        private ChartStopAlert CreatePopup(HorizontalLineAnnotation annotation, string text)
        {
            var location = annotation.PointToScreen(new Point(0, 0));
            var popup    = new ChartStopAlert(Window, text)
            {
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                //Left = Window.Left + Window.ActualWidth / 2
            };

            popup.Show();
            popup.Top = location.Y;
            return(popup);
        }
コード例 #12
0
ファイル: RealCandleChart.cs プロジェクト: aum-inv/AUM
 private void CreatePriceLineAnnotation(double price)
 {
     hPrice       = new HorizontalLineAnnotation();
     hPrice.AxisX = chart.ChartAreas[0].AxisX;
     hPrice.AxisY = chart.ChartAreas[0].AxisY2;
     hPrice.IsSizeAlwaysRelative = false;
     hPrice.IsInfinitive         = true;
     hPrice.ClipToChartArea      = chart.ChartAreas[0].Name;
     hPrice.LineColor            = Color.Black;
     hPrice.LineWidth            = 1;
     hPrice.Visible = true;
     hPrice.AnchorY = price;
     chart.Annotations.Add(hPrice);
 }
コード例 #13
0
        private void CreateLine()
        {
            _initialBalanceLine = new HorizontalLineAnnotation
            {
                AxisX           = mainChart.ChartAreas[0].AxisX,
                AxisY           = mainChart.ChartAreas[0].AxisY,
                IsInfinitive    = true,
                ClipToChartArea = mainChart.ChartAreas[0].Name,
                LineColor       = Color.WhiteSmoke,
                LineDashStyle   = ChartDashStyle.Dash
            };

            mainChart.Annotations.Add(_initialBalanceLine);
        }
コード例 #14
0
        public void DisplayAvgResistanceAndSupportLine()
        {
            int idx = 1;
            int max = 1;

            foreach (var p in resistanceAvgList)
            {
                HorizontalLineAnnotation yLine = new HorizontalLineAnnotation();
                yLine.AxisX   = chart.ChartAreas[1].AxisX;
                yLine.AxisY   = chart.ChartAreas[1].AxisY2;
                yLine.AnchorY = p;
                yLine.IsSizeAlwaysRelative = false;
                yLine.ToolTip         = p.ToString();
                yLine.IsInfinitive    = true;
                yLine.ClipToChartArea = chart.ChartAreas[1].Name;
                yLine.LineColor       = Color.Red;
                yLine.LineWidth       = 1;
                yLine.Tag             = "RS";
                chart.Annotations.Add(yLine);

                if (idx >= max)
                {
                    break;
                }
                idx++;
            }

            idx = 1;
            foreach (var p in supportAvgList)
            {
                HorizontalLineAnnotation yLine = new HorizontalLineAnnotation();
                yLine.AxisX   = chart.ChartAreas[1].AxisX;
                yLine.AxisY   = chart.ChartAreas[1].AxisY2;
                yLine.AnchorY = p;
                yLine.IsSizeAlwaysRelative = false;
                yLine.ToolTip         = p.ToString();
                yLine.IsInfinitive    = true;
                yLine.ClipToChartArea = chart.ChartAreas[1].Name;
                yLine.LineColor       = Color.Blue;
                yLine.LineWidth       = 1;
                yLine.Tag             = "RS";
                chart.Annotations.Add(yLine);

                if (idx >= max)
                {
                    break;
                }
                idx++;
            }
        }
コード例 #15
0
 private void NewStoporder(string board, string seccode, string id, double price, string buySell)
 {
     if (board != Board && seccode != Seccode)
     {
         return;
     }
     _dispatcher.Invoke(() => {
         var annotation = new HorizontalLineAnnotation
         {
             Name   = "stop" + buySell,
             Stroke = buySell == "B" ?
                      new LinearGradientBrush(Colors.Green, Colors.White, new Point(0, 0), new Point(0.025, 0))
             {
                 SpreadMethod = GradientSpreadMethod.Repeat
             } :
             new LinearGradientBrush(Colors.OrangeRed, Colors.White, new Point(0, 0), new Point(0.025, 0))
             {
                 SpreadMethod = GradientSpreadMethod.Repeat
             },
             StrokeThickness = 2,
             Y1              = price,
             IsEditable      = true,
             StrokeDashArray = new DoubleCollection {
                 10, 5
             },
             Visibility = Visibility.Visible,
             YDragStep  = _dragStep
         };
         annotation.DragStarted += StopDragged;
         annotation.DragEnded   += DeleteStopOnDragOverAsync;
         annotation.AnnotationLabels.Add(new AnnotationLabel
         {
             LabelPlacement = LabelPlacement.Axis,
             Foreground     = Brushes.White,
             Background     = buySell == "B" ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.OrangeRed)
         });
         annotation.AnnotationLabels.Add(new AnnotationLabel
         {
             LabelPlacement = LabelPlacement.TopRight,
             Foreground     = Brushes.White,
             Text           = id,
             Margin         = new Thickness(0, 0, 20, 0)
         });
         if (StockChartAnnotations == null)
         {
             StockChartAnnotations = new AnnotationCollection();
         }
         StockChartAnnotations.Add(annotation);
     });
 }
コード例 #16
0
        private void setLineAnnotation(double value)
        {
            HorizontalLineAnnotation annH = new HorizontalLineAnnotation();

            annH.AxisX = chart.ChartAreas[0].AxisX;
            annH.AxisY = chart.ChartAreas[0].AxisY2;
            annH.IsSizeAlwaysRelative = false;
            annH.AnchorY         = value;
            annH.IsInfinitive    = true;
            annH.ClipToChartArea = chart.ChartAreas[0].Name;
            annH.LineColor       = Color.DarkGray;
            annH.LineWidth       = 1;
            chart.Annotations.Add(annH);
        }
コード例 #17
0
        private void CreateBaseLineAnnotation(double price, Color color)
        {
            HorizontalLineAnnotation hbase = new HorizontalLineAnnotation();

            hbase.AxisX = chart.ChartAreas[0].AxisX;
            hbase.AxisY = chart.ChartAreas[0].AxisY2;
            hbase.IsSizeAlwaysRelative = false;
            hbase.IsInfinitive         = true;
            hbase.ClipToChartArea      = chart.ChartAreas[0].Name;
            hbase.LineColor            = color;
            hbase.LineWidth            = 1;
            hbase.Visible = true;
            hbase.AnchorY = price;
            chart.Annotations.Add(hbase);
        }
コード例 #18
0
ファイル: GraphRenderer.cs プロジェクト: juergenbr/Jansensor
        //Chart
        public bool setupAxisChart(float thresX, float thresY, float thresZ, int lengthXAxis, int intervall_X, Chart chart1, int marking_value)
        {
            X_axis_panel_width_factor = panel_max_width / thresX;
            Y_axis_panel_width_factor = panel_max_width / thresY;
            Z_axis_panel_width_factor = panel_max_width / thresZ;

            ChartArea ca = chart1.ChartAreas[0];

            intervall_X_axis = intervall_X;
            length_X_axis    = lengthXAxis;
            ca.AxisX.Minimum = 0;
            ca.AxisX.Maximum = length_X_axis;
            ca.AxisY.Maximum = Double.NaN;
            ca.AxisY.Minimum = Double.NaN;
            // Set automatic scrolling
            ca.CursorX.AutoScroll       = true;
            ca.AxisX.ScrollBar.Enabled  = true;
            ca.AxisX.MajorGrid.Interval = intervall_X_axis;
            ca.AxisX.Interval           = intervall_X_axis;

            HorizontalLineAnnotation max = new HorizontalLineAnnotation();

            max.AxisY   = ca.AxisY;
            max.AnchorY = marking_value;

            max.IsInfinitive = true;
            max.LineColor    = Color.Red;
            max.LineWidth    = 2;
            chart1.Annotations.Add(max);

            HorizontalLineAnnotation min = new HorizontalLineAnnotation();

            min.AxisY   = ca.AxisY;
            min.AnchorY = 0 - marking_value;

            min.IsInfinitive = true;
            min.LineColor    = Color.Red;
            min.LineWidth    = 2;
            chart1.Annotations.Add(min);

            return(true);
        }
コード例 #19
0
        /// <summary>
        /// Draw trigger level dashed line in scope view.
        /// </summary>
        private void DrawTriggerLevelLine()
        {
            HorizontalLineAnnotation annotation = new HorizontalLineAnnotation
            {
                IsSizeAlwaysRelative = false,
                IsInfinitive         = true,
                ClipToChartArea      = "ChartArea1",
                AxisX         = dataIn.ChartAreas["ChartArea1"].AxisX,
                AxisY         = dataIn.ChartAreas["ChartArea1"].AxisY,
                AnchorY       = _analyzer.TriggerLevel,
                LineWidth     = 1,
                StartCap      = LineAnchorCapStyle.None,
                EndCap        = LineAnchorCapStyle.None,
                LineDashStyle = ChartDashStyle.Dash,
                LineColor     = Color.Green
            };

            dataIn.Annotations.Clear();
            dataIn.Annotations.Add(annotation);
        }
コード例 #20
0
        protected void chartSTOCH_Click(object sender, ImageMapEventArgs e)
        {
            int      chartIndex = System.Convert.ToInt32(e.PostBackValue.Split(',')[0]);
            DateTime xDate      = System.Convert.ToDateTime(e.PostBackValue.Split(',')[1]);
            double   lineWidth  = xDate.ToOADate();

            double lineHeight = System.Convert.ToDouble(e.PostBackValue.Split(',')[2]);

            //double lineHeight = -35;

            if (chartSTOCH.Annotations.Count > 0)
            {
                chartSTOCH.Annotations.Clear();
            }

            HorizontalLineAnnotation HA = new HorizontalLineAnnotation();

            HA.AxisX = chartSTOCH.ChartAreas[chartIndex].AxisX;
            HA.AxisY = chartSTOCH.ChartAreas[chartIndex].AxisY;
            HA.IsSizeAlwaysRelative = false;
            HA.AnchorY         = lineHeight;
            HA.IsInfinitive    = true;
            HA.ClipToChartArea = chartSTOCH.ChartAreas[chartIndex].Name;
            HA.LineDashStyle   = ChartDashStyle.Dash;
            HA.LineColor       = Color.Red;
            HA.LineWidth       = 1;
            chartSTOCH.Annotations.Add(HA);

            VerticalLineAnnotation VA = new VerticalLineAnnotation();

            VA.AxisX = chartSTOCH.ChartAreas[chartIndex].AxisX;
            VA.AxisY = chartSTOCH.ChartAreas[chartIndex].AxisY;
            VA.IsSizeAlwaysRelative = false;
            VA.AnchorX         = lineWidth;
            VA.IsInfinitive    = true;
            VA.ClipToChartArea = chartSTOCH.ChartAreas[chartIndex].Name;
            VA.LineDashStyle   = ChartDashStyle.Dash;
            VA.LineColor       = Color.Red;
            VA.LineWidth       = 1;
            chartSTOCH.Annotations.Add(VA);
        }
コード例 #21
0
ファイル: CandleAntiCandleChart.cs プロジェクト: aum-inv/AUM
        private void setLineAnnotation(int index, Point p)
        {
            double highPoint = 0;
            double lowPoint  = 0;

            highPoint = Math.Round(ChartData[index].QuantumHighPrice, RoundLength);
            lowPoint  = Math.Round(ChartData[index].QuantumLowPrice, RoundLength);

            if (ChartData[index].OpenPrice < ChartData[index].QuantumPrice)
            {
                HorizontalLineAnnotation annH = new HorizontalLineAnnotation();
                annH.AxisX = chart.ChartAreas[0].AxisX;
                annH.AxisY = chart.ChartAreas[0].AxisY2;
                annH.IsSizeAlwaysRelative = false;
                annH.AnchorY         = highPoint;
                annH.IsInfinitive    = true;
                annH.ClipToChartArea = chart.ChartAreas[0].Name;
                annH.LineColor       = lblQPrice.ForeColor = Color.Red;
                annH.LineWidth       = 1;
                chart.Annotations.Add(annH);
                lblQPrice.Text     = highPoint.ToString("N" + RoundLength);
                lblQPrice.Visible  = true;
                lblQPrice.Location = p;
            }
            if (ChartData[index].OpenPrice > ChartData[index].QuantumPrice)
            {
                HorizontalLineAnnotation annL = new HorizontalLineAnnotation();
                annL.AxisX = chart.ChartAreas[0].AxisX;
                annL.AxisY = chart.ChartAreas[0].AxisY2;
                annL.IsSizeAlwaysRelative = false;
                annL.AnchorY         = lowPoint;
                annL.IsInfinitive    = true;
                annL.ClipToChartArea = chart.ChartAreas[0].Name;
                annL.LineColor       = lblQPrice.ForeColor = Color.Blue;
                annL.LineWidth       = 1;
                chart.Annotations.Add(annL);
                lblQPrice.Text     = lowPoint.ToString("N" + RoundLength);
                lblQPrice.Visible  = true;
                lblQPrice.Location = p;
            }
        }
コード例 #22
0
ファイル: bbands.aspx.cs プロジェクト: vinaybhide/Analytics
        protected void drawLine2(string e)
        {
            DateTime xDate     = System.Convert.ToDateTime(e.Split(',')[0]);
            double   lineWidth = xDate.ToOADate();

            double lineHeight = System.Convert.ToDouble(e.Split(',')[1]);

            //double lineHeight = -35;

            if (chartBollingerBands.Annotations.Count > 0)
            {
                chartBollingerBands.Annotations.Clear();
            }

            HorizontalLineAnnotation HA = new HorizontalLineAnnotation();

            HA.AxisX = chartBollingerBands.ChartAreas[0].AxisX;
            HA.AxisY = chartBollingerBands.ChartAreas[0].AxisY;
            HA.IsSizeAlwaysRelative = false;
            HA.AnchorY         = lineHeight;
            HA.IsInfinitive    = true;
            HA.ClipToChartArea = chartBollingerBands.ChartAreas[0].Name;
            HA.LineDashStyle   = ChartDashStyle.Dash;
            HA.LineColor       = Color.Red;
            HA.LineWidth       = 1;
            chartBollingerBands.Annotations.Add(HA);

            VerticalLineAnnotation VA = new VerticalLineAnnotation();

            VA.AxisX = chartBollingerBands.ChartAreas[0].AxisX;
            VA.AxisY = chartBollingerBands.ChartAreas[0].AxisY;
            VA.IsSizeAlwaysRelative = false;
            VA.AnchorX         = lineWidth;
            VA.IsInfinitive    = true;
            VA.ClipToChartArea = chartBollingerBands.ChartAreas[0].Name;
            VA.LineDashStyle   = ChartDashStyle.Dash;
            VA.LineColor       = Color.Red;
            VA.LineWidth       = 1;
            chartBollingerBands.Annotations.Add(VA);
        }
コード例 #23
0
        private void AnnotationStyle1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (Annotation.SelectedItem.ToString() == "Line")
            {
                LineAnnotation annotation = (LineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Vertical Line")
            {
                VerticalLineAnnotation annotation = (VerticalLineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = (HorizontalLineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Polyline")
            {
                PolylineAnnotation annotation = (PolylineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Rectangle")
            {
                RectangleAnnotation annotation = (RectangleAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.ToString()));
            }
            else if (Annotation.SelectedItem.ToString() == "Ellipse")
            {
                EllipseAnnotation annotation = (EllipseAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.ToString()));
            }
            else if (Annotation.SelectedItem.ToString() == "Arrow")
            {
                ArrowAnnotation annotation = (ArrowAnnotation)Chart1.Annotations[0];

                if (AnnotationStyle1.SelectedItem.ToString() != "")
                {
                    annotation.ArrowSize = int.Parse(AnnotationStyle1.SelectedItem.ToString());
                }
            }
            else if (Annotation.SelectedItem.ToString() == "Border3D")
            {
                Border3DAnnotation annotation = (Border3DAnnotation)Chart1.Annotations[0];

                annotation.BorderSkin.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.ToString()));
            }
            else if (Annotation.SelectedItem.ToString() == "Callout")
            {
                CalloutAnnotation annotation = (CalloutAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.ToString()));
            }
            else if (Annotation.SelectedItem.ToString() == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.LineColor = Color.FromName(AnnotationStyle1.SelectedItem.ToString());
            }
        }
コード例 #24
0
        private void Annotation_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            Chart1.Annotations.Clear();

            AnnotationStyle.Items.Clear();
            AnnotationStyle.Enabled = false;

            AnnotationStyle1.Items.Clear();
            AnnotationStyle1.Enabled = false;
            AnnotationStyle2.Items.Clear();
            AnnotationStyle2.Visible = false;

            if (Annotation.SelectedItem.ToString() == "Line")
            {
                LineAnnotation annotation = new LineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Height          = -25;
                annotation.Width           = -25;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);
            }
            else if (Annotation.SelectedItem.ToString() == "Vertical Line")
            {
                VerticalLineAnnotation annotation = new VerticalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Height          = -25;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);
            }
            else if (Annotation.SelectedItem.ToString() == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = new HorizontalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Width           = -25;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);
            }
            else if (Annotation.SelectedItem.ToString() == "Polyline")
            {
                PolylineAnnotation annotation = new PolylineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width  = 30;

                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 0;
                points[2].Y = 100;

                points[3].X = 100;
                points[3].Y = 100;

                points[4].X = 0;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);

                SetLineControls(false);
            }
            else if (Annotation.SelectedItem.ToString() == "Text")
            {
                TextAnnotation annotation = new TextAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am a TextAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 12);;

                Chart1.Annotations.Add(annotation);
                SetTextControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Rectangle")
            {
                RectangleAnnotation annotation = new RectangleAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am a\nRectangleAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 12);;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetTextControls();
                SetColorLineControls();
                AnnotationStyle1.SelectedIndex = 2;
            }
            else if (Annotation.SelectedItem.ToString() == "Ellipse")
            {
                EllipseAnnotation annotation = new EllipseAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am an EllipseAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 12);;
                annotation.LineWidth       = 2;
                annotation.Height          = 35;
                annotation.Width           = 60;

                Chart1.Annotations.Add(annotation);

                SetTextControls();
                SetColorLineControls();
                AnnotationStyle1.SelectedIndex = 2;
            }
            else if (Annotation.SelectedItem.ToString() == "Arrow")
            {
                ArrowAnnotation annotation = new ArrowAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Height          = -25;
                annotation.Width           = -25;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetArrowControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Border3D")
            {
                Border3DAnnotation annotation = new Border3DAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am a Border3DAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 12);
                annotation.Height          = 40;
                annotation.Width           = 50;

                Chart1.Annotations.Add(annotation);

                SetBorder3DControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Callout")
            {
                CalloutAnnotation annotation = new CalloutAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am a\nCalloutAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 10);;
                annotation.Height          = 35;
                annotation.Width           = 50;

                Chart1.Annotations.Add(annotation);

                SetCalloutControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Polygon")
            {
                PolygonAnnotation annotation = new PolygonAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width  = 30;

                annotation.BackColor = Color.FromArgb(128, Color.Orange);

                // define relative value points for a polygon
                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 100;
                points[2].Y = 100;

                points[3].X = 0;
                points[3].Y = 100;

                points[4].X = 50;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);

                SetColorControl();
                SetColorLineControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Image")
            {
                if (Chart1.Images.IndexOf("MyBmp") < 0)
                {
                    Bitmap   Bmp = new Bitmap(200, 75);
                    Graphics g   = Graphics.FromImage(Bmp);
                    g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, Bmp.Width, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleGoldenrod), Bmp.Width / 2, 0, Bmp.Width / 2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleVioletRed), 0, 0, Bmp.Width / 2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.DarkOrange)), 0, Bmp.Height / 2, Bmp.Width, Bmp.Height / 2);
                    g.DrawString("I am an ImageAnnotation", new Font("Arial", 12),
                                 new SolidBrush(Color.Black),
                                 new Rectangle(0, 0, Bmp.Width, Bmp.Height));

                    g.Dispose();

                    Chart1.Images.Add(new NamedImage("MyBmp", Bmp));
                }

                ImageAnnotation annotation = new ImageAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Image           = "MyBmp";

                Chart1.Annotations.Add(annotation);
                StyleLabel1.Text = "";
                StyleLabel2.Text = "";
            }
        }
    private void AddThresholds() {
      chart.Annotations.Clear();
      int classIndex = 1;
      IClassificationProblemData problemData = Content.ProblemData;
      var classValues = Content.Model.ClassValues.ToArray();
      Axis y = chart.ChartAreas[0].AxisY;
      Axis x = chart.ChartAreas[0].AxisX;
      string name;
      foreach (double threshold in Content.Model.Thresholds) {
        if (!double.IsInfinity(threshold)) {
          HorizontalLineAnnotation annotation = new HorizontalLineAnnotation();
          annotation.AllowMoving = true;
          annotation.AllowResizing = false;
          annotation.LineWidth = 2;
          annotation.LineColor = Color.Red;
          annotation.IsInfinitive = true;
          annotation.ClipToChartArea = chart.ChartAreas[0].Name;
          annotation.Tag = classIndex;  //save classIndex as Tag to avoid moving the threshold accross class bounderies
          annotation.AxisX = chart.ChartAreas[0].AxisX;
          annotation.AxisY = y;
          annotation.Y = threshold;

          name = problemData.GetClassName(classValues[classIndex - 1]);
          TextAnnotation beneathLeft = CreateTextAnnotation(name, classIndex, x, y, x.Minimum, threshold, ContentAlignment.TopLeft);
          TextAnnotation beneathRight = CreateTextAnnotation(name, classIndex, x, y, x.Maximum, threshold, ContentAlignment.TopRight);

          name = problemData.GetClassName(classValues[classIndex]);
          TextAnnotation aboveLeft = CreateTextAnnotation(name, classIndex, x, y, x.Minimum, threshold, ContentAlignment.BottomLeft);
          TextAnnotation aboveRight = CreateTextAnnotation(name, classIndex, x, y, x.Maximum, threshold, ContentAlignment.BottomRight);

          chart.Annotations.Add(annotation);
          chart.Annotations.Add(beneathLeft);
          chart.Annotations.Add(aboveLeft);
          chart.Annotations.Add(beneathRight);
          chart.Annotations.Add(aboveRight);

          beneathLeft.ResizeToContent();
          beneathRight.ResizeToContent();
          aboveLeft.ResizeToContent();
          aboveRight.ResizeToContent();

          beneathRight.Width = -beneathRight.Width;
          aboveLeft.Height = -aboveLeft.Height;
          aboveRight.Height = -aboveRight.Height;
          aboveRight.Width = -aboveRight.Width;

          classIndex++;
        }
      }
    }
コード例 #26
0
ファイル: MM_Unit.cs プロジェクト: sylvainr/MacomberMap
        /// <summary>
        /// Draw the unit's MVAR capability curve
        /// </summary>
        /// <param name="g"></param>
        /// <param name="Rect"></param>
        /// <param name="DarkBackground"></param>
        public void DrawUnitMVARCapabilityCurve(Graphics g, Rectangle Rect, bool DarkBackground)
        {
            if (MVARCapabilityCurve.Length == 0)
            {
                g.Clear(DarkBackground ? Color.Black : Color.White);
                return;
            }
            using (Chart NewChart = new Chart()
            {
                Size = Rect.Size
            })
                using (Bitmap DrawBitmap = new Bitmap(Rect.Width, Rect.Height, PixelFormat.Format32bppArgb))
                    try
                    {
                        ChartArea Area = NewChart.ChartAreas.Add("MVAR Capability");
                        NewChart.Titles.Add("MVAR: " + this.ToString());
                        Area.AxisY.Title               = "MVAR";
                        Area.AxisX.Title               = "MW";
                        Area.AxisX.LabelStyle.Format   = "0";
                        Area.AxisX.MajorGrid.LineColor = Area.AxisX.MinorGrid.LineColor = Area.AxisY.MajorGrid.LineColor = Area.AxisY.MinorGrid.LineColor = Color.LightGray;
                        Area.AxisX.MajorGrid.Enabled   = Area.AxisY.MajorGrid.Enabled = false;
                        if (DarkBackground)
                        {
                            Area.BackColor     = Color.Black;
                            NewChart.BackColor = Color.Black;
                            NewChart.ForeColor = Color.White;
                            Area.AxisX.LabelStyle.ForeColor    = Color.White;
                            Area.AxisY.LabelStyle.ForeColor    = Color.White;
                            Area.AxisX.TitleForeColor          = Color.White;
                            Area.AxisX.LineColor               = Color.White;
                            Area.AxisY.TitleForeColor          = Color.White;
                            Area.AxisY.LineColor               = Color.White;
                            NewChart.Titles[0].ForeColor       = Color.White;
                            Area.AxisX.MajorTickMark.LineColor = Color.White;
                            Area.AxisY.MajorTickMark.LineColor = Color.White;
                        }
                        Series MVAR  = NewChart.Series.Add("MVAR Capability Curve");
                        Series MVAR2 = NewChart.Series.Add("MVAR Capability Curve2");
                        MVAR.BorderWidth  = 2;
                        MVAR2.BorderWidth = 2;
                        MVAR.ChartType    = SeriesChartType.Line;
                        MVAR2.ChartType   = SeriesChartType.Line;

                        MVAR.Points.AddXY(0, MVARCapabilityCurve[1]);
                        MVAR2.Points.AddXY(0, MVARCapabilityCurve[2]);
                        for (int a = 0; a < MVARCapabilityCurve.Length; a += 3)
                        {
                            MVAR.Points.AddXY(MVARCapabilityCurve[a], MVARCapabilityCurve[a + 1]);
                            MVAR2.Points.AddXY(MVARCapabilityCurve[a], MVARCapabilityCurve[a + 2]);
                        }
                        Area.AxisX.Minimum = 0;

                        //Add our lines
                        AddVerticalLine(NewChart, LEL, "LEL", Color.Red);
                        AddVerticalLine(NewChart, LSL, "LSL", Color.Yellow);
                        AddVerticalLine(NewChart, LDL, "LDL", Color.Blue);
                        AddVerticalLine(NewChart, LASL, "LASL", Color.Magenta);
                        AddVerticalLine(NewChart, HEL, "HEL", Color.Red);
                        AddVerticalLine(NewChart, HSL, "HSL", Color.Yellow);
                        AddVerticalLine(NewChart, HDL, "HDL", Color.Blue);
                        AddVerticalLine(NewChart, HASL, "HASL", Color.Magenta);
                        AddVerticalLine(NewChart, Estimated_MW, "MW", Color.Green, 2f);
                        AddVerticalLine(NewChart, MaxCapacity, "Max", Color.Red, 2f);

                        HorizontalLineAnnotation hla = new HorizontalLineAnnotation();
                        hla.ClipToChartArea = Area.Name;
                        hla.AxisX           = Area.AxisX;
                        hla.AxisY           = Area.AxisY;
                        hla.IsInfinitive    = true;
                        hla.LineColor       = Color.Green;
                        hla.Y         = Estimated_MVAR;
                        hla.LineWidth = 2;

                        NewChart.Annotations.Add(hla);
                        NewChart.DrawToBitmap(DrawBitmap, Rect);
                        g.DrawImageUnscaled(DrawBitmap, Rect.Location);
                    }
                    catch { }
        }
コード例 #27
0
        public ChartAnnotation()
        {
            SFChart chart = new SFChart();

            chart.AreaBackgroundColor = UIColor.FromRGB(245, 245, 245);
            chart.PrimaryAxis         = new SFNumericalAxis()
            {
                Minimum            = new NSNumber(0),
                Maximum            = new NSNumber(4),
                ShowMajorGridLines = false
            };
            chart.SecondaryAxis = new SFNumericalAxis()
            {
                Minimum            = new NSNumber(20),
                Maximum            = new NSNumber(70),
                ShowMajorGridLines = false,
            };

            VerticalLineAnnotation VerticalLineAnnotation = new VerticalLineAnnotation();

            VerticalLineAnnotation.X1            = 2;
            VerticalLineAnnotation.LineCap       = ChartLineCap.Arrow;
            VerticalLineAnnotation.Text          = "Vertical Line";
            VerticalLineAnnotation.ShowAxisLabel = true;

            HorizontalLineAnnotation horizontalLineAnnotation = new HorizontalLineAnnotation();

            horizontalLineAnnotation.Y1            = 45;
            horizontalLineAnnotation.LineCap       = ChartLineCap.Arrow;
            horizontalLineAnnotation.Text          = "Horizontal Line";
            horizontalLineAnnotation.ShowAxisLabel = true;

            LineAnnotation lineAnnotation = new LineAnnotation();

            lineAnnotation.X1      = 2.5;
            lineAnnotation.X2      = 3.5;
            lineAnnotation.Y1      = 52;
            lineAnnotation.Y2      = 63;
            lineAnnotation.LineCap = ChartLineCap.Arrow;
            lineAnnotation.Text    = "Line";

            RectangleAnnotation rectangleAnnotation = new RectangleAnnotation();

            rectangleAnnotation.Text = "Rectangle";
            rectangleAnnotation.X1   = 0.5;
            rectangleAnnotation.X2   = 1.5;
            rectangleAnnotation.Y1   = 25;
            rectangleAnnotation.Y2   = 35;

            EllipseAnnotation ellipseAnnotation = new EllipseAnnotation();

            ellipseAnnotation.Text = "Ellipse";
            ellipseAnnotation.X1   = 2.5;
            ellipseAnnotation.X2   = 3.5;
            ellipseAnnotation.Y1   = 25;
            ellipseAnnotation.Y2   = 35;

            TextAnnotation textAnnotation = new TextAnnotation();

            textAnnotation.X1   = 1;
            textAnnotation.Y1   = 57.5;
            textAnnotation.Text = "Text Annotation";

            chart.Annotations.Add(VerticalLineAnnotation);
            chart.Annotations.Add(horizontalLineAnnotation);
            chart.Annotations.Add(lineAnnotation);
            chart.Annotations.Add(rectangleAnnotation);
            chart.Annotations.Add(ellipseAnnotation);
            chart.Annotations.Add(textAnnotation);
            this.AddSubview(chart);
        }
コード例 #28
0
        protected void chartAdvGraph_Click(object sender, ImageMapEventArgs e)
        {
            string[] postBackValues;
            DateTime xDate;
            double   lineWidth;
            double   lineHeight;
            string   seriesName;

            try
            {
                if (chartAdvGraph.Annotations.Count > 0)
                {
                    chartAdvGraph.Annotations.Clear();
                }

                postBackValues = e.PostBackValue.Split(',');

                if (postBackValues[0].Equals("AnnotationClicked"))
                {
                    return;
                }

                seriesName = postBackValues[0];

                xDate      = System.Convert.ToDateTime(postBackValues[2]);
                lineWidth  = xDate.ToOADate();
                lineHeight = System.Convert.ToDouble(postBackValues[3]);

                HorizontalLineAnnotation HA = new HorizontalLineAnnotation();
                VerticalLineAnnotation   VA = new VerticalLineAnnotation();
                RectangleAnnotation      ra = new RectangleAnnotation();

                if (seriesName.Equals("Volume"))
                {
                    HA.AxisY = chartAdvGraph.ChartAreas[2].AxisY;
                    VA.AxisY = chartAdvGraph.ChartAreas[2].AxisY;
                    ra.AxisY = chartAdvGraph.ChartAreas[2].AxisY;

                    HA.AxisX = chartAdvGraph.ChartAreas[2].AxisX;
                    VA.AxisX = chartAdvGraph.ChartAreas[2].AxisX;
                    ra.AxisX = chartAdvGraph.ChartAreas[2].AxisX;

                    HA.ClipToChartArea = chartAdvGraph.ChartAreas[2].Name;
                }
                else if (seriesName.Equals("PctChange"))
                {
                    HA.AxisY = chartAdvGraph.ChartAreas[0].AxisY;
                    VA.AxisY = chartAdvGraph.ChartAreas[0].AxisY;
                    ra.AxisY = chartAdvGraph.ChartAreas[0].AxisY;

                    HA.AxisX = chartAdvGraph.ChartAreas[0].AxisX2;
                    VA.AxisX = chartAdvGraph.ChartAreas[0].AxisX2;
                    ra.AxisX = chartAdvGraph.ChartAreas[0].AxisX2;

                    HA.ClipToChartArea = chartAdvGraph.ChartAreas[0].Name;
                }
                else
                {
                    HA.AxisY = chartAdvGraph.ChartAreas[1].AxisY;
                    VA.AxisY = chartAdvGraph.ChartAreas[1].AxisY;
                    ra.AxisY = chartAdvGraph.ChartAreas[1].AxisY;

                    HA.AxisX           = chartAdvGraph.ChartAreas[1].AxisX2;
                    VA.AxisX           = chartAdvGraph.ChartAreas[1].AxisX2;
                    ra.AxisX           = chartAdvGraph.ChartAreas[1].AxisX2;
                    HA.ClipToChartArea = chartAdvGraph.ChartAreas[1].Name;
                }

                HA.IsSizeAlwaysRelative = false;
                HA.AnchorY       = lineHeight;
                HA.IsInfinitive  = true;
                HA.LineDashStyle = ChartDashStyle.Dash;
                HA.LineColor     = Color.Red;
                HA.LineWidth     = 1;
                HA.ToolTip       = postBackValues[3];
                chartAdvGraph.Annotations.Add(HA);

                VA.IsSizeAlwaysRelative = false;
                VA.AnchorX       = lineWidth;
                VA.IsInfinitive  = true;
                VA.LineDashStyle = ChartDashStyle.Dash;
                VA.LineColor     = Color.Red;
                VA.LineWidth     = 1;
                VA.ToolTip       = postBackValues[2];
                chartAdvGraph.Annotations.Add(VA);

                ra.Name = seriesName;
                ra.IsSizeAlwaysRelative = true;
                ra.AnchorX       = lineWidth;
                ra.AnchorY       = lineHeight;
                ra.IsMultiline   = true;
                ra.LineDashStyle = ChartDashStyle.Solid;
                ra.LineColor     = Color.Blue;
                ra.LineWidth     = 1;
                ra.PostBackValue = "AnnotationClicked";

                if (seriesName.Equals("OHLC"))
                {   //high,low,open,close
                    //"OHLC," + symbol + "," + "#VALX,#VALY1,#VALY2,#VALY3,#VALY4";
                    ra.Text = postBackValues[1] + "\n" + "Date:" + postBackValues[2] + "\n" + "High:" + postBackValues[3] + "\n" +
                              "Low:" + postBackValues[4] + "\n" + "Open:" + postBackValues[5] + "\n" + "Close:" + postBackValues[6];
                }
                else if (seriesName.Equals("PctChange"))
                {
                    ra.Text = postBackValues[1] + "\n" + "Date:" + postBackValues[2] + "\n" + "Prev Close:" + postBackValues[5] + "\n" + "Change %:" + postBackValues[3] + "\n" +
                              "Change:" + postBackValues[4];
                }
                else if (seriesName.Equals("Portfolio"))
                {
                    ra.Text = postBackValues[1] + "\nPurchase Date:" + postBackValues[4] + "\nPurchase Price:" + postBackValues[5] + "\nPurchased Units: " + postBackValues[6] +
                              "\nPurchase Cost: " + postBackValues[7] + "\nCumulative Units: " + postBackValues[8] + "\nCumulative Cost: " + postBackValues[9] +
                              "\nValue as of date: " + postBackValues[10];
                    HA.ToolTip = "Close Price: " + postBackValues[3];
                    VA.ToolTip = postBackValues[2];
                }
                else
                {
                    //0-Volume, 1-Date, 2-Volume/Open/High/Low/Close
                    ra.Text = postBackValues[1] + "\n" + "Date:" + postBackValues[2] + "\n" + seriesName + ":" + postBackValues[3];
                }

                chartAdvGraph.Annotations.Add(ra);
            }
            catch (Exception ex)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('Exception while plotting lines:" + ex.Message + "');", true);
            }
        }
コード例 #29
0
        public override View GetSampleContent(Context context)
        {
            chart = new SfChart(context);
            chart.SetBackgroundColor(Color.White);
            chart.AreaBackgroundColor = Color.Rgb(245, 245, 245);

            NumericalAxis categoryaxis = new NumericalAxis();

            categoryaxis.ShowMajorGridLines    = false;
            categoryaxis.Minimum               = 0;
            categoryaxis.Maximum               = 4;
            categoryaxis.LineStyle.StrokeColor = Color.White;
            chart.PrimaryAxis = categoryaxis;

            NumericalAxis numericalaxis = new NumericalAxis();

            numericalaxis.ShowMajorGridLines    = false;
            numericalaxis.Minimum               = 20;
            numericalaxis.Maximum               = 70;
            numericalaxis.LineStyle.StrokeColor = Color.White;
            chart.SecondaryAxis = numericalaxis;

            LineAnnotation lineAnnotation = new LineAnnotation();

            lineAnnotation.Text = "Line";
            lineAnnotation.X1   = 2.5;
            lineAnnotation.X2   = 3.5;
            lineAnnotation.Y1   = 52;
            lineAnnotation.Y2   = 63;
            lineAnnotation.LabelStyle.MarginTop    = 5;
            lineAnnotation.LabelStyle.MarginRight  = 5;
            lineAnnotation.LabelStyle.MarginLeft   = 5;
            lineAnnotation.LabelStyle.MarginBottom = 5;
            lineAnnotation.LineCap = ChartLineCap.Arrow;

            HorizontalLineAnnotation horizontalAnnotation = new HorizontalLineAnnotation();

            horizontalAnnotation.Y1            = 45;
            horizontalAnnotation.Text          = "Horizontal Line";
            horizontalAnnotation.LineCap       = ChartLineCap.Arrow;
            horizontalAnnotation.ShowAxisLabel = true;

            VerticalLineAnnotation verticalAnnotation = new VerticalLineAnnotation();

            verticalAnnotation.X1            = 2;
            verticalAnnotation.Text          = "Vertical Line";
            verticalAnnotation.LineCap       = ChartLineCap.Arrow;
            verticalAnnotation.ShowAxisLabel = true;

            RectangleAnnotation RectAnnotation = new RectangleAnnotation();

            RectAnnotation.X1   = 0.5;
            RectAnnotation.X2   = 1.5;
            RectAnnotation.Y1   = 25;
            RectAnnotation.Y2   = 35;
            RectAnnotation.Text = "Rectangle";

            EllipseAnnotation eleAnnotation = new EllipseAnnotation();

            eleAnnotation.X1   = 2.5;
            eleAnnotation.X2   = 3.5;
            eleAnnotation.Y1   = 25;
            eleAnnotation.Y2   = 35;
            eleAnnotation.Text = "Ellipse";

            TextAnnotation textAnnotation = new TextAnnotation();

            textAnnotation.X1   = 1;
            textAnnotation.Y1   = 57.5;
            textAnnotation.Text = "Text Annotation";

            chart.Annotations.Add(textAnnotation);
            chart.Annotations.Add(eleAnnotation);
            chart.Annotations.Add(RectAnnotation);
            chart.Annotations.Add(verticalAnnotation);
            chart.Annotations.Add(horizontalAnnotation);
            chart.Annotations.Add(lineAnnotation);
            return(chart);
        }
コード例 #30
0
ファイル: bbands.aspx.cs プロジェクト: vinaybhide/Analytics
        public void drawLine(string eventargs)
        {
            string[] sargs = eventargs.Split(',');

            double lineWidthClient = System.Convert.ToDouble(sargs[0]);

            double lineHeightClient = System.Convert.ToDouble(sargs[1]);
            double lineWidthScreen  = System.Convert.ToDouble(sargs[2]);

            double lineHeightScreen = System.Convert.ToDouble(sargs[3]);

            //double lineHeight = -35;

            if (chartBollingerBands.Annotations.Count > 0)
            {
                chartBollingerBands.Annotations.Clear();
            }

            HorizontalLineAnnotation HA = new HorizontalLineAnnotation();

            HA.AxisX = chartBollingerBands.ChartAreas[0].AxisX;
            HA.AxisY = chartBollingerBands.ChartAreas[0].AxisY;
            HA.IsSizeAlwaysRelative = false;
            HA.AnchorY         = lineHeightClient;
            HA.IsInfinitive    = true;
            HA.ClipToChartArea = chartBollingerBands.ChartAreas[0].Name;
            HA.LineDashStyle   = ChartDashStyle.Dash;
            HA.LineColor       = Color.Red;
            HA.LineWidth       = 1;
            chartBollingerBands.Annotations.Add(HA);

            VerticalLineAnnotation VA = new VerticalLineAnnotation();

            VA.AxisX = chartBollingerBands.ChartAreas[0].AxisX;
            VA.AxisY = chartBollingerBands.ChartAreas[0].AxisY;
            VA.IsSizeAlwaysRelative = false;
            VA.AnchorX         = lineWidthClient;
            VA.IsInfinitive    = true;
            VA.ClipToChartArea = chartBollingerBands.ChartAreas[0].Name;
            VA.LineDashStyle   = ChartDashStyle.Dash;
            VA.LineColor       = Color.Red;
            VA.LineWidth       = 1;
            chartBollingerBands.Annotations.Add(VA);

            HorizontalLineAnnotation HA2 = new HorizontalLineAnnotation();

            HA2.AxisX = chartBollingerBands.ChartAreas[0].AxisX;
            HA2.AxisY = chartBollingerBands.ChartAreas[0].AxisY;
            HA2.IsSizeAlwaysRelative = false;
            HA2.AnchorY         = lineHeightScreen;
            HA2.IsInfinitive    = true;
            HA2.ClipToChartArea = chartBollingerBands.ChartAreas[0].Name;
            HA2.LineDashStyle   = ChartDashStyle.Dash;
            HA2.LineColor       = Color.Blue;
            HA2.LineWidth       = 1;
            chartBollingerBands.Annotations.Add(HA2);

            VerticalLineAnnotation VA2 = new VerticalLineAnnotation();

            VA2.AxisX = chartBollingerBands.ChartAreas[0].AxisX;
            VA2.AxisY = chartBollingerBands.ChartAreas[0].AxisY;
            VA2.IsSizeAlwaysRelative = false;
            VA2.AnchorX         = lineWidthScreen;
            VA2.IsInfinitive    = true;
            VA2.ClipToChartArea = chartBollingerBands.ChartAreas[0].Name;
            VA2.LineDashStyle   = ChartDashStyle.Dash;
            VA2.LineColor       = Color.Blue;
            VA2.LineWidth       = 1;
            chartBollingerBands.Annotations.Add(VA2);
        }
コード例 #31
0
        private void SetAnnotationStyle1()
        {
            if (AnnotationStyle1 == null || AnnotationStyle1.SelectedIndex == -1)
            {
                return;
            }

            if (Annotation.SelectedItem.Value == "Line")
            {
                LineAnnotation annotation = (LineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Vertical Line")
            {
                VerticalLineAnnotation annotation = (VerticalLineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = (HorizontalLineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Polyline")
            {
                PolylineAnnotation annotation = (PolylineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Rectangle")
            {
                RectangleAnnotation annotation = (RectangleAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.Value));
            }
            else if (Annotation.SelectedItem.Value == "Ellipse")
            {
                EllipseAnnotation annotation = (EllipseAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.Value));
            }
            else if (Annotation.SelectedItem.Value == "Arrow")
            {
                ArrowAnnotation annotation = (ArrowAnnotation)Chart1.Annotations[0];

                if (AnnotationStyle1.SelectedItem.Value != "")
                {
                    annotation.ArrowSize = int.Parse(AnnotationStyle1.SelectedItem.Value);
                }
            }
            else if (Annotation.SelectedItem.Value == "Border3D")
            {
                Border3DAnnotation annotation = (Border3DAnnotation)Chart1.Annotations[0];

                annotation.BorderSkin.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.Value));
            }
            else if (Annotation.SelectedItem.Value == "Callout")
            {
                CalloutAnnotation annotation = (CalloutAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.Value));
            }
            else if (Annotation.SelectedItem.Value == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.LineColor = Color.FromName(AnnotationStyle1.SelectedItem.Value);
            }
        }
コード例 #32
0
        protected void chartMF_Click(object sender, ImageMapEventArgs e)
        {
            string[] postBackValues;
            DateTime xDate;
            double   lineWidth;
            double   lineHeight;
            string   seriesName;

            try
            {
                if (chartMF.Annotations.Count > 0)
                {
                    chartMF.Annotations.Clear();
                }

                postBackValues = e.PostBackValue.Split(',');

                if (postBackValues[0].Equals("AnnotationClicked"))
                {
                    return;
                }

                seriesName = postBackValues[0];

                xDate      = System.Convert.ToDateTime(postBackValues[2]);
                lineWidth  = xDate.ToOADate();
                lineHeight = System.Convert.ToDouble(postBackValues[3]);


                HorizontalLineAnnotation HA = new HorizontalLineAnnotation();
                VerticalLineAnnotation   VA = new VerticalLineAnnotation();
                RectangleAnnotation      ra = new RectangleAnnotation();

                if (seriesName.Equals("DAILY_NAV") || seriesName.Equals("SMA Fast") || seriesName.Equals("SMA Slow") || seriesName.Equals("EMA Fast") ||
                    seriesName.Equals("EMA Slow") ||
                    seriesName.Equals("WMA Fast") || seriesName.Equals("WMA Slow") || seriesName.Equals("Upper Band") || seriesName.Equals("Middle Band") ||
                    seriesName.Equals("Lower Band"))
                {
                    HA.AxisY = chartMF.ChartAreas[0].AxisY;
                    VA.AxisY = chartMF.ChartAreas[0].AxisY;
                    ra.AxisY = chartMF.ChartAreas[0].AxisY;

                    HA.AxisX = chartMF.ChartAreas[0].AxisX2;
                    VA.AxisX = chartMF.ChartAreas[0].AxisX2;
                    ra.AxisX = chartMF.ChartAreas[0].AxisX2;

                    HA.ClipToChartArea = chartMF.ChartAreas[0].Name;
                }
                else if (seriesName.Equals("RSI"))
                {
                    HA.AxisY = chartMF.ChartAreas[1].AxisY;
                    VA.AxisY = chartMF.ChartAreas[1].AxisY;
                    ra.AxisY = chartMF.ChartAreas[1].AxisY;

                    HA.AxisX = chartMF.ChartAreas[1].AxisX;
                    VA.AxisX = chartMF.ChartAreas[1].AxisX;
                    ra.AxisX = chartMF.ChartAreas[1].AxisX;

                    HA.ClipToChartArea = chartMF.ChartAreas[1].Name;
                }
                else if (seriesName.Equals("MACD") || seriesName.Equals("Histogram") || seriesName.Equals("Signal"))
                {
                    HA.AxisY = chartMF.ChartAreas[2].AxisY;
                    VA.AxisY = chartMF.ChartAreas[2].AxisY;
                    ra.AxisY = chartMF.ChartAreas[2].AxisY;

                    HA.AxisX = chartMF.ChartAreas[2].AxisX;
                    VA.AxisX = chartMF.ChartAreas[2].AxisX;
                    ra.AxisX = chartMF.ChartAreas[2].AxisX;

                    HA.ClipToChartArea = chartMF.ChartAreas[2].Name;
                }

                HA.IsSizeAlwaysRelative = false;
                HA.AnchorY       = lineHeight;
                HA.IsInfinitive  = true;
                HA.LineDashStyle = ChartDashStyle.Dash;
                HA.LineColor     = Color.Red;
                HA.LineWidth     = 1;
                HA.ToolTip       = postBackValues[3];
                chartMF.Annotations.Add(HA);

                //VA.Name = seriesName;
                VA.IsSizeAlwaysRelative = false;
                VA.AnchorX       = lineWidth;
                VA.IsInfinitive  = true;
                VA.LineDashStyle = ChartDashStyle.Dash;
                VA.LineColor     = Color.Red;
                VA.LineWidth     = 1;
                VA.ToolTip       = postBackValues[2];
                chartMF.Annotations.Add(VA);

                ra.Name = seriesName;
                ra.IsSizeAlwaysRelative = true;
                ra.AnchorX     = lineWidth;
                ra.AnchorY     = lineHeight;
                ra.IsMultiline = true;
                //ra.ClipToChartArea = chartADX.ChartAreas[0].Name;
                ra.LineDashStyle = ChartDashStyle.Solid;
                ra.LineColor     = Color.Blue;
                ra.LineWidth     = 1;
                ra.PostBackValue = "AnnotationClicked";
                //ra.SmartLabelStyle = sl;
                ra.Text = postBackValues[1] + "\n" + "Date:" + postBackValues[2] + "\n" + seriesName + ":" + postBackValues[3];

                chartMF.Annotations.Add(ra);
            }
            catch (Exception ex)
            {
                //Response.Write("<script language=javascript>alert('Exception while ploting lines: " + ex.Message + "')</script>");
                Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('Exception while plotting lines:" + ex.Message + "');", true);
            }
        }
コード例 #33
0
        protected void chartAdvGraph_Click(object sender, ImageMapEventArgs e)
        {
            string[] postBackValues;

            DateTime xDate;
            double   lineWidth;
            double   lineHeight;
            string   seriesName;
            //string legendName;
            int chartIndex;

            //DataPoint p;
            //double lineHeight = -35;

            try
            {
                postBackValues = e.PostBackValue.Split(',');

                if (chartAdvGraph.Annotations.Count > 0)
                {
                    chartAdvGraph.Annotations.Clear();
                }

                if (postBackValues[0].Equals("AnnotationClicked"))
                {
                    return;
                }

                xDate      = System.Convert.ToDateTime(postBackValues[2]);
                lineWidth  = xDate.ToOADate();
                lineHeight = System.Convert.ToDouble(postBackValues[3]);

                seriesName = postBackValues[0];


                HorizontalLineAnnotation HA = new HorizontalLineAnnotation();
                //HA.Name = seriesName;
                VerticalLineAnnotation VA = new VerticalLineAnnotation();
                RectangleAnnotation    ra = new RectangleAnnotation();
                if (seriesName.Equals("Volume"))
                {
                    HA.AxisX = chartAdvGraph.ChartAreas[2].AxisX;
                    HA.AxisY = chartAdvGraph.ChartAreas[2].AxisY;

                    VA.AxisX = chartAdvGraph.ChartAreas[2].AxisX;
                    VA.AxisY = chartAdvGraph.ChartAreas[2].AxisY;

                    ra.AxisX   = chartAdvGraph.ChartAreas[2].AxisX;
                    ra.AxisY   = chartAdvGraph.ChartAreas[2].AxisY;
                    chartIndex = 2;
                }
                else if (seriesName.Contains("AROON"))
                {
                    HA.AxisX = chartAdvGraph.ChartAreas[1].AxisX2;
                    HA.AxisY = chartAdvGraph.ChartAreas[1].AxisY;

                    VA.AxisX = chartAdvGraph.ChartAreas[1].AxisX2;
                    VA.AxisY = chartAdvGraph.ChartAreas[1].AxisY;

                    ra.AxisX   = chartAdvGraph.ChartAreas[1].AxisX2;
                    ra.AxisY   = chartAdvGraph.ChartAreas[1].AxisY;
                    chartIndex = 1;
                }
                else
                {
                    HA.AxisX = chartAdvGraph.ChartAreas[0].AxisX2;
                    HA.AxisY = chartAdvGraph.ChartAreas[0].AxisY;

                    VA.AxisX = chartAdvGraph.ChartAreas[0].AxisX2;
                    VA.AxisY = chartAdvGraph.ChartAreas[0].AxisY;

                    ra.AxisX   = chartAdvGraph.ChartAreas[0].AxisX2;
                    ra.AxisY   = chartAdvGraph.ChartAreas[0].AxisY;
                    chartIndex = 0;
                }

                HA.IsSizeAlwaysRelative = false;
                HA.AnchorY         = lineHeight;
                HA.IsInfinitive    = true;
                HA.ClipToChartArea = chartAdvGraph.ChartAreas[chartIndex].Name;
                HA.LineDashStyle   = ChartDashStyle.Dash;
                HA.LineColor       = Color.Red;
                HA.LineWidth       = 1;
                HA.ToolTip         = postBackValues[3];
                chartAdvGraph.Annotations.Add(HA);

                //VA.Name = seriesName;
                VA.IsSizeAlwaysRelative = false;
                VA.AnchorX      = lineWidth;
                VA.IsInfinitive = true;
                //VA.ClipToChartArea = chartAdvGraph.ChartAreas[chartIndex].Name;
                VA.LineDashStyle = ChartDashStyle.Dash;
                VA.LineColor     = Color.Red;
                VA.LineWidth     = 1;
                VA.ToolTip       = postBackValues[2];
                chartAdvGraph.Annotations.Add(VA);

                ra.Name = seriesName;
                ra.IsSizeAlwaysRelative = true;
                ra.AnchorX     = lineWidth;
                ra.AnchorY     = lineHeight;
                ra.IsMultiline = true;
                //ra.ClipToChartArea = chartADX.ChartAreas[0].Name;
                ra.LineDashStyle = ChartDashStyle.Solid;
                ra.LineColor     = Color.Blue;
                ra.LineWidth     = 1;
                ra.PostBackValue = "AnnotationClicked";

                if (seriesName.Equals("OHLC"))
                {
                    //0-OHLC,1-Date,2-High,3-Low,4-Open,5-Close
                    ra.Text = postBackValues[1] + "\n" + "Date:" + postBackValues[2] + "\n" + "Open:" + postBackValues[5] + "\n" + "High:" + postBackValues[3] + "\n" +
                              "Low:" + postBackValues[4] + "\n" + "Close:" + postBackValues[6];
                }
                else if (seriesName.Equals("Portfolio"))
                {
                    ra.Text = postBackValues[1] + "\nPurchase Date:" + postBackValues[4] + "\nPurchase Price:" + postBackValues[5] + "\nPurchased Units: " + postBackValues[6] +
                              "\nPurchase Cost: " + postBackValues[7] + "\nCumulative Units: " + postBackValues[8] + "\nCumulative Cost: " + postBackValues[9] +
                              "\nValue as of date: " + postBackValues[10];

                    HA.ToolTip = "Close Price: " + postBackValues[3];
                    VA.ToolTip = postBackValues[2];
                }
                else if (seriesName.Equals("^BSESN") || seriesName.Equals("^NSEI"))
                {
                    ra.Text = seriesName + "\n" + "Date:" + postBackValues[2] + "\n" + "Close:" + postBackValues[3] + "\n" + "Open:" + postBackValues[4] + "\n" +
                              "High:" + postBackValues[5] + "\n" + "Low:" + postBackValues[6];
                }
                else
                {
                    ra.Text = "Date:" + postBackValues[2] + "\n" + seriesName + ":" + postBackValues[3];
                }
                //ra.SmartLabelStyle = sl;

                chartAdvGraph.Annotations.Add(ra);
            }
            catch (Exception ex)
            {
                //Response.Write("<script language=javascript>alert('Exception while ploting lines: " + ex.Message + "')</script>");
                Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('" + ex.Message + "');", true);
            }
        }