Exemplo n.º 1
0
        public static PlotModel LineAnnotation()
        {
            var model = new PlotModel {
                Title = "LineAnnotation", Subtitle = "Click and drag the annotation line."
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = -20, Maximum = 80
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = -10, Maximum = 10
            });
            var la = new LineAnnotation {
                Type = LineAnnotationType.Vertical, X = 4
            };

            la.MouseDown += (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }

                la.StrokeThickness *= 5;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            // Handle mouse movements (note: this is only called when the mousedown event was handled)
            la.MouseMove += (s, e) =>
            {
                la.X = la.InverseTransform(e.Position).X;
                model.InvalidatePlot(false);
                e.Handled = true;
            };
            la.MouseUp += (s, e) =>
            {
                la.StrokeThickness /= 5;
                model.InvalidatePlot(false);
                e.Handled = true;
            };
            model.Annotations.Add(la);
            return(model);
        }
Exemplo n.º 2
0
        private void AddGapAnnotations(DataTable dt)
        {
            DateTime lastBucket   = DateTime.MinValue;
            int      bucketNumber = 0;

            foreach (DataRow dr in dt.Rows)
            {
                DateTime currentBucket = new DateTime((int)dr["Year"], (int)dr["Month"], 1);
                var      diff          = currentBucket.Subtract(lastBucket);

                bucketNumber++;

                if (lastBucket != DateTime.MinValue && diff.TotalDays > 31)
                {
                    //add gap annotation
                    var line = new LineAnnotation();
                    line.IsSizeAlwaysRelative = false;
                    line.AxisX         = chart1.ChartAreas[0].AxisX;
                    line.AxisY         = chart1.ChartAreas[0].AxisY;
                    line.AnchorX       = bucketNumber;
                    line.AnchorY       = 0;
                    line.IsInfinitive  = true;
                    line.LineWidth     = 1;
                    line.LineDashStyle = ChartDashStyle.Dot;
                    line.Width         = 0;
                    line.LineWidth     = 2;
                    line.StartCap      = LineAnchorCapStyle.None;
                    line.EndCap        = LineAnchorCapStyle.None;

                    var text = new TextAnnotation();
                    text.Text = diff.TotalDays + "d gap";
                    text.IsSizeAlwaysRelative = false;
                    text.AxisX   = chart1.ChartAreas[0].AxisX;
                    text.AxisY   = chart1.ChartAreas[0].AxisY;
                    text.AnchorX = bucketNumber;
                    text.AnchorY = 0;

                    chart1.Annotations.Add(line);
                    chart1.Annotations.Add(text);
                }

                lastBucket = new DateTime((int)dr["Year"], (int)dr["Month"], 1);
            }
        }
Exemplo n.º 3
0
        private static void AddLineAnnotations(
            List <DatePrice> prices, IDataSeries series, AnnotationCollection annotations, Color colour)
        {
            int?     startIndex   = null;
            DateTime?startDate    = null;
            decimal? currentPrice = null;

            foreach (var p in prices)
            {
                if (p.Price != currentPrice)
                {
                    // Price changed
                    if (currentPrice != null && startIndex != null)
                    {
                        var endIndex = series.FindIndex(p.Date.ToLocalTime(), SearchMode.Nearest);

                        if (endIndex == startIndex.Value)
                        {
                            endIndex++;
                        }

                        var brush = new SolidColorBrush(colour)
                        {
                            Opacity = 0.3
                        };
                        var annotation = new LineAnnotation
                        {
                            X1     = startDate,            //startIndex.Value,
                            X2     = p.Date.ToLocalTime(), //endIndex,
                            Y1     = currentPrice.Value,
                            Y2     = currentPrice.Value,
                            Stroke = brush
                        };

                        annotations.Add(annotation);
                    }

                    startIndex   = series.FindIndex(p.Date.ToLocalTime(), SearchMode.Nearest);
                    startDate    = p.Date.ToLocalTime();
                    currentPrice = p.Price;
                }
            }
        }
Exemplo n.º 4
0
        public static void AddHorizontalLine(decimal price, DateTime start, DateTime end, IDataSeries dataSeries,
                                             AnnotationCollection annotations, Trade trade, Color colour, bool extendLeftAndRight = false,
                                             bool extendRightIfZeroLength = false, DoubleCollection strokeDashArray = null)
        {
            var dateStartIndex = dataSeries.FindIndex(start, SearchMode.RoundDown);
            var dateEndIndex   = dataSeries.FindIndex(end, SearchMode.RoundUp);

            if (extendLeftAndRight)
            {
                dateStartIndex -= 4;
            }
            if (dateStartIndex < 0)
            {
                dateStartIndex = 0;
            }
            if (extendLeftAndRight)
            {
                dateEndIndex += 4;
            }

            if (extendRightIfZeroLength && dateStartIndex == dateEndIndex)
            {
                dateEndIndex++;
            }

            var lineAnnotation = new LineAnnotation
            {
                DataContext     = trade,
                X1              = dateStartIndex,
                Y1              = price,
                X2              = dateEndIndex,
                Y2              = price,
                StrokeThickness = 3,
                Opacity         = 0.8,
                Stroke          = new SolidColorBrush(colour)
            };

            if (strokeDashArray != null)
            {
                lineAnnotation.StrokeDashArray = strokeDashArray;
            }
            annotations.Add(lineAnnotation);
        }
Exemplo n.º 5
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            if (s.s != null)
            {
                s.send_command("s");
                datajson data = s.acquisisci();

                for (int i = 0; i < data.ch1.Length; i++)
                {
                    chart1.Series["ch1"].Points.AddXY((double)x, (double)data.ch1[i]);
                    chart1.Series["ch1Point"].Points.AddXY((double)x, (double)data.ch1[i]);
                    chart1.Series["ch1filter"].Points.AddXY((double)x, (double)data.ch1filter[i]);
                    chart1.Series["ch1filterPoint"].Points.AddXY((double)x, (double)data.ch1filter[i]);
                    chart1.Series["rms"].Points.AddXY((double)x, (double)data.rms);
                    chart1.Series["rmsPoint"].Points.AddXY((double)x, (double)data.rms);

                    chart1.Series["ch2"].Points.AddXY((double)x, (double)data.ch2[i]);
                    chart1.Series["ch2Point"].Points.AddXY((double)x, (double)data.ch2[i]);
                    chart1.Series["ch2filter"].Points.AddXY((double)x, (double)data.ch2filter[i]);
                    chart1.Series["ch2filterPoint"].Points.AddXY((double)x, (double)data.ch2filter[i]);
                    chart1.Series["rms2"].Points.AddXY((double)x, (double)data.rms2);

                    x++;
                }

                LineAnnotation annotation2  = new LineAnnotation();
                double         maxDataPoint = chart1.ChartAreas[0].AxisY.Maximum;
                double         minDataPoint = chart1.ChartAreas[0].AxisY.Minimum;
                annotation2.IsSizeAlwaysRelative = false;
                annotation2.AxisX     = chart1.ChartAreas[0].AxisX;
                annotation2.AxisY     = chart1.ChartAreas[0].AxisY;
                annotation2.AnchorY   = minDataPoint;
                annotation2.Height    = maxDataPoint - minDataPoint;;
                annotation2.Width     = 0;
                annotation2.LineWidth = 3;
                annotation2.StartCap  = LineAnchorCapStyle.None;
                annotation2.EndCap    = LineAnchorCapStyle.None;
                annotation2.AnchorX   = chart1.Series["ch1"].Points.Count - 1; // <- your point
                annotation2.LineColor = Color.DarkRed;                         // <- your color
                chart1.Annotations.Add(annotation2);
            }
        }
Exemplo n.º 6
0
        /// <summary>Draws the specified series definition on the view.</summary>
        /// <param name="definition">The definition.</param>
        private void DrawOnView(List <Annotation> annotations)
        {
            double minimumX         = graphView.AxisMinimum(Axis.AxisType.Bottom);
            double maximumX         = graphView.AxisMaximum(Axis.AxisType.Bottom);
            double minimumY         = graphView.AxisMinimum(Axis.AxisType.Left);
            double maximumY         = graphView.AxisMaximum(Axis.AxisType.Left);
            double majorStepY       = graphView.AxisMajorStep(Axis.AxisType.Left);
            double lowestAxisScale  = Math.Min(minimumX, minimumY);
            double largestAxisScale = Math.Max(maximumX, maximumY);

            for (int i = 0; i < annotations.Count; i++)
            {
                if (annotations[i] is TextAnnotation)
                {
                    TextAnnotation textAnnotation = annotations[i] as TextAnnotation;
                    if (textAnnotation.x is double && ((double)textAnnotation.x) == double.MinValue)
                    {
                        double interval = (largestAxisScale - lowestAxisScale) / 10; // fit 10 annotations on graph.

                        double yPosition = largestAxisScale - i * interval;
                        double xPosition = minimumX + (maximumX - minimumX) * 0.01;
                        graphView.DrawText(textAnnotation.text, xPosition, yPosition,
                                           textAnnotation.leftAlign, textAnnotation.textRotation,
                                           Axis.AxisType.Bottom, Axis.AxisType.Left, textAnnotation.colour);
                    }
                    else
                    {
                        graphView.DrawText(textAnnotation.text, textAnnotation.x, textAnnotation.y,
                                           textAnnotation.leftAlign, textAnnotation.textRotation,
                                           Axis.AxisType.Bottom, Axis.AxisType.Left, textAnnotation.colour);
                    }
                }
                else
                {
                    LineAnnotation lineAnnotation = annotations[i] as LineAnnotation;

                    graphView.DrawLine(lineAnnotation.x1, lineAnnotation.y1,
                                       lineAnnotation.x2, lineAnnotation.y2,
                                       lineAnnotation.type, lineAnnotation.thickness, lineAnnotation.colour);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Set the annotation for selected MS feature.
        /// </summary>
        private void SetMsFeatureAnnotation()
        {
            if (this.SelectedMsFeature == null)
            {
                return;
            }

            this.XicPlotModel.Annotations.Clear();
            var annotation = new LineAnnotation
            {
                X               = this.SelectedMsFeature.Net,
                TextColor       = OxyColors.Gray,
                Text            = this.SelectedMsFeature.Net.ToString("0.###"),
                TextOrientation = AnnotationTextOrientation.Vertical,
                LineStyle       = LineStyle.Dash,
                Type            = LineAnnotationType.Vertical,
            };

            this.XicPlotModel.Annotations.Add(annotation);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
        private static void CreateFileModel(
            File file,
            string[] sourceLines,
            out List<LineAnnotation> beginAnnotations,
            out List<LineAnnotation> endAnnotations,
            out Line[] lines)
        {
            beginAnnotations = new List<LineAnnotation>();
            endAnnotations = new List<LineAnnotation>();
            lines = sourceLines.Select((x, i) => new Line() {Source = x, Number = i + 1}).ToArray();

            foreach (var annotation in file.Annotations)
            {
                var lineAnnotation = new LineAnnotation()
                {
                    Category = annotation.Category,
                    Message = annotation.Message,
                    References = annotation.References,
                    Type = annotation.Type,
                };
                if (annotation.Line <= 0)
                {
                    beginAnnotations.Add(lineAnnotation);
                }
                else if (annotation.Line > lines.Length)
                {
                    endAnnotations.Add(lineAnnotation);
                }
                else
                {
                    var size = annotation.Size > 0 ? annotation.Size : 1;
                    for (var i = annotation.Line; i < annotation.Line + size; i++)
                    {
                        var line = lines[i-1];
                        line.Count++;
                        line.Markers.Add(annotation.Type);
                    }
                    lines[Math.Min(annotation.Line + size - 2, lines.Length-1)].LineAnnotations.Add(lineAnnotation);
                }
            }
        }
Exemplo n.º 11
0
        private void HistogramBreaksChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            Histogram.Annotations.Clear();

            foreach (var item in visualizationViewModel.HistogramBreaks)
            {
                var histogramBreak = item.Item1;

                var annotation = new LineAnnotation
                {
                    X     = histogramBreak,
                    Type  = OxyPlot.Annotations.LineAnnotationType.Vertical,
                    Color = Colors.Red,
                    Text  = item.Item2
                };

                Histogram.Annotations.Add(annotation);

                Histogram.InvalidatePlot(true);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// リアルタイム表示用プロットモデル初期設定
        /// </summary>
        public void InitPlotModelRT()
        {
            PlotModelRT.Title       = "Sound Data Realtime Display";
            PlotModelRT.PlotMargins = new OxyThickness(50.0, 0.0, 10.0, 40.0);

            var seriesRT = new LineSeries();

            seriesRT.Title           = "line1";
            seriesRT.ItemsSource     = DataPointsRT;//ListをImageSourceに設定
            seriesRT.Color           = OxyColor.Parse("#4CAF50");
            seriesRT.StrokeThickness = 1;
            PlotModelRT.Series.Add(seriesRT);

            //センターライン描画
            var lineAnnotation = new LineAnnotation();

            lineAnnotation.Type  = LineAnnotationType.Horizontal;
            lineAnnotation.Y     = 0;
            lineAnnotation.Color = OxyColors.Blue;
            PlotModelRT.Annotations.Add(lineAnnotation);

            var linearAxis1 = new LinearAxis();

            linearAxis1.Minimum         = -0.1;
            linearAxis1.Maximum         = 0.1;
            linearAxis1.AbsoluteMinimum = -1.0;
            linearAxis1.AbsoluteMaximum = 1.0;
            linearAxis1.Title           = "Sound Level";
            PlotModelRT.Axes.Add(linearAxis1);

            var linearAxis2 = new LinearAxis();

            linearAxis2.Position      = AxisPosition.Bottom;
            linearAxis2.Title         = "Time";
            linearAxis2.Unit          = "sec";
            linearAxis2.Minimum       = -0.51;
            linearAxis2.Maximum       = 0.0;
            linearAxis2.IsZoomEnabled = false;
            PlotModelRT.Axes.Add(linearAxis2);
        }
Exemplo n.º 13
0
        private LineAnnotation AddPlotAnnotationLine(double yval, string label, OxyColor color)
        {
            LineAnnotation line = new LineAnnotation
            {
                StrokeThickness = 1,
                Color           = color,
                Type            = LineAnnotationType.Horizontal,
                Text            = label,
                TextColor       = OxyColors.Black,
                Y = yval,
                X = 0
            };

            if (!plotModel.Annotations.Contains(line))
            {
                plotModel.Annotations.Add(line);
                int index = plotModel.Annotations.IndexOf(line);
                plotModel.InvalidatePlot(true);
            }

            return(line);
        }
Exemplo n.º 14
0
        /**
         * Creates annotation, type of annotation is taken from given properties
         */
        public static Annotation CreateAnnotation(Document doc, Page page, int index, AnnotationProperties props)
        {
            Annotation ann      = null;
            int        addAfter = index - 1;

            switch (props.Subtype)
            {
            case "Line": ann = new LineAnnotation(page, props.BoundingRect, props.StartPoint, props.EndPoint, addAfter); break;

            case "Circle": ann = new CircleAnnotation(page, props.BoundingRect, addAfter); break;

            case "Square": ann = new SquareAnnotation(page, props.BoundingRect, addAfter); break;

            case "FreeText": ann = new FreeTextAnnotation(page, props.BoundingRect, "", addAfter); break;

            case "PolyLine": ann = new PolyLineAnnotation(page, props.BoundingRect, props.Vertices, addAfter); break;

            case "Polygon": ann = new PolygonAnnotation(page, props.BoundingRect, props.Vertices, addAfter); break;

            case "Link": ann = new LinkAnnotation(page, props.BoundingRect, addAfter); break;

            case "Ink": ann = new InkAnnotation(page, props.BoundingRect, addAfter); break;

            case "Underline": ann = new UnderlineAnnotation(page, addAfter, props.Quads); break;

            case "Highlight": ann = new HighlightAnnotation(page, addAfter, props.Quads); break;

            default: throw new Exception("Logic error");
            }
            AnnotationAppearance app = new AnnotationAppearance(doc, ann);

            app.CaptureAnnotation();
            app.Properties.SetFrom(props);
            app.Properties.Dirty = true;
            app.UpdateAppearance();
            app.ReleaseAnnotation();
            return(ann);
        }
Exemplo n.º 15
0
        public override void OnModifierMouseDown(ModifierMouseArgs e)
        {
            if (_currentLine == null)
            {
                if (_chartingService.ChartMode == ChartMode.AddLine)
                {
                    var xy = GetXY(e.MousePoint, ParentSurface, ModifierSurface);
                    var id = Guid.NewGuid();
                    _currentLine = CreateLine(e, ParentSurface, xy.X, xy.Y, id);

                    if (LinkedChartSurface != null)
                    {
                        _currentLinkedLine = CreateLine(e, LinkedChartSurface, xy.X, xy.Y, id);
                    }

                    e.Handled = true;
                }
                else
                {
                    e.Handled = false;
                }
            }
            else
            {
                _currentLine.IsEditable = true;
                _currentLine            = null;
                if (_currentLinkedLine != null)
                {
                    _currentLinkedLine.IsEditable = true;
                    _currentLinkedLine            = null;
                }

                _chartingService.ChartMode = null;
                e.Handled = true;

                _chartingService.RaiseChartLinesChanged();
            }
        }
Exemplo n.º 16
0
        public void AddAnnotations(int n)
        {
            var points = GetFirst().Points;

            if (points.Count == 0)
            {
                return;
            }
            var lastPoint  = points.Max(x => x.X);
            var firstPoint = points.Min(x => x.X);

            var beginingDate = DateTimeAxis.ToDateTime(firstPoint);

            var    lastDate = DateTimeAxis.ToDateTime(lastPoint);
            double Y        = 70;
            var    hours    = (int)(lastDate - beginingDate).TotalHours;
            var    date     = beginingDate;
            double X        = DateTimeAxis.ToDouble(date);

            for (int i = 0; i < hours / n; i++)
            {
                LineAnnotation Line = new LineAnnotation()
                {
                    Tag             = "period",
                    StrokeThickness = 2,
                    Color           = OxyColors.Green,
                    Type            = LineAnnotationType.Vertical,
                    Text            = Y.ToString(),
                    TextColor       = OxyColors.White,
                    X         = X,
                    LineStyle = LineStyle.Dash,
                };
                Annotations.Add(Line);
                date = date.AddHours(n);
                X    = DateTimeAxis.ToDouble(date);
            }
        }
        public static void Run()
        {
            // ExStart:UseMeasureWithLineAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Miscellaneous();

            Document       doc  = new Document(dataDir + "input.pdf");
            Rectangle      rect = new Rectangle(260, 630, 451, 662);
            LineAnnotation line = new LineAnnotation(doc.Pages[1], rect, new Point(266, 657), new Point(446, 656));

            line.Color = Color.Red;

            // Set extension line parameters.
            line.LeaderLine          = -15;
            line.LeaderLineExtension = 5;

            // Set line endings
            line.StartingStyle = LineEnding.OpenArrow;
            line.EndingStyle   = LineEnding.OpenArrow;

            // Create Measure element
            line.Measure = new Measure(line);
            line.Measure.DistanceFormat = new Measure.NumberFormatList(line.Measure);
            line.Measure.DistanceFormat.Add(new Measure.NumberFormat(line.Measure));
            line.Measure.DistanceFormat[1].UnitLabel         = "mm";
            line.Measure.DistanceFormat[1].FractionSeparator = ".";
            line.Measure.DistanceFormat[1].ConvresionFactor  = 1;

            // Text of measure line
            line.Contents = "155 mm";
            // This must be set to show the text.
            line.ShowCaption     = true;
            line.CaptionPosition = CaptionPosition.Top;
            doc.Pages[1].Annotations.Add(line);
            doc.Save(dataDir + "UseMeasureWithLineAnnotation_out.pdf");
            // ExEnd:UseMeasureWithLineAnnotation
        }
Exemplo n.º 18
0
        /// <summary>
        /// グラフにエリアを追加します。
        /// </summary>
        /// <param name="title">エリアのタイトル。</param>
        /// <param name="color">エリアの色。</param>
        /// <param name="minX">横軸の最小値。</param>
        /// <param name="maxX">横軸の最大値。</param>
        /// <param name="minY">縦軸の最小値。</param>
        /// <param name="maxY">縦軸の最大値。</param>
        public void AddArea(string title, OxyColor color, int minX, int maxX, int minY, int maxY)
        {
            var area = new RectangleAnnotation
            {
                Fill     = color,
                MinimumX = minX,
                MaximumX = maxX,
                MinimumY = minY,
                MaximumY = maxY,
                Text     = title,
                TextVerticalAlignment = OxyPlot.VerticalAlignment.Bottom,
                Layer = AnnotationLayer.BelowAxes,
            };

            var line = new LineAnnotation
            {
                Color = OxyColors.Black,
                Type  = LineAnnotationType.Vertical,
                X     = maxX,
            };

            PlotModel.Annotations.Add(area);
            PlotModel.Annotations.Add(line);
        }
Exemplo n.º 19
0
        private void StepButton_Click(object sender, RoutedEventArgs e)
        {
            if (steps % 2 == 0)
            {
                var annotation = new LineAnnotation();
                annotation.Color     = OxyColors.Blue;
                annotation.MinimumY  = 0;
                annotation.MaximumY  = 40;
                annotation.X         = axesValues[0][steps / 2];
                annotation.LineStyle = LineStyle.Solid;
                annotation.Type      = LineAnnotationType.Vertical;
                viewModel.MyModel.Annotations.Add(annotation);
            }
            if (steps % 2 == 1)
            {
                var annotation = new LineAnnotation();
                annotation.Color     = OxyColors.Blue;
                annotation.MinimumX  = 0;
                annotation.MaximumX  = 40;
                annotation.Y         = axesValues[1][steps / 2];
                annotation.LineStyle = LineStyle.Solid;
                annotation.Type      = LineAnnotationType.Horizontal;
                viewModel.MyModel.Annotations.Add(annotation);
            }

            steps++;
            if (steps >= lines)
            {
                stepButton.IsEnabled = false;
                steps = 0;
                lines = 0;
            }
            this.DataContext = null;
            this.DataContext = viewModel;
            plot.InvalidatePlot(true);
        }
Exemplo n.º 20
0
 private void DrawEverything(object sender, RoutedEventArgs e)
 {
     for (int i = 0; i < axesValues.Count; i++)
     {
         for (int j = 0; j < axesValues[i].Count; j++)
         {
             if (i == 0)
             {
                 var annotation = new LineAnnotation();
                 annotation.Color     = OxyColors.Blue;
                 annotation.MinimumY  = -100;
                 annotation.MaximumY  = 100;
                 annotation.X         = axesValues[i][j];
                 annotation.LineStyle = LineStyle.Solid;
                 annotation.Type      = LineAnnotationType.Vertical;
                 viewModel.MyModel.Annotations.Add(annotation);
             }
             if (i == 1)
             {
                 var annotation = new LineAnnotation();
                 annotation.Color     = OxyColors.Blue;
                 annotation.MinimumX  = -100;
                 annotation.MaximumX  = 100;
                 annotation.Y         = axesValues[i][j];
                 annotation.LineStyle = LineStyle.Solid;
                 annotation.Type      = LineAnnotationType.Horizontal;
                 viewModel.MyModel.Annotations.Add(annotation);
             }
             Console.Write(axesValues[i][j] + " ");
         }
         Console.WriteLine();
     }
     this.DataContext = null;
     this.DataContext = viewModel;
     plot.InvalidatePlot(true);
 }
Exemplo n.º 21
0
        public virtual void AddAnnotation(IMarkerViewModel mvm)
        {
            mvm.PropertyChanged += (a, b) =>
            {
                foreach (LineAnnotation item in this.PlotModel.Annotations)
                {
                    if (item.Tag == a)
                    {
                        item.X    = OxyPlot.Axes.DateTimeAxis.ToDouble(mvm.Time);
                        item.Text = mvm.Title;
                        this.PlotModel.InvalidatePlot(false);
                    }
                }
            };

            var vline = new LineAnnotation();

            vline.Type = LineAnnotationType.Vertical;
            vline.X    = OxyPlot.Axes.DateTimeAxis.ToDouble(mvm.Time);
            vline.Text = mvm.Title;
            vline.Tag  = mvm;
            this.PlotModel.Annotations.Add(vline);
            this.PlotModel.InvalidatePlot(false);
        }
Exemplo n.º 22
0
        public MainPage()
        {
            this.InitializeComponent();

            for (int i = 0; i < 10; i++)
            {
                PlotView Plot = new PlotView();
                Plot.Height = 200;
                var model = new PlotModel();

                model.Series.Add(new FunctionSeries(System.Math.Sin, 0, 10, 0.01, "sin(x)"));
                Plot.Model = model;

                var annotation = new LineAnnotation()
                {
                    Type        = LineAnnotationType.Vertical,
                    ClipByXAxis = false,
                    X           = 0,
                };
                Plot.Model.Annotations.Add(annotation);
                annotations.Add(annotation);
                stack.Children.Add(Plot);
            }
        }
        public static void Run()
        {
            // ExStart:UseMeasureWithLineAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Miscellaneous();

            Document doc = new Document( dataDir + "input.pdf");
            Rectangle rect = new Rectangle(260, 630, 451, 662);
            LineAnnotation line = new LineAnnotation(doc.Pages[1], rect, new Point(266, 657), new Point(446, 656));
            line.Color = Color.Red;

            // Set extension line parameters.
            line.LeaderLine = -15;
            line.LeaderLineExtension = 5;

            // Set line endings
            line.StartingStyle = LineEnding.OpenArrow;
            line.EndingStyle = LineEnding.OpenArrow;

            // Create Measure element
            line.Measure = new Measure(line);
            line.Measure.DistanceFormat = new Measure.NumberFormatList(line.Measure);
            line.Measure.DistanceFormat.Add(new Measure.NumberFormat(line.Measure));
            line.Measure.DistanceFormat[1].UnitLabel = "mm";
            line.Measure.DistanceFormat[1].FractionSeparator = ".";
            line.Measure.DistanceFormat[1].ConvresionFactor = 1;

            // Text of measure line
            line.Contents = "155 mm";
            // This must be set to show the text.
            line.ShowCaption = true;
            line.CaptionPosition = CaptionPosition.Top;
            doc.Pages[1].Annotations.Add(line);
            doc.Save(dataDir + "UseMeasureWithLineAnnotation_out.pdf");
            // ExEnd:UseMeasureWithLineAnnotation
        }
Exemplo n.º 24
0
        //---------チャート関係---------------
        //チャートにannotationを追加
        private void Create_Ano()
        {
            LineAnnotation ano1 = new LineAnnotation();
            LineAnnotation ano2 = new LineAnnotation();
            LineAnnotation ano3 = new LineAnnotation();
            LineAnnotation ano4 = new LineAnnotation();

            ano1.AxisX = chart1.ChartAreas[0].AxisX;
            ano2.AxisX = chart1.ChartAreas[0].AxisX;
            ano3.AxisX = chart2.ChartAreas[0].AxisX;
            ano4.AxisX = chart2.ChartAreas[0].AxisX;
            ano1.AxisY = chart1.ChartAreas[0].AxisY;
            ano2.AxisY = chart1.ChartAreas[0].AxisY;
            ano3.AxisY = chart2.ChartAreas[0].AxisY;
            ano4.AxisY = chart2.ChartAreas[0].AxisY;

            ano1.IsSizeAlwaysRelative = false;
            ano2.IsSizeAlwaysRelative = false;
            ano3.IsSizeAlwaysRelative = false;
            ano4.IsSizeAlwaysRelative = false;

            ano1.LineColor = Color.Red;
            ano2.LineColor = Color.Red;
            ano3.LineColor = Color.Red;
            ano4.LineColor = Color.Red;

            ano1.Name = "Line1";
            ano2.Name = "Line2";
            ano3.Name = "Line1";
            ano4.Name = "Line2";

            chart1.Annotations.Add(ano1);
            chart1.Annotations.Add(ano2);
            chart2.Annotations.Add(ano3);
            chart2.Annotations.Add(ano4);
        }
Exemplo n.º 25
0
        static void GenerateGraph(ImagePlot plot)
        {
            PlotModel model = new PlotModel {
                Title = plot.name
            };

            model.LegendTitle = "Descriptor";
            if (arguments.Flip)
            {
                model.LegendTitle = "Image";
            }

            float maxPrecision = 0;
            int   colorIndex   = 0;

            foreach (DescriptorData data in plot.descriptors)
            {
                String title = data.descriptor;
                if (arguments.Flip)
                {
                    title = data.image;
                }

                title += " (" + data.correctMatches + "/" + data.totalMatches + ")";


                LineSeries line = new LineSeries {
                    Title = title, Color = colors[colorIndex++ % colors.Length]
                };
                for (int i = 0; i < data.pointData.Count; i++)
                {
                    maxPrecision = Math.Max(maxPrecision, data.pointData[i].precision);
                    line.Points.Add(new DataPoint(data.pointData[i].precision, data.pointData[i].recall));
                }
                model.Series.Add(line);
            }

            // If global scale is on, we'll use that instead.
            if (arguments.GlobalScale)
            {
                maxPrecision = globalScaleMax;
            }

            // Add some padding
            maxPrecision = (float)Math.Min(maxPrecision + (maxPrecision * .2), 1.2f);

            // If we aren't scaling, just set it to 1.0
            if (!arguments.Scale && !arguments.GlobalScale)
            {
                maxPrecision = 1.0f;
            }

            LineAnnotation max = new LineAnnotation {
                Type = LineAnnotationType.Vertical, X = 1.0, Color = OxyColors.LightGray, LineStyle = OxyPlot.LineStyle.Dash
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = 0.0, Maximum = maxPrecision, Title = "Recall"
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = 0.0, Maximum = 1.05, Title = "Precision"
            });
            model.Annotations.Add(max);

            plot.plot = model;
        }
        private void WriteAnnotationDiv(StreamWriter sw, LineAnnotation annotation)
        {
            sw.WriteLine(
                "<tr><td colspan='3'>&nbsp;</td><td><div class='annotationdiv {0}'><div class='code'>{1}<br/>{2}</div>",
                annotation.Type,
                annotation.Category,
                WebUtility.HtmlEncode(annotation.Message));
            if (annotation.References != null && annotation.References.Length > 0)
            {
                sw.WriteLine("<ul><li class='heading'>See also:</li>");
                foreach (var reference in annotation.References)
                {
                    var filename = GetFileName(reference.Name) + ".html#line" + reference.Line;

                    string[] lines = null;
                    try
                    {
                        lines = System.IO.File.ReadAllLines(reference.Name);
                    }
                    catch (Exception ex)
                    {
                        Log.ErrorFormat("Read reference error {0}: {1}", reference.Name, ex.Message);
                    }

                    if(lines == null)
                        continue;

                    sw.WriteLine(
                        "<li><a href='{0}'>{1}</a><br/>",
                        filename,
                        WebUtility.HtmlEncode(reference.Name));

                    sw.WriteLine("<div class='annotationdiv {0}'><table class='lineAnalysis'><tbody>", annotation.Type);

                    var size = reference.Size > 0 ? reference.Size : 1;
                    for(var i = reference.Line; (i < reference.Line + size) && i-1 < lines.Length && i >= 1; i++)
                    {
                        sw.WriteLine(
                            "<tr><td class='rightmargin right'><div class='code'>{0}</div></td><td><code>{1}</code></td></tr>",
                            i,
                            WebUtility.HtmlEncode(lines[i-1]).Replace(" ", "&nbsp;"));
                    }
                    sw.WriteLine("</tbody></table></div>");
                    sw.WriteLine("</li>");
                }

                sw.WriteLine("</ul>");
            }
            sw.WriteLine("</td></tr>");
        }
Exemplo n.º 27
0
        public OxyArea(OxyAreaSettings settings, OxyChartPainter owner)
        {
            this.chart_name = owner.chart_name;

            area_settings = settings;
            Tag           = area_settings.Tag;
            this.owner    = owner;

            candles_in_run = area_settings.candles_in_run;
            empty_gap      = area_settings.empty_gap;

            plot_model = new PlotModel()
            {
                PlotAreaBorderThickness = new OxyThickness(0),
                TextColor         = OxyColors.AliceBlue,
                EdgeRenderingMode = EdgeRenderingMode.PreferSpeed
            };

            plot_view = new PlotView()
            {
                Background = area_settings.Brush_background,
            };

            drawed_name = new CustomTextAnnotation()
            {
                Text       = (string)Tag,
                TextColor  = OxyColor.FromArgb(255, 98, 103, 113),
                Background = OxyColors.Transparent,
                Stroke     = OxyColors.Transparent,
                Tag        = "drawed_name",
                Layer      = OxyPlot.Annotations.AnnotationLayer.AboveSeries,
                TextHorizontalAlignment = HorizontalAlignment.Left,
                TextVerticalAlignment   = VerticalAlignment.Middle,
                FontSize = 24,
            };

            annotation_price = new CustomTextAnnotation()
            {
                Layer                   = AnnotationLayer.AboveSeries,
                ClipByXAxis             = false,
                ClipByYAxis             = false,
                Background              = OxyColor.Parse("#FF5500"),
                TextColor               = OxyColors.AliceBlue,
                Stroke                  = OxyColor.Parse("#FF5500"),
                TextHorizontalAlignment = HorizontalAlignment.Right,
                TextVerticalAlignment   = VerticalAlignment.Middle,
                Padding                 = new OxyThickness(2),
                EdgeRenderingMode       = EdgeRenderingMode.PreferSpeed,
                Tag = "annotation_price"
            };


            annotation_date_time = new CustomTextAnnotation()
            {
                Layer                   = AnnotationLayer.AboveSeries,
                ClipByXAxis             = false,
                ClipByYAxis             = true,
                Background              = OxyColor.Parse("#FF5500"),
                TextColor               = OxyColors.AliceBlue,
                Stroke                  = OxyColor.Parse("#FF5500"),
                TextHorizontalAlignment = HorizontalAlignment.Center,
                TextVerticalAlignment   = VerticalAlignment.Bottom,
                Padding                 = new OxyThickness(2),
                EdgeRenderingMode       = EdgeRenderingMode.PreferSpeed,
                Tag = "annotation_date_time"
            };


            date_time_axis_X = new DateTimeAxis()
            {
                TicklineColor          = area_settings.TicklineColor,
                AxislineStyle          = area_settings.AxislineStyle,
                AxislineThickness      = 1,
                AxislineColor          = area_settings.AxislineColor,
                MajorGridlineColor     = area_settings.MajorGridlineColor,
                MajorGridlineStyle     = area_settings.MajorGridlineStyle,
                MajorGridlineThickness = area_settings.MajorGridlineThickness,
                MinorGridlineColor     = area_settings.MinorGridlineColor,
                MinorGridlineStyle     = area_settings.MinorGridlineStyle,
                MinorGridlineThickness = area_settings.MinorGridlineThickness,
                Key               = "DateTime",
                IsAxisVisible     = false,
                Position          = AxisPosition.Bottom,
                EdgeRenderingMode = area_settings.EdgeRenderingMode,
            };


            linear_axis_Y = new LinearAxis()
            {
                TicklineColor          = area_settings.TicklineColor,
                AxislineStyle          = area_settings.AxislineStyle,
                AxislineThickness      = 1,
                AxislineColor          = area_settings.AxislineColor,
                MajorGridlineColor     = area_settings.MajorGridlineColor,
                MajorGridlineStyle     = area_settings.MajorGridlineStyle,
                MajorGridlineThickness = area_settings.MajorGridlineThickness,
                MinorGridlineColor     = area_settings.MinorGridlineColor,
                MinorGridlineStyle     = area_settings.MinorGridlineStyle,
                MinorGridlineThickness = area_settings.MinorGridlineThickness,
                IsAxisVisible          = false,
                Layer             = AxisLayer.BelowSeries,
                Position          = AxisPosition.Right,
                EdgeRenderingMode = area_settings.EdgeRenderingMode,
            };


            if (settings.cursor_Y_is_active)
            {
                cursor_Y = new LineAnnotation()
                {
                    Type              = LineAnnotationType.Vertical,
                    Color             = area_settings.CursorColor,
                    Selectable        = false,
                    ClipByYAxis       = false,
                    X                 = double.MinValue,
                    StrokeThickness   = 0.5,
                    Layer             = AnnotationLayer.BelowSeries,
                    EdgeRenderingMode = EdgeRenderingMode.Automatic,
                    LineStyle         = LineStyle.LongDash
                };
            }

            if (settings.cursor_X_is_active)
            {
                cursor_X = new LineAnnotation()
                {
                    Type              = LineAnnotationType.Horizontal,
                    Color             = area_settings.CursorColor,
                    ClipByXAxis       = false,
                    Selectable        = false,
                    Y                 = double.MinValue,
                    StrokeThickness   = 0.5,
                    Layer             = AnnotationLayer.BelowSeries,
                    EdgeRenderingMode = EdgeRenderingMode.Automatic,
                    LineStyle         = LineStyle.LongDash
                };
            }

            plot_model.Annotations.Add(annotation_price);
            plot_model.Annotations.Add(annotation_date_time);


            plot_model.Axes.Add(date_time_axis_X);
            plot_model.Axes.Add(linear_axis_Y);

            if (area_settings.cursor_X_is_active)
            {
                plot_model.Annotations.Add(cursor_X);
            }

            if (area_settings.cursor_Y_is_active)
            {
                plot_model.Annotations.Add(cursor_Y);
            }

            plot_view.Model = plot_model;
        }
Exemplo n.º 28
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());
            }
        }
Exemplo n.º 29
0
        public void GenerateChartData()
        {
            _chartsDraggablePointTooltip.Clear();
            _chartsDraggablePoints.Clear();
            _chartsRanges.Clear();
            for (var i = 0; i < PlotModels.Count; i++)
            {
                var chartIndex = i;

                void ChartAnnotationOnMouseDown(object sender, OxyMouseDownEventArgs e)
                {
                    AnnotationOnMouseDown(chartIndex, sender, e);
                }

                void ChartAnnotationOnMouseMove(object sender, OxyMouseEventArgs e)
                {
                    AnnotationOnMouseMove(chartIndex, sender, e);
                }

                void ChartAnnotationOnMouseUp(object sender, OxyMouseEventArgs e)
                {
                    AnnotationOnMouseUp(chartIndex, sender, e);
                }

                var plotModel  = PlotModels[i];
                var linePoints = GetPlotLinePoints(plotModel);
                plotModel.Annotations.Clear();
                linePoints.Clear();
                _chartsRanges.Add(new Dictionary <double, LineAnnotation>());
                _chartsDraggablePoints.Add(new Dictionary <double, PointAnnotation>());

                foreach (var pointValues in _chartsPointsValues[i])
                {
                    var point = new DataPoint(pointValues.X, pointValues.Y);
                    linePoints.Add(point);

                    var range = new LineAnnotation
                    {
                        Type            = LineAnnotationType.Vertical,
                        X               = pointValues.X,
                        MinimumY        = pointValues.MinValue,
                        MaximumY        = pointValues.MaxValue,
                        StrokeThickness = 8,
                        Color           = _rangesColor,
                        LineStyle       = LineStyle.Solid
                    };
                    _chartsRanges[i].Add(pointValues.X, range);
                    range.MouseDown += ChartAnnotationOnMouseDown;
                    range.MouseMove += ChartAnnotationOnMouseMove;
                    range.MouseUp   += ChartAnnotationOnMouseUp;
                    plotModel.Annotations.Add(range);

                    var draggablePoint = new PointAnnotation
                    {
                        X    = pointValues.X,
                        Y    = pointValues.Y,
                        Size = 8,
                        Fill = _colorPrimary
                    };
                    _chartsDraggablePoints[i].Add(pointValues.X, draggablePoint);
                    draggablePoint.MouseDown += ChartAnnotationOnMouseDown;
                    draggablePoint.MouseMove += ChartAnnotationOnMouseMove;
                    draggablePoint.MouseUp   += ChartAnnotationOnMouseUp;
                    plotModel.Annotations.Add(draggablePoint);
                }

                var draggablePointTooltip = new TextAnnotation
                {
                    Background      = _draggablePointTooltipFillColor,
                    Stroke          = _draggablePointTooltipStrokeColor,
                    StrokeThickness = 1,
                    Padding         = new OxyThickness(8, 2, 8, 2)
                };
                _chartsDraggablePointTooltip.Add(draggablePointTooltip);

                plotModel.Annotations.Add(draggablePointTooltip);
                plotModel.InvalidatePlot(false);
            }
        }
Exemplo n.º 30
0
        private PlotModel CreatePlotModel()
        {
            _timeAxis.Position               = AxisPosition.Bottom;
            _timeAxis.MajorGridlineStyle     = LineStyle.Solid;
            _timeAxis.MajorGridlineThickness = 1;
            _timeAxis.MajorGridlineColor     = OxyColor.FromRgb(192, 192, 192);
            _timeAxis.MinorGridlineStyle     = LineStyle.Solid;
            _timeAxis.MinorGridlineThickness = 1;
            _timeAxis.MinorGridlineColor     = OxyColor.FromRgb(232, 232, 232);
            _timeAxis.StartPosition          = 1;
            _timeAxis.EndPosition            = 0;
            _timeAxis.MinimumPadding         = 0;
            _timeAxis.MaximumPadding         = 0;
            _timeAxis.AbsoluteMinimum        = 0;
            _timeAxis.Minimum         = 0;
            _timeAxis.AbsoluteMaximum = 24 * 60 * 60;
            _timeAxis.Zoom(
                _settings.GetValue("plotPanel.MinTimeSpan", 0.0f),
                _settings.GetValue("plotPanel.MaxTimeSpan", 10.0f * 60));
            _timeAxis.StringFormat = "h:mm";

            var units = new Dictionary <SensorType, string>
            {
                { SensorType.Voltage, "V" },
                { SensorType.Clock, "MHz" },
                { SensorType.Temperature, "°C" },
                { SensorType.Load, "%" },
                { SensorType.Fan, "RPM" },
                { SensorType.Flow, "L/h" },
                { SensorType.Control, "%" },
                { SensorType.Level, "%" },
                { SensorType.Factor, "1" },
                { SensorType.Power, "W" },
                { SensorType.Data, "GB" },
                { SensorType.Frequency, "Hz" }
            };

            foreach (SensorType type in Enum.GetValues(typeof(SensorType)))
            {
                string typeName = type.ToString();
                var    axis     = new LinearAxis
                {
                    Position               = AxisPosition.Left,
                    MajorGridlineStyle     = LineStyle.Solid,
                    MajorGridlineThickness = 1,
                    MajorGridlineColor     = _timeAxis.MajorGridlineColor,
                    MinorGridlineStyle     = LineStyle.Solid,
                    MinorGridlineThickness = 1,
                    MinorGridlineColor     = _timeAxis.MinorGridlineColor,
                    AxislineStyle          = LineStyle.Solid,
                    Title = typeName,
                    Key   = typeName,
                };

                var annotation = new LineAnnotation
                {
                    Type            = LineAnnotationType.Horizontal,
                    ClipByXAxis     = false,
                    ClipByYAxis     = false,
                    LineStyle       = LineStyle.Solid,
                    Color           = OxyColors.Black,
                    YAxisKey        = typeName,
                    StrokeThickness = 2,
                };

                axis.AxisChanged      += (sender, args) => annotation.Y = axis.ActualMinimum;
                axis.TransformChanged += (sender, args) => annotation.Y = axis.ActualMinimum;

                axis.Zoom(_settings.GetValue("plotPanel.Min" + axis.Key, float.NaN), _settings.GetValue("plotPanel.Max" + axis.Key, float.NaN));

                if (units.ContainsKey(type))
                {
                    axis.Unit = units[type];
                }

                _axes.Add(type, axis);
                _annotations.Add(type, annotation);
            }

            var model = new ScaledPlotModel(_dpiXScale, _dpiYScale);

            model.Axes.Add(_timeAxis);
            foreach (LinearAxis axis in _axes.Values)
            {
                model.Axes.Add(axis);
            }
            model.IsLegendVisible = false;

            return(model);
        }
Exemplo n.º 31
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 = "";
            }
        }
Exemplo n.º 32
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);
            }
        }
Exemplo n.º 33
0
        public DBPPlot()
        {
            ShowAll();
            range = 60;

            HeightRequest = 150;
            WidthRequest  = 300;

            dati = new Punto[range];
            for (int i = 0; i <= dati.Length - 1; i++)
            {
                dati[i] = new Punto(i * (120 / range), 0);
            }

            model = new PlotModel
            {
                Title           = "Pressione Diastolica",
                TitleFontSize   = 10,
                Padding         = new OxyThickness(-10, 5, 5, -10),
                IsLegendVisible = false
            };

            line = new LineSeries
            {
                Title       = "DBP",
                Background  = OxyColors.White,
                Color       = OxyColors.Orange,
                LineStyle   = LineStyle.Solid,
                ItemsSource = dati,
            };
            model.Series.Add(line);

            LineAnnotation topGuide = new LineAnnotation
            {
                Text = "Ipertensione",
                TextVerticalAlignment = VerticalAlignment.Bottom,
                TextColor             = OxyColors.Blue,
                Type      = LineAnnotationType.Horizontal,
                LineStyle = LineStyle.Solid,
                Y         = 90
            };

            model.Annotations.Add(topGuide);

            LineAnnotation bottomGuide = new LineAnnotation
            {
                Text = "Ipotensione",
                TextVerticalAlignment = VerticalAlignment.Top,
                TextColor             = OxyColors.Blue,
                Type      = LineAnnotationType.Horizontal,
                LineStyle = LineStyle.Solid,
                Y         = 70
            };

            model.Annotations.Add(bottomGuide);

            Xaxis = new LinearAxis
            {
                Title         = "min",
                Position      = AxisPosition.Bottom,
                Maximum       = 120,
                IsPanEnabled  = false,
                IsZoomEnabled = false,

                /*
                 * MajorGridlineStyle = LineStyle.Solid,
                 * MajorGridlineColor = OxyColors.Gray,
                 * MinorGridlineStyle = LineStyle.Dot,
                 * MinorGridlineColor = OxyColors.Gray,
                 */
            };
            model.Axes.Add(Xaxis);

            Yaxis = new LinearAxis
            {
                Title           = "mmHg",
                TitleColor      = OxyColors.White,
                Position        = AxisPosition.Left,
                Maximum         = 200,
                AbsoluteMinimum = 0,

                /*
                 * MajorGridlineStyle = LineStyle.Solid,
                 * MajorGridlineColor = OxyColors.Gray,
                 * MinorGridlineStyle = LineStyle.Dot,
                 * MinorGridlineColor = OxyColors.Gray,
                 */
                Angle = 90
            };
            model.Axes.Add(Yaxis);

            Model = model;
        }
Exemplo n.º 34
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);
        }
        /// <summary>
        /// Draw a line on chart.
        /// </summary>
        /// <param name="sender">Source Chart.</param>
        /// <param name="x0">First point on XAxis.</param>
        /// <param name="x1">Second piont on XAxis.</param>
        /// <param name="y0">First point on YAxis.</param>
        /// <param name="y1">Second point on YAxis.</param>
        /// <param name="lineColor">Outline color.</param>
        /// <param name="name">Annotation name.</param>
        /// <param name="lineWidth">Line width</param>
        /// <param name="lineStyle">Line style</param>
        /// <param name="chartArea">Target ChartArea where annotation should be displayed. Default to first ChartArea if not defined.</param>
        public static Annotation DrawLine(this Chart sender, double x0, double x1,
            double y0, double y1, Drawing.Color lineColor, string name = "",
            int lineWidth = 1, ChartDashStyle lineStyle = ChartDashStyle.Solid, ChartArea chartArea = null)
        {
            LineAnnotation line = new LineAnnotation();
            string chartAreaName = (chartArea == null) ? sender.ChartAreas[0].Name : chartArea.Name;
            line.ClipToChartArea = chartAreaName;
            line.AxisXName = chartAreaName + "\\rX";
            line.YAxisName = chartAreaName + "\\rY";
            line.IsSizeAlwaysRelative = false;

            line.X = x0;
            line.Y = y0;
            line.Height = y1 - y0;
            line.Width = x1 - x0;
            line.LineColor = lineColor;
            line.LineWidth = lineWidth;
            line.LineDashStyle = lineStyle;
            sender.Annotations.Add(line);

            if (!string.IsNullOrEmpty(name)) line.Name = name;

            return line;
        }
Exemplo n.º 36
0
    private static LineAnnotation createArrowAnnotation(double valueXStart_, double valueY_, double valueYEnd_, Color color_)
    {
        var line = new LineAnnotation();
        line.Location.Type = Infragistics.UltraChart.Shared.Styles.LocationType.DataValues;
        line.Location.ValueX = valueXStart_;
        line.Location.ValueY = valueY_;

        line.Offset.Type = Infragistics.UltraChart.Shared.Styles.LocationType.DataValues;
        line.Offset.ValueX = valueXStart_;
        line.Offset.ValueY = valueYEnd_;

        line.OffsetMode = Infragistics.UltraChart.Shared.Styles.LocationOffsetMode.Manual;

        line.Color = color_;
        line.Style.EndStyle = LineCapStyle.ArrowAnchor;
        //line.Style = new LineStyle { DrawStyle = LineDrawStyle.Dot };
        line.Thickness = 4;
        return line;
    }
        public static PlotModel LineAnnotation()
        {
            var model = new PlotModel("LineAnnotation", "Click and drag the annotation line.");
            model.Axes.Add(new LinearAxis(AxisPosition.Bottom, -20, 80));
            model.Axes.Add(new LinearAxis(AxisPosition.Left, -10, 10));
            var la = new LineAnnotation { Type = LineAnnotationType.Vertical, X = 4 };
            la.MouseDown += (s, e) =>
                {
                    if (e.ChangedButton != OxyMouseButton.Left)
                    {
                        return;
                    }

                    la.StrokeThickness *= 5;
                    model.RefreshPlot(false);
                    e.Handled = true;
                };

            // Handle mouse movements (note: this is only called when the mousedown event was handled)
            la.MouseMove += (s, e) =>
                {
                    la.X = la.InverseTransform(e.Position).X;
                    model.RefreshPlot(false);
                    e.Handled = true;
                };
            la.MouseUp += (s, e) =>
                {
                    la.StrokeThickness /= 5;
                    model.RefreshPlot(false);
                    e.Handled = true;
                };
            model.Annotations.Add(la);
            return model;
        }
Exemplo n.º 38
0
        private void SetAnnotationType()
        {
            Chart1.Annotations.Clear();

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

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

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

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Polyline")
            {
                PolylineAnnotation annotation = new PolylineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];

                // 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);
            }
            else if(Annotation.SelectedItem.Value == "Text")
            {
                TextAnnotation annotation = new TextAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am a TextAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;

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

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Ellipse")
            {
                EllipseAnnotation annotation = new EllipseAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                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);
            }
            else if(Annotation.SelectedItem.Value == "Arrow")
            {
                ArrowAnnotation annotation = new ArrowAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Height = -25;
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Border3D")
            {
                Border3DAnnotation annotation = new Border3DAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                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);
            }
            else if(Annotation.SelectedItem.Value == "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);
            }
            else if(Annotation.SelectedItem.Value == "Polygon")
            {
                PolygonAnnotation annotation = new PolygonAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];

                // 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);
            }
            else if(Annotation.SelectedItem.Value == "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[2];
                annotation.Image = "MyBmp";

                Chart1.Annotations.Add(annotation);
            }
        }
Exemplo n.º 39
0
 public void LineAnnotation()
 {
     var s1 = new LineAnnotation();
     var s2 = new Annotations.LineAnnotation();
     OxyAssert.PropertiesAreEqual(s1, s2);
 }
Exemplo n.º 40
0
    private LineAnnotation createHorizontalLineAnnotation(double valueXStart_, double valueXEnd_, double valueY_,
      Color color_)
    {
      var line = new LineAnnotation();
      line.Location.Type = Infragistics.UltraChart.Shared.Styles.LocationType.DataValues;
      line.Location.ValueX = valueXStart_;
      line.Location.ValueY = valueY_;

      line.Offset.Type = Infragistics.UltraChart.Shared.Styles.LocationType.DataValues;
      line.Offset.ValueX = valueXEnd_;
      line.Offset.ValueY = valueY_;

      line.OffsetMode = Infragistics.UltraChart.Shared.Styles.LocationOffsetMode.Manual;

      line.Color = color_;

      return line;
    }