private void AddLineAnnotation()
        {
            // create a line annotation
            LineAnnotation annotation = new LineAnnotation();

            // setup visual attributes
            annotation.StartCap        = LineAnchorCapStyle.Arrow;
            annotation.EndCap          = LineAnchorCapStyle.Arrow;
            annotation.LineWidth       = 3;
            annotation.LineColor       = Color.OrangeRed;
            annotation.ShadowOffset    = 2;
            annotation.ClipToChartArea = "Default";

            // prevent moving or selecting
            annotation.AllowMoving       = false;
            annotation.AllowAnchorMoving = false;
            annotation.AllowSelecting    = false;

            if (Chart1.Series[0].Points.Count > 10)
            {
                // Use the Anchor Method to anchor to points 8 and 10...
                annotation.SetAnchor(Chart1.Series[0].Points[8], Chart1.Series[0].Points[10]);
            }


            // add the annotation to the collection
            Chart1.Annotations.Add(annotation);
        }
Beispiel #2
0
        /// <summary>
        /// AddLineAnnotation
        /// </summary>
        /// <param name="series"></param>
        /// <param name="index"></param>
        private void AddLineAnnotation(string series, int firstPoint, int secondPoint, Func <Color> coloring)
        {
            LineAnnotation annotation = new LineAnnotation();

            annotation.SetAnchor(chartStrategy.Series[series].Points[firstPoint], chartStrategy.Series[series].Points[secondPoint]);
            annotation.Height    = 1;
            annotation.Width     = 1;
            annotation.LineWidth = 1;
            annotation.StartCap  = LineAnchorCapStyle.Round;
            annotation.EndCap    = LineAnchorCapStyle.Round;
            annotation.LineColor = coloring();
            chartStrategy.Annotations.Add(annotation);
        }
Beispiel #3
0
        public void AddEntryToChart(ChartArea area, Series series, AnnotationCollection annotations, double y = 0)
        {
            if (Date == null)
            {
                throw new Exception();
            }

            var p1 = new DataPoint(Date.Value.AddDays(-1).ToOADate(), y);
            var p2 = new DataPoint(GetEndDate.ToOADate(), y);

            series.Points.Add(p1);
            series.Points.Add(p2);

            var line = new LineAnnotation
            {
                LineWidth       = 10,
                Height          = 0,
                LineColor       = DrawColor ?? Color.Red,
                ClipToChartArea = area.Name,
            };

            line.SetAnchor(p1, p2);

            var callout = new CalloutAnnotation
            {
                Text            = Note ?? "ERROR: NOT SET",
                AnchorDataPoint = p1,
                CalloutStyle    = CalloutStyle.RoundedRectangle,
                ForeColor       = DrawColor ?? Color.Red,
                LineColor       = DrawColor ?? Color.Red,
                //BackColor = Color.Transparent,
                Font            = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold),
                SmartLabelStyle = { IsMarkerOverlappingAllowed = true, AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Yes, MaxMovingDistance = 100, IsOverlappedHidden = false, MovingDirection = LabelAlignmentStyles.Bottom | LabelAlignmentStyles.BottomLeft | LabelAlignmentStyles.BottomRight },
                AnchorAlignment = ContentAlignment.TopCenter,
                ToolTip         = (Note ?? "ERROR: NOT SET") + "\n(" + Date.Value.ToShortDateString() + " - " + GetEndDate.ToShortDateString() + ")",
                Alignment       = ContentAlignment.MiddleCenter
            };

            annotations.Add(line);
            annotations.Add(callout);
        }